-
Notifications
You must be signed in to change notification settings - Fork 1
111 lines (102 loc) · 4.19 KB
/
Copy pathlighthouse.yml
File metadata and controls
111 lines (102 loc) · 4.19 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-ci
# T090 — Lighthouse CI gate.
#
# Runs Lighthouse against the live PR preview URL (surfaced in the PR's
# Deployments box by pr-preview.yml) and uploads the report as an artifact.
# Currently WARN-ONLY: assertions log to the run summary but don't fail the
# check. After we accumulate one production baseline this will flip to a
# hard gate on SC-001 (first interactive paint ≤ 3 s) + total transferred
# size for SC-006.
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'site/**'
- '.github/workflows/lighthouse.yml'
workflow_dispatch:
inputs:
target_url:
description: 'Full URL to audit (overrides PR preview detection).'
required: false
type: string
permissions:
contents: read
pull-requests: read
concurrency:
group: lighthouse-pr-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
audit:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve target URL
id: target
# Stage 9 (spec 009-conference-subpath FR-104): PR previews now
# host the conference site under /pr-<N>/ohbm2026/. The default
# target widens accordingly so the audit runs against the actual
# conference shell, not the root redirect island.
run: |
if [ -n "${{ inputs.target_url }}" ]; then
echo "url=${{ inputs.target_url }}" >> "$GITHUB_OUTPUT"
else
echo "url=https://abstractatlas.brainkb.org/pr-${{ github.event.pull_request.number }}/ohbm2026/" >> "$GITHUB_OUTPUT"
fi
- name: Wait for PR-preview deploy to settle
if: github.event_name == 'pull_request'
# The pr-preview workflow runs in parallel; give it a head start so
# we don't audit a stale build. Capped at 10 min — if the deploy
# hasn't surfaced by then, we audit whatever's there. Each curl /
# grep is run with `|| true` so an early-iteration miss (preview
# not yet uploaded → 404 → empty grep) doesn't kill the loop under
# `bash -e`.
run: |
set +e
head=$(echo "${{ github.event.pull_request.head.sha }}" | head -c 7)
for i in $(seq 1 30); do
sha=$(curl -sf "${{ steps.target.outputs.url }}" 2>/dev/null \
| grep -oE 'build-info-short-sha"[^>]*>([a-f0-9]+)' \
| head -1 \
| grep -oE '[a-f0-9]+$')
echo "iter $i: preview SHA=${sha:-(none)} expected=$head"
if [ "$sha" = "$head" ]; then echo "preview ready"; exit 0; fi
sleep 20
done
echo "::warning::Preview SHA did not match head after 10 min; auditing whatever's deployed."
exit 0
- name: Run Lighthouse
uses: treosh/lighthouse-ci-action@v12
with:
urls: |
${{ steps.target.outputs.url }}
${{ steps.target.outputs.url }}about/
uploadArtifacts: true
temporaryPublicStorage: true
configPath: ./site/lighthouse.config.json
- name: Summarise scores
if: always()
run: |
# Lighthouse uploads a JSON manifest; print the headline numbers
# into the GitHub job summary so reviewers don't have to dig.
if [ -d .lighthouseci ]; then
for f in .lighthouseci/manifest.json; do
[ -f "$f" ] || continue
echo "## Lighthouse summary" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
python3 - <<'PY' >> "$GITHUB_STEP_SUMMARY"
import json, sys
for entry in json.load(open(".lighthouseci/manifest.json")):
s = entry["summary"]
print(f'### `{entry["url"]}`')
print()
print('| metric | score |')
print('|---|---|')
for k in ("performance","accessibility","best-practices","seo"):
if k in s:
print(f'| {k} | {s[k]:.2f} |')
print()
PY
done
fi