1- name : Regression Tests (Preview)
1+ name : Regression Tests
22
33on :
44 deployment_status :
55 states : ["success"]
66
7- concurrency :
8- group : regression-preview-${{ github.event.deployment.sha }}
9- cancel-in-progress : true
10-
117env :
128 VERCEL_PROTECTION_BYPASS : ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
139
1410jobs :
1511 detect-provider :
1612 name : Detect Deployment Provider
17- if : github.event.deployment.environment == 'Preview'
1813 runs-on : ubuntu-latest
1914 outputs :
2015 provider : ${{ steps.detect.outputs.provider }}
2116 production-url : ${{ steps.detect.outputs.production-url }}
17+ branch-label : ${{ steps.detect.outputs.branch-label }}
18+ is-preview : ${{ steps.detect.outputs.is-preview }}
2219 steps :
2320 - uses : actions/checkout@v4
2421
2522 - name : Detect provider and production URL
2623 id : detect
2724 run : |
2825 CREATOR="${{ github.event.deployment_status.creator.login }}"
26+ ENVIRONMENT="${{ github.event.deployment.environment }}"
27+
28+ if [[ "$ENVIRONMENT" == "Preview" ]]; then
29+ echo "is-preview=true" >> $GITHUB_OUTPUT
30+ else
31+ echo "is-preview=false" >> $GITHUB_OUTPUT
32+ fi
2933
3034 if [[ "$CREATOR" == "vercel[bot]" ]]; then
3135 echo "provider=vercel" >> $GITHUB_OUTPUT
3236 PKG_NAME=$(node -p "require('./core/package.json').name")
33- case "$PKG_NAME" in
34- "@bigcommerce/catalyst-core")
35- echo "production-url=https://canary.catalyst-demo.site/" >> $GITHUB_OUTPUT ;;
36- "@bigcommerce/catalyst-makeswift")
37- echo "production-url=https://canary.makeswift.catalyst-demo.site" >> $GITHUB_OUTPUT ;;
38- *)
39- echo "::warning::No production URL configured for package: $PKG_NAME. Skipping comparison."
40- echo "production-url=" >> $GITHUB_OUTPUT ;;
41- esac
37+
38+ if [[ "$ENVIRONMENT" == "Preview" ]]; then
39+ case "$PKG_NAME" in
40+ "@bigcommerce/catalyst-core")
41+ echo "production-url=https://canary.catalyst-demo.site/" >> $GITHUB_OUTPUT ;;
42+ "@bigcommerce/catalyst-makeswift")
43+ echo "production-url=https://canary.makeswift.catalyst-demo.site" >> $GITHUB_OUTPUT ;;
44+ *)
45+ echo "::warning::No production URL configured for package: $PKG_NAME. Skipping comparison."
46+ echo "production-url=" >> $GITHUB_OUTPUT ;;
47+ esac
48+ echo "branch-label=" >> $GITHUB_OUTPUT
49+ else
50+ case "$PKG_NAME" in
51+ "@bigcommerce/catalyst-core")
52+ echo "branch-label=canary" >> $GITHUB_OUTPUT
53+ echo "production-url=${{ github.event.deployment_status.target_url }}" >> $GITHUB_OUTPUT ;;
54+ "@bigcommerce/catalyst-makeswift")
55+ echo "branch-label=integrations/makeswift" >> $GITHUB_OUTPUT
56+ echo "production-url=${{ github.event.deployment_status.target_url }}" >> $GITHUB_OUTPUT ;;
57+ *)
58+ echo "branch-label=" >> $GITHUB_OUTPUT
59+ echo "production-url=" >> $GITHUB_OUTPUT ;;
60+ esac
61+ fi
4262
4363 elif [[ "$CREATOR" == "cloudflare-pages[bot]" ]]; then
4464 echo "provider=cloudflare" >> $GITHUB_OUTPUT
4565 echo "::warning::Cloudflare production URL not yet configured. Skipping comparison."
4666 echo "production-url=" >> $GITHUB_OUTPUT
67+ echo "branch-label=" >> $GITHUB_OUTPUT
4768
4869 else
4970 echo "::warning::Unknown deployment provider: $CREATOR. Skipping audits."
5071 echo "provider=unknown" >> $GITHUB_OUTPUT
5172 echo "production-url=" >> $GITHUB_OUTPUT
73+ echo "branch-label=" >> $GITHUB_OUTPUT
5274 fi
5375
5476 unlighthouse-audit-preview :
5577 name : Unlighthouse Audit Preview (${{ needs.detect-provider.outputs.provider }}) - ${{ matrix.device }}
5678 needs : [detect-provider]
79+ if : needs.detect-provider.outputs.is-preview == 'true'
5780 runs-on : ubuntu-latest
81+ concurrency :
82+ group : regression-preview-${{ github.event.deployment.sha }}-${{ matrix.device }}
83+ cancel-in-progress : true
5884 strategy :
5985 matrix :
6086 device : [desktop, mobile]
92118 needs : [detect-provider]
93119 if : needs.detect-provider.outputs.production-url != ''
94120 runs-on : ubuntu-latest
121+ concurrency :
122+ group : regression-production-${{ github.event.deployment.sha }}-${{ matrix.device }}
123+ cancel-in-progress : ${{ github.event.deployment.environment == 'Preview' }}
95124 strategy :
96125 matrix :
97126 device : [desktop, mobile]
@@ -118,7 +147,7 @@ jobs:
118147 unlighthouse-compare :
119148 name : Unlighthouse Compare & Comment (${{ needs.detect-provider.outputs.provider }})
120149 needs : [detect-provider, unlighthouse-audit-preview, unlighthouse-audit-production]
121- if : needs.detect-provider.outputs.production-url != ''
150+ if : needs.detect-provider.outputs.is-preview == 'true' && needs.detect-provider.outputs. production-url != ''
122151 runs-on : ubuntu-latest
123152 permissions :
124153 pull-requests : write
@@ -163,3 +192,41 @@ jobs:
163192 reportPath: '/tmp/unlighthouse-report.md',
164193 metaPath: '/tmp/unlighthouse-meta.json',
165194 })
195+
196+ unlighthouse-report :
197+ name : Unlighthouse Report (${{ needs.detect-provider.outputs.provider }}) — ${{ needs.detect-provider.outputs.branch-label }}
198+ needs : [detect-provider, unlighthouse-audit-production]
199+ if : needs.detect-provider.outputs.is-preview == 'false' && needs.detect-provider.outputs.production-url != ''
200+ runs-on : ubuntu-latest
201+ permissions :
202+ contents : write
203+
204+ steps :
205+ - uses : actions/checkout@v4
206+
207+ - uses : actions/setup-node@v4
208+ with :
209+ node-version-file : " .nvmrc"
210+
211+ - name : Download production Unlighthouse artifacts
212+ uses : actions/download-artifact@v4
213+ with :
214+ pattern : unlighthouse-production-*-report
215+ path : /tmp/unlighthouse-artifacts
216+ merge-multiple : false
217+
218+ - name : Format report
219+ run : |
220+ node .github/scripts/audit-unlighthouse.mts \
221+ --desktop /tmp/unlighthouse-artifacts/unlighthouse-production-desktop-report/ci-result.json \
222+ --mobile /tmp/unlighthouse-artifacts/unlighthouse-production-mobile-report/ci-result.json \
223+ --branch "${{ needs.detect-provider.outputs.branch-label }}" \
224+ --output /tmp/unlighthouse-report.md
225+ cat /tmp/unlighthouse-report.md >> "$GITHUB_STEP_SUMMARY"
226+
227+ - name : Post commit comment
228+ uses : actions/github-script@v7
229+ with :
230+ script : |
231+ const postReport = require('./.github/scripts/post-unlighthouse-commit-comment.js')
232+ await postReport({ github, context, reportPath: '/tmp/unlighthouse-report.md' })
0 commit comments