From 9256f1717ccb84122fe40f0ff98fb308053ba282 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 22:51:07 +0200 Subject: [PATCH 01/11] trying unlighthouse --- .gitlab-ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b26e06..cbdc4a9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - validate - build + - benchmark - deploy - post_deploy - scripts @@ -47,6 +48,24 @@ build-site: - public expire_in: 1 day +unlighthouse: + image: registry.gitlab.com/gitlab-ci-utils/lighthouse:latest + stage: benchmark + when: on_success + except: + - main + - tags + before_script: + - npm install @unlighthouse/cli puppeteer + - mkdir unlighthouse-reports + script: + - serve ./public/ > /dev/null 2>&1 & wait-on http://localhost:9101/ + - unlighthouse-ci http://localhost:3000 --site localhost:9101 --budget 75 --build-static --output-path ./unlighthouse-reports + artifacts: + paths: + - unlighthouse-reports + expire_in: 1 day + deploy-site: stage: deploy when: on_success From 6f9d4c71bb880dffe5bcb0b131e010d290384c56 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 23:07:13 +0200 Subject: [PATCH 02/11] trying unlighthouse with staging --- .gitlab-ci.yml | 72 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cbdc4a9..0f38576 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ stages: - validate - build - - benchmark - deploy + - benchmark - post_deploy - scripts @@ -48,24 +48,6 @@ build-site: - public expire_in: 1 day -unlighthouse: - image: registry.gitlab.com/gitlab-ci-utils/lighthouse:latest - stage: benchmark - when: on_success - except: - - main - - tags - before_script: - - npm install @unlighthouse/cli puppeteer - - mkdir unlighthouse-reports - script: - - serve ./public/ > /dev/null 2>&1 & wait-on http://localhost:9101/ - - unlighthouse-ci http://localhost:3000 --site localhost:9101 --budget 75 --build-static --output-path ./unlighthouse-reports - artifacts: - paths: - - unlighthouse-reports - expire_in: 1 day - deploy-site: stage: deploy when: on_success @@ -105,6 +87,43 @@ deploy-testing: - ssh $DEPLOY_USER@$DEPLOY_HOST "find staging -maxdepth 1 -printf '%p\n'; screen -S staging-firq-npx -dm npx serve staging/ -p 9100 -c serve.json" - echo "Staging environment is up!" +unlighthouse: + image: registry.gitlab.com/gitlab-ci-utils/lighthouse:latest + stage: benchmark + when: on_success + except: + - main + - tags + before_script: + - npm install @unlighthouse/cli puppeteer + - mkdir unlighthouse-reports + script: + - unlighthouse-ci --site staging.firq.dev --budget 75 --build-static --output-path ./unlighthouse-reports + - cp public/serve.json unlighthouse-reports + artifacts: + paths: + - unlighthouse-reports + expire_in: 1 day + +unlighthouse-output: + stage: post_deploy + when: on_success + except: + - tags + - main + before_script: + - *ssh_default + script: + - echo "Getting artifacts" + - ls unlighthouse-reports + - echo "Stopping screen session, cleaning" + - ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S unlighthouse-results kill; rm -r -f unlighthouse/*;" + - echo "Copying to proxmox machine" + - rsync -az --stats unlighthouse-reports/* $DEPLOY_USER@$DEPLOY_HOST:~/unlighthouse + - echo "Restarting screen session" + - ssh $DEPLOY_USER@$DEPLOY_HOST "find unlighthouse -maxdepth 1 -printf '%p\n'; screen -S unlighthouse -dm npx serve unlighthouse/ -p 9101 -c serve.json" + - echo "Website is up on https://firq.dev/" + success_notification: stage: post_deploy before_script: @@ -178,6 +197,21 @@ redeploy-staging: - ssh $DEPLOY_USER@$DEPLOY_HOST "screen -S staging-firq-npx -dm npx serve staging/ -p 9100 -c serve.json" - echo "Staging environment is up!" +redeploy-unlighthouse: + stage: scripts + when: manual + except: + - main + - tags + before_script: + - *ssh_default + script: + - echo "Stopping screen session" + - ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S unlighthouse-results kill" || true + - echo "Restarting screen session" + - ssh $DEPLOY_USER@$DEPLOY_HOST "screen -S unlighthouse-results -dm npx serve unlighthouse/ -p 9101 -c serve.json" + - echo "Staging environment is up!" + maintenance-deploy: stage: scripts when: manual From ee1d26a84d08ca30a1f779fb5e96be6542b98b49 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 23:21:53 +0200 Subject: [PATCH 03/11] missing g flag --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f38576..997cb10 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,7 @@ unlighthouse: - main - tags before_script: - - npm install @unlighthouse/cli puppeteer + - npm install -g @unlighthouse/cli puppeteer - mkdir unlighthouse-reports script: - unlighthouse-ci --site staging.firq.dev --budget 75 --build-static --output-path ./unlighthouse-reports From 13a48becd62be10f1c00394ded942a2a0d60c6e3 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 23:30:15 +0200 Subject: [PATCH 04/11] using path instead of -g --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 997cb10..1324689 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,10 +95,10 @@ unlighthouse: - main - tags before_script: - - npm install -g @unlighthouse/cli puppeteer + - npm install @unlighthouse/cli puppeteer - mkdir unlighthouse-reports script: - - unlighthouse-ci --site staging.firq.dev --budget 75 --build-static --output-path ./unlighthouse-reports + - node_modules/.bin/unlighthouse-ci --site staging.firq.dev --budget 75 --build-static --output-path ./unlighthouse-reports - cp public/serve.json unlighthouse-reports artifacts: paths: From 5edeaf9833540f147fe3216288227084bac5afb5 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 23:34:34 +0200 Subject: [PATCH 05/11] added chromium-sandbox --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1324689..ee50a9a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,6 +95,7 @@ unlighthouse: - main - tags before_script: + - apk update && apk add chromium-sandbox - npm install @unlighthouse/cli puppeteer - mkdir unlighthouse-reports script: From 84b43872d1eec2c78cf7430a663f39916239bf74 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 23:38:17 +0200 Subject: [PATCH 06/11] apt-get not apk --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee50a9a..1cfc6f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,7 @@ unlighthouse: - main - tags before_script: - - apk update && apk add chromium-sandbox + - apt-get update && apt-get -y install --no-install-recommends chromium-sandbox - npm install @unlighthouse/cli puppeteer - mkdir unlighthouse-reports script: From 38cc096e7e171b239f7f3e5934e9b8e4cb0de323 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 23:44:31 +0200 Subject: [PATCH 07/11] unlighthouse config --- unlighthouse.config.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 unlighthouse.config.ts diff --git a/unlighthouse.config.ts b/unlighthouse.config.ts new file mode 100644 index 0000000..ab8f97b --- /dev/null +++ b/unlighthouse.config.ts @@ -0,0 +1,5 @@ +export default { + puppeteerOptions: { + args: ["--no-sandbox", "--disable-setuid-sandbox"], + }, + } \ No newline at end of file From e8bed584a5eb8c04e9d1d8973d717036def33cf3 Mon Sep 17 00:00:00 2001 From: Firq Date: Sat, 8 Jul 2023 23:52:47 +0200 Subject: [PATCH 08/11] Finalized config --- .gitlab-ci.yml | 2 +- unlighthouse.config.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1cfc6f6..6c58b08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -99,7 +99,7 @@ unlighthouse: - npm install @unlighthouse/cli puppeteer - mkdir unlighthouse-reports script: - - node_modules/.bin/unlighthouse-ci --site staging.firq.dev --budget 75 --build-static --output-path ./unlighthouse-reports + - node_modules/.bin/unlighthouse-ci - cp public/serve.json unlighthouse-reports artifacts: paths: diff --git a/unlighthouse.config.ts b/unlighthouse.config.ts index ab8f97b..4e05d89 100644 --- a/unlighthouse.config.ts +++ b/unlighthouse.config.ts @@ -1,5 +1,12 @@ export default { + site: 'http://192.168.178.141:9100', puppeteerOptions: { args: ["--no-sandbox", "--disable-setuid-sandbox"], }, - } \ No newline at end of file + ci: { + budget: 90, + buildStatic: true + }, + auth: { username: "staging", password: "staging" }, + outputPath: "unlighthouse-reports", +} From b8dd3d41db80d75bacf7deae9c3d989700199848 Mon Sep 17 00:00:00 2001 From: Firq Date: Sun, 9 Jul 2023 00:06:17 +0200 Subject: [PATCH 09/11] Structure change and config --- .gitlab-ci.yml | 8 +++++--- unlighthouse.config.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6c58b08..42eb73e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -90,7 +90,7 @@ deploy-testing: unlighthouse: image: registry.gitlab.com/gitlab-ci-utils/lighthouse:latest stage: benchmark - when: on_success + when: manual except: - main - tags @@ -106,9 +106,11 @@ unlighthouse: - unlighthouse-reports expire_in: 1 day -unlighthouse-output: - stage: post_deploy +unlighthouse-publish: + stage: benchmark when: on_success + needs: + - unlighthouse except: - tags - main diff --git a/unlighthouse.config.ts b/unlighthouse.config.ts index 4e05d89..fbd6208 100644 --- a/unlighthouse.config.ts +++ b/unlighthouse.config.ts @@ -1,5 +1,5 @@ export default { - site: 'http://192.168.178.141:9100', + site: 'staging.firq.dev', puppeteerOptions: { args: ["--no-sandbox", "--disable-setuid-sandbox"], }, From d008b759c13a3c2f18228f920c90f05884876e7a Mon Sep 17 00:00:00 2001 From: Firq Date: Sun, 9 Jul 2023 00:11:15 +0200 Subject: [PATCH 10/11] Finalization --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 42eb73e..b838571 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,6 @@ unlighthouse: - main - tags before_script: - - apt-get update && apt-get -y install --no-install-recommends chromium-sandbox - npm install @unlighthouse/cli puppeteer - mkdir unlighthouse-reports script: @@ -125,7 +124,7 @@ unlighthouse-publish: - rsync -az --stats unlighthouse-reports/* $DEPLOY_USER@$DEPLOY_HOST:~/unlighthouse - echo "Restarting screen session" - ssh $DEPLOY_USER@$DEPLOY_HOST "find unlighthouse -maxdepth 1 -printf '%p\n'; screen -S unlighthouse -dm npx serve unlighthouse/ -p 9101 -c serve.json" - - echo "Website is up on https://firq.dev/" + - echo "Unlighthouse results are up!" success_notification: stage: post_deploy From f05f1659b03bb135de28e9c0714345ae209122f0 Mon Sep 17 00:00:00 2001 From: Firq Date: Sun, 9 Jul 2023 00:23:08 +0200 Subject: [PATCH 11/11] final --- src/pages/blog/deploying-this.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/blog/deploying-this.md b/src/pages/blog/deploying-this.md index c636c1a..55c5458 100644 --- a/src/pages/blog/deploying-this.md +++ b/src/pages/blog/deploying-this.md @@ -209,7 +209,6 @@ Funnily enough, this also taught me how to squash commits on main, as I had like ```shell git rebase -i origin/main~30 main -# do the rebase here git push origin +main ```