-
Notifications
You must be signed in to change notification settings - Fork 7
111 lines (95 loc) · 3.25 KB
/
Copy pathlighthouse.yml
File metadata and controls
111 lines (95 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Lighthouse
on:
push:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.head.sha || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
actions: read
pull-requests: read
jobs:
dedupe:
name: Avoid Duplicate Lighthouse Runs
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.dedupe.outputs.should_run }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Decide whether this run owns the Lighthouse work
id: dedupe
env:
GH_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
PR_ACTION: ${{ github.event.action }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
WORKFLOW_FILE: lighthouse.yml
run: bash .github/scripts/should-run-tests-workflow.sh
detect-changes:
name: Detect Changes
needs: dedupe
if: needs.dedupe.outputs.should_run == 'true'
runs-on: ubuntu-latest
outputs:
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed components
id: filter
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE_SHA: ${{ github.event.before }}
run: bash .github/scripts/detect-component-changes.sh
audit:
name: Lighthouse Audit (non-blocking)
needs: detect-changes
if: needs.detect-changes.outputs.frontend == 'true'
runs-on: ubuntu-latest
continue-on-error: true
defaults:
run:
working-directory: frontend
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.12.0
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci
- name: Set up Chrome for Lighthouse
id: setup-chrome
uses: browser-actions/setup-chrome@v2
with:
install-dependencies: true
- name: Build frontend for Lighthouse
run: npm run build
- name: Run Lighthouse audit
id: lighthouse
continue-on-error: true
env:
CHROME_PATH: ${{ steps.setup-chrome.outputs.chrome-path }}
run: npm run audit:lighthouse
- name: Upload Lighthouse reports
if: always()
uses: actions/upload-artifact@v4
with:
name: lighthouse-reports
path: frontend/.lighthouseci
if-no-files-found: ignore
retention-days: 7
- name: Report Lighthouse audit result
if: steps.lighthouse.outcome == 'failure'
run: |
echo "::warning::Lighthouse audit failed or thresholds were not met. This workflow is non-blocking; review the uploaded lighthouse-reports artifact for details."