Skip to content

Commit 24afedc

Browse files
chore(ci): switch lighthouse to unlighthouse (#2338)
Co-authored-by: Jordan Arldt <jordan.arldt@bigcommerce.com>
1 parent 3969a62 commit 24afedc

8 files changed

Lines changed: 3278 additions & 227 deletions

.github/workflows/.lighthouserc-desktop.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/lighthouseCommentMaker.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/pull-request-data.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/regression-tests.yml

Lines changed: 24 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5,100 +5,40 @@ on:
55
states: ['success']
66

77
env:
8-
PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }}
98
VERCEL_PROTECTION_BYPASS: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
10-
BIGCOMMERCE_ACCESS_TOKEN: ${{ secrets.BIGCOMMERCE_ACCESS_TOKEN }}
11-
BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }}
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.deployment_status.target_url }}
12+
cancel-in-progress: true
1213

1314
jobs:
14-
generate-lighthouse-audit:
15-
name: Lighthouse Audit
16-
timeout-minutes: 30
17-
runs-on: ubuntu-latest
15+
unlighthouse-audit:
1816
if: ${{ contains(fromJson('["Production – catalyst-canary", "Preview – catalyst-canary"]'), github.event.deployment_status.environment) }}
17+
name: Unlighthouse Audit - ${{ matrix.device }}
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
device: [desktop, mobile]
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.deployment_status.target_url }}-${{ matrix.device }}
24+
cancel-in-progress: true
1925

2026
steps:
2127
- name: Checkout code
2228
uses: actions/checkout@v4
23-
24-
- name: Pull Request Details
25-
id: pr_details
26-
uses: actions/github-script@v7
2729
with:
28-
script: |
29-
const prData = require('./.github/workflows/pull-request-data.js');
30-
await prData({ github, context, core });
30+
fetch-depth: 0
3131

32-
- name: Lighthouse house audit on desktop
33-
id: lighthouse_audit_desktop
34-
uses: treosh/lighthouse-ci-action@v11
35-
with:
36-
urls: |
37-
${{ github.event.deployment_status.target_url }}
38-
configPath: '.github/workflows/.lighthouserc-desktop.json'
39-
temporaryPublicStorage: true
40-
runs: 3
41-
42-
- name: Lighthouse audit on mobile
43-
id: lighthouse_audit_mobile
44-
uses: treosh/lighthouse-ci-action@v11
45-
with:
46-
urls: |
47-
${{ github.event.deployment_status.target_url }}
48-
temporaryPublicStorage: true
49-
runs: 3
50-
51-
- uses: pnpm/action-setup@v3
52-
- name: Format lighthouse score on desktop
53-
id: format_lighthouse_score_desktop
54-
uses: actions/github-script@v7
55-
with:
56-
script: |
57-
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js');
58-
59-
const lighthouseOutputs = {
60-
manifest: ${{ steps.lighthouse_audit_desktop.outputs.manifest }},
61-
links: ${{ steps.lighthouse_audit_desktop.outputs.links }},
62-
preset: "desktop"
63-
};
64-
65-
const comment = lighthouseCommentMaker({ lighthouseOutputs });
66-
core.setOutput("comment", comment);
67-
68-
- name: Format lighthouse score on mobile
69-
id: format_lighthouse_score_mobile
70-
uses: actions/github-script@v7
71-
with:
72-
script: |
73-
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js');
74-
75-
const lighthouseOutputs = {
76-
manifest: ${{ steps.lighthouse_audit_mobile.outputs.manifest }},
77-
links: ${{ steps.lighthouse_audit_mobile.outputs.links }},
78-
preset: "mobile"
79-
};
32+
- name: Install Dependencies
33+
run: npm install @unlighthouse/cli puppeteer -g
8034

81-
const comment = lighthouseCommentMaker({ lighthouseOutputs });
82-
core.setOutput("comment", comment);
35+
- name: Unlighthouse audit on ${{ matrix.device }}
36+
run: unlighthouse-ci --site ${{ github.event.deployment_status.target_url }} --${{ matrix.device }} --disable-robots-txt --extra-headers x-vercel-protection-bypass=$VERCEL_PROTECTION_BYPASS,x-vercel-set-bypass-cookie=true
8337

84-
- name: Add comment to PR
85-
id: comment_to_pr
86-
uses: marocchino/sticky-pull-request-comment@v2.9.0
87-
if: ${{ steps.pr_details.outputs.pr }}
38+
- name: Upload ${{ matrix.device }} audit
39+
if: failure() || success()
40+
uses: actions/upload-artifact@v4
8841
with:
89-
recreate: true
90-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91-
number: ${{ steps.pr_details.outputs.pr }}
92-
header: lighthouse
93-
message: |
94-
# ⚡️🏠 Lighthouse report
95-
96-
*Lighthouse ran against ${{ github.event.deployment_status.target_url }}*
97-
98-
## 🖥️ Desktop
99-
100-
${{ steps.format_lighthouse_score_desktop.outputs.comment }}
101-
102-
## 📱 Mobile
103-
104-
${{ steps.format_lighthouse_score_mobile.outputs.comment }}
42+
name: unlighthouse-${{ matrix.device }}-report
43+
path: './.unlighthouse/'
44+
include-hidden-files: 'true'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ bigcommerce-graphql.d.ts
1818
.DS_Store
1919
coverage/
2020
.history
21+
.unlighthouse

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@changesets/cli": "^2.29.0",
2525
"dotenv-cli": "^8.0.0",
2626
"turbo": "^2.5.0",
27-
"typescript": "^5.8.3"
27+
"typescript": "^5.8.3",
28+
"unlighthouse": "^0.16.3"
2829
}
2930
}

0 commit comments

Comments
 (0)