Repository navigation
183 lines (160 loc) · 7.45 KB
/
Copy pathlint.yml
File metadata and controls
183 lines (160 loc) · 7.45 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Lint and Test
# `preview` is the N-way composition of every open non-draft PR, rebuilt by
# sync-preview.yml on each PR open/sync/close. Running the suite against it is
# what replaces the "require branches to be up to date" rule (TRA-1094): rather
# than re-testing each PR pairwise against a main that moves out from under it,
# we test all open PRs merged together, continuously. Composition breakage
# surfaces on preview instead of after the merge.
on:
pull_request:
push:
branches: [main, preview]
concurrency:
group: lint-${{ github.ref }}
# Preview is force-rewritten on every PR event, so a superseded run is
# testing a composition that no longer exists — cancel it. Main runs are
# never cancelled: each one is the authoritative result for that commit.
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/preview' }}
permissions:
contents: read
jobs:
lint-test:
# Pinned, not ubuntu-latest. This is the only job that installs a browser,
# and "playwright install --with-deps" pulls system packages with apt. On
# the Ubuntu 26.04 image every run since 2026-11-11 failed there with
# "Temporary failure resolving 'security.ubuntu.com'", across reruns and
# branches, while GitHub reported Actions healthy. Move it back to
# ubuntu-latest once a run on 26.04 installs the browser cleanly.
runs-on: ubuntu-24.04
# Without this the job inherits the 360-minute Actions default. A hung test
# runner would then occupy a runner for six hours and emit no signal about
# what happened — see TRA-1050. The job takes ~5 min when healthy.
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26'
cache: true
cache-dependency-path: backend/go.sum
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
# 22, not 20: Playwright 1.65 is no longer tested on Node 20, and
# Node 20 is past end of life. 22 is what local dev runs.
node-version: '22'
cache: 'pnpm'
cache-dependency-path: pnpm-lock.yaml
- name: Install just
uses: taiki-e/install-action@just
- name: Install workspace deps
run: pnpm install --frozen-lockfile
- name: Build frontend (required for backend go:embed)
run: |
pnpm --filter frontend build
mkdir -p backend/frontend
cp -r frontend/dist backend/frontend/dist
- name: Install swag CLI
run: go install github.com/swaggo/swag/cmd/swag@v1.16.6
- name: Generate OpenAPI specs (swag init + apispec — required for swaggerspec go:embed)
run: just backend api-spec
- name: Changelog gate (release PRs only)
# TRA-1085 item 4 / TRA-1126. Deliberately a step inside lint-test
# rather than its own job: the main-branch-protection ruleset requires
# the exact contexts `build`, `lint-test`, `api-spec` and `main
# contract-tests must be green`, so a new job would need a ruleset edit
# before it enforced anything. Inert unless VERSION declares a clean
# release, which is every PR that is not the release PR.
run: just check-changelog
- name: Lint
run: just lint
- name: Test
# Step-level guard as well as the job-level one, so a hang points at the
# step that hung instead of just failing the whole job on timeout.
timeout-minutes: 10
run: just test
- name: Test mqtt-rpc (reader daemon + deploy scripts)
timeout-minutes: 10
run: just test-mqtt-rpc
# ── The e2e gate (TRA-1253 item 2, ADR 0022) ────────────────────────────
#
# These steps live INSIDE lint-test rather than in a job of their own, for
# the same reason the changelog gate does: the main-branch-protection
# ruleset requires the exact contexts `build`, `lint-test`, `api-spec` and
# `main contract-tests must be green`. A new job would be advisory until
# somebody edited that ruleset — which is precisely the aspirational
# "it is a gate" that nothing enforces that ADR 0022 exists to rule out.
#
# WHAT IS GATED, AND WHAT IS NOT. `--grep-invert @hardware` excludes the
# 31 specs that drive a real CS108. Two independent reasons, and the
# second is the one that is easy to forget:
#
# 1. There is one physical reader behind one bridge. CI cannot reach it.
# 2. A gate must not flake. TRA-1259 is a live intermittent in
# `hold-sweep` — the store loses CONNECTED with the transport intact —
# and gating anything that can fail at random teaches people to ignore
# the gate, which is the failure this whole exercise is about.
#
# Measured on the 2026-09-07 bench arm: the non-hardware subset is 182
# tests in 4.7 minutes, against 8.9 minutes for the hardware half.
#
# `APP_ENV=test` is what lets the backend boot on the dev JWT secret —
# jwt.go's ValidateSecret permits exactly local and test. Everything else
# (roles, passwords, the Feistel key) uses the deliberately well-known
# defaults in database/justfile, so no secret is needed here at all.
- name: Start database
env:
POSTGRES_PASSWORD: postgres
run: just database up
- name: Migrate and grant
env:
POSTGRES_PASSWORD: postgres
run: |
just backend migrate
just database grants
- name: Start backend
env:
POSTGRES_PASSWORD: postgres
APP_ENV: test
run: |
# setsid + nohup so the server survives this step's shell exiting;
# a plain `&` is not reliably orphaned between Actions steps.
setsid nohup just backend dev-no-reload > /tmp/backend.log 2>&1 &
# Fail loudly here rather than letting 182 specs fail identically on a
# backend that never came up — that shape has already been triaged as
# test rot once (TRA-1190).
for i in $(seq 1 45); do
if curl -fsS --max-time 2 http://localhost:8080/health.json > /dev/null; then
echo "backend up after ${i} attempt(s)"; exit 0
fi
sleep 2
done
echo "backend did not become healthy in 90s; log follows:" >&2
cat /tmp/backend.log >&2
exit 1
- name: Install Playwright browser
run: pnpm --filter frontend exec playwright install --with-deps chromium
- name: E2E (non-hardware subset)
timeout-minutes: 12
env:
# Playwright's own webServer starts vite (CI=true, USE_BRIDGE unset),
# so only the API origin has to be pointed at the backend — there is
# no dev-server proxy for /api.
VITE_API_URL: http://localhost:8080/api/v1
run: pnpm --filter frontend exec playwright test --grep-invert @hardware
- name: Backend log on failure
if: failure()
run: tail -200 /tmp/backend.log || true
- name: Upload e2e artefacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: |
frontend/test-results/
frontend/playwright-report/
retention-days: 7