-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (97 loc) · 3.73 KB
/
ci.yml
File metadata and controls
123 lines (97 loc) · 3.73 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
112
113
114
115
116
117
118
119
120
121
122
123
name: CI
on:
pull_request:
branches: [develop, main]
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Typecheck
run: pnpm typecheck
- name: Test
run: pnpm test:run
lighthouse:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
# No NUXT_APP_BASE_URL here — Lighthouse audits the site at root,
# unlike deploy.yml which prefixes /clearance-website/ for GitHub Pages.
- name: Generate static site
run: pnpm generate
- name: Lighthouse CI
id: lhci
uses: treosh/lighthouse-ci-action@v12
if: always()
with:
configPath: ./lighthouserc.cjs
- name: Comment Lighthouse results on PR
if: always() && github.event_name == 'pull_request' && steps.lhci.outputs.resultsPath != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESULTS_PATH: ${{ steps.lhci.outputs.resultsPath }}
LINKS: ${{ steps.lhci.outputs.links }}
run: |
MANIFEST="$RESULTS_PATH/manifest.json"
if [ ! -f "$MANIFEST" ]; then exit 0; fi
COMMENT=$(jq -r '
"## Lighthouse Report\n\n| URL | Performance | Accessibility | Best Practices | SEO |\n|-----|:-----------:|:------------:|:--------------:|:---:|",
(
[ .[] | select(.isRepresentativeRun == true) ] |
.[] |
"| `\(.url | split("//")[1] | split("/")[1:] | "/" + join("/"))` | \((.summary.performance // 0) * 100 | round) | \((.summary.accessibility // 0) * 100 | round) | \((.summary["best-practices"] // 0) * 100 | round) | \((.summary.seo // 0) * 100 | round) |"
)
' "$MANIFEST")
if [ -n "$LINKS" ]; then
COMMENT+=$'\n\n'"**Report links:** ${LINKS}"
fi
echo "$COMMENT" | gh pr comment "${{ github.event.pull_request.number }}" --body-file -
- name: Create issue on Lighthouse regression
if: always() && steps.lhci.outcome == 'failure' && steps.lhci.outputs.resultsPath != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESULTS_PATH: ${{ steps.lhci.outputs.resultsPath }}
LINKS: ${{ steps.lhci.outputs.links }}
run: |
if [ ! -f "$RESULTS_PATH/assertion-results.json" ]; then
echo "No assertion results found — LHCI likely crashed during collection."
exit 0
fi
REPORT=$(jq -r '
.[] | select(.level == "error" or .level == "warn") |
"- **\(.level)**: \(.auditId // .name) — score \(.actual) (expected ≥ \(.expected))"
' "$RESULTS_PATH/assertion-results.json")
gh issue create \
--title "Lighthouse regression detected on $(date +%Y-%m-%d)" \
--label "lighthouse" \
--assignee wazolab \
--body "$(cat <<EOF
## Lighthouse CI failed
**Run:** ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
**Commit:** \`${{ github.sha }}\`
**Branch:** \`${{ github.ref_name }}\`
### Failures
${REPORT}
### Report links
${LINKS}
EOF
)"