Repository navigation
206 lines (190 loc) · 8.48 KB
/
Copy pathe2e.yml
File metadata and controls
206 lines (190 loc) · 8.48 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: e2e
# Full-stack e2e against kind-deployed SUTs (deploy/overlays/e2e/): pull the two
# images image.yml just published for this PR's head SHA, load them into kind,
# apply the e2e overlay, then run the Go API suite and the Playwright browser
# suite against the NodePort-exposed control-plane.
#
# Reusable workflow — pr.yml calls it after `image` for PRs that touch the SUT
# (control-plane, data-plane, web, deploy/, e2e scripts, Makefile, workflows).
# The file stays at this path on purpose: scripts/check-fidelity-allowlist.py
# and the reconciler model tbm_session-platform-e2e-mock-policy both scan
# `.github/workflows/e2e.yml`.
#
# Layout: one matrix job, every entry on its **own runner with its own kind
# SUT** — five API shards and the browser suite. The API suite is serial
# pod-per-test waiting (no t.Parallel, and it should not get any on a shared
# SUT: several tests assert cluster-wide invariants such as one pod per session
# or nothing scheduled beside the control plane, and the serial-queue tests
# measure timing). Separate SUTs give the speed-up without any test sharing
# state with another. scripts/e2e/api_shard.py splits the `go test -list`
# names by measured duration (longest first, onto the lightest shard).
#
# Wall-clock notes:
# - Nothing is built here. The SUT is the arm64 bytes image.yml pushed to
# ghcr for this SHA (the same bytes a preview environment runs), so the
# runners are arm64 too. The pull runs in the background while kind starts.
# - The browser entry starts `playwright install --with-deps` in the
# background right after checkout. Its apt step regularly crawls on runner
# mirrors (25 MB at ~40 kB/s); overlapping it with kind and the SUT rollout
# hides most of that.
on:
workflow_call:
inputs:
sha:
description: PR head SHA — the commit under test and the image tag
required: true
type: string
permissions:
contents: read
packages: read
jobs:
e2e:
name: ${{ matrix.name }}
runs-on: ubuntu-24.04-arm
timeout-minutes: 45
strategy:
# Let every shard finish: one red shard should not hide another's result.
fail-fast: false
matrix:
include:
- { name: "API e2e (shard 1/5)", suite: api, shard: 0, shards: 5 }
- { name: "API e2e (shard 2/5)", suite: api, shard: 1, shards: 5 }
- { name: "API e2e (shard 3/5)", suite: api, shard: 2, shards: 5 }
- { name: "API e2e (shard 4/5)", suite: api, shard: 3, shards: 5 }
- { name: "API e2e (shard 5/5)", suite: api, shard: 4, shards: 5 }
- { name: "browser e2e (playwright)", suite: browser }
env:
SHA: ${{ inputs.sha }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
# Every entry needs Go: scripts/e2e/up.sh builds the PocketAide and drop
# fixtures from source, and the API entries run the suite.
- uses: actions/setup-go@v5
with:
go-version: "1.24"
cache-dependency-path: control-plane/go.sum
- uses: actions/setup-node@v4
if: matrix.suite == 'browser'
with:
node-version: "22"
cache: npm
cache-dependency-path: web/package-lock.json
- name: install web deps
if: matrix.suite == 'browser'
working-directory: web
run: npm ci
# Kick off the browser + system-deps install now and collect it right
# before the browser suite (see the header). The runner only reaps
# orphaned processes when the job ends, so it survives across steps.
- name: start Playwright browser install (background)
if: matrix.suite == 'browser'
working-directory: web
run: |
# shellcheck disable=SC2016 # expanded by the inner bash, on purpose
nohup bash -c 'npx playwright install --with-deps chromium \
> "$RUNNER_TEMP/playwright-install.log" 2>&1
echo $? > "$RUNNER_TEMP/playwright-install.rc"' >/dev/null 2>&1 &
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Pull both published images under the local tags up.sh and the e2e
# overlay expect, so `make e2e-up` keeps one meaning on a laptop (local
# build) and here (published bytes). Collected after kind is up.
- name: pull published images (background)
run: |
# shellcheck disable=SC2016 # expanded by the inner bash, on purpose
nohup bash -c 'set -e
for pair in "session-platform:session-platform/control-plane:dev" \
"session-platform-data-plane:session-platform/data-plane:dev"; do
src="ghcr.io/dlddu/${pair%%:*}:${SHA}"; dst="${pair#*:}"
docker pull -q "$src" && docker tag "$src" "$dst"
done' > "$RUNNER_TEMP/pull.log" 2>&1 &
echo $! > "$RUNNER_TEMP/pull.pid"
# Creates a kind cluster from deploy/overlays/e2e/kind-config.yaml.
# cluster_name matches the config so the idempotent make e2e-up below
# reuses it instead of recreating.
- name: create kind cluster
uses: helm/kind-action@v1
with:
version: v0.24.0
cluster_name: session-platform
config: deploy/overlays/e2e/kind-config.yaml
- name: collect image pull
run: |
pid=$(cat "$RUNNER_TEMP/pull.pid")
while kill -0 "$pid" 2>/dev/null; do sleep 2; done
cat "$RUNNER_TEMP/pull.log"
docker image inspect session-platform/control-plane:dev session-platform/data-plane:dev > /dev/null
# Load the pulled images into kind, apply the overlay, wait for the
# rollouts, and poll the SUT at http://localhost:8080 (host :8080 -> node
# :30080 via the extraPortMapping). No port-forward needed.
- name: deploy SUT
env:
SKIP_IMAGE_BUILD: "1"
run: make e2e-up
- name: API e2e (go, -tags=e2e)
if: matrix.suite == 'api'
working-directory: control-plane
env:
E2E_BASE_URL: http://localhost:8080
SHARD_INDEX: ${{ matrix.shard }}
SHARD_TOTAL: ${{ matrix.shards }}
# -timeout is explicit because go's default is 10 minutes *per package*
# and this one package provisions a pod per test. The claude-code tests
# add cold CLI invocations on top of that, so the default stopped being
# a safe bound; 30m fails a genuinely stuck suite without failing a slow
# runner.
run: |
set -euo pipefail
mine=$(go test -tags=e2e -list '^Test' ./test/... | grep -E '^Test' \
| python3 ../scripts/e2e/api_shard.py "$SHARD_INDEX" "$SHARD_TOTAL")
if [ -z "$mine" ]; then
echo "::error::shard $((SHARD_INDEX + 1))/$SHARD_TOTAL selected no tests"
exit 1
fi
echo "$mine"
go test -tags=e2e -timeout=30m -v -run "^($(paste -sd'|' <<<"$mine"))\$" ./test/...
- name: install Playwright browser (collect background install)
if: matrix.suite == 'browser'
run: |
rc_file="$RUNNER_TEMP/playwright-install.rc"
for _ in $(seq 1 180); do
[ -f "$rc_file" ] && break
sleep 5
done
cat "$RUNNER_TEMP/playwright-install.log" || true
if [ -f "$rc_file" ] && [ "$(cat "$rc_file")" = 0 ]; then
exit 0
fi
echo "::warning::background Playwright install did not finish cleanly — retrying in the foreground"
cd web && npx playwright install --with-deps chromium
- name: browser e2e (playwright)
if: matrix.suite == 'browser'
working-directory: web
env:
E2E_BASE_URL: http://localhost:8080
run: npx playwright test
- name: upload Playwright report
if: ${{ matrix.suite == 'browser' && !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: web/playwright-report/
retention-days: 7
- name: upload Playwright traces
if: ${{ matrix.suite == 'browser' && failure() }}
uses: actions/upload-artifact@v4
with:
name: playwright-traces
path: web/test-results/
retention-days: 7
- name: SUT diagnostics on failure
if: failure()
run: |
kubectl get pods -A -o wide || true
kubectl describe deploy/control-plane || true
kubectl logs deploy/control-plane --tail=200 || true