Repository navigation
305 lines (286 loc) · 14.3 KB
/
Copy pathlinux.yml
File metadata and controls
305 lines (286 loc) · 14.3 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
name: Linux
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, converted_to_draft]
paths-ignore:
- 'docs/**'
- 'website/**'
- 'README.md'
- 'AGENTS.md'
- 'CONTEXT.md'
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'SECURITY.md'
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
smoke-linux:
name: Smoke Tests
if: ${{ !github.event.pull_request.draft }}
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
env:
# Force X11 mode (Xvfb) — no Wayland on CI.
XDG_SESSION_TYPE: x11
DISPLAY: ':99'
# Headless GTK: avoid dconf issues, enable accessibility bridge.
GSETTINGS_BACKEND: memory
NO_AT_BRIDGE: '0'
GTK_A11Y: atspi
GTK_MODULES: 'gail:atk-bridge'
steps:
- name: Checkout
uses: useblacksmith/checkout@2b9fe87d796feea153b455ec2f3125b471a7b0e7 # v1.8.2
- name: Setup toolchain
uses: ./.github/actions/setup-node-pnpm
- name: Fetch the PR base for Linux smoke selection
if: github.event_name == 'pull_request'
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: git fetch origin "$BASE_SHA" --depth=1 || echo "Base fetch failed; Linux smoke selection will fail open."
- name: Select Linux smoke tests
id: impact
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: node --experimental-strip-types scripts/device-lane-impact.ts replay-linux linux-command-evidence
# Unbounded, this step could not fail — it could only stall. On 2026-08-19 a slow mirror
# held apt past the job's 30-minute budget. On 2026-10-22 a pull-through mirror crawled on
# packages nobody else had requested recently (poppler-data, fonts-urw-base35, pulled in by
# gnome-calculator). In November 2026 the index refresh itself became the failure: a slow
# archive.ubuntu.com mirror could not serve the ~41 MB of indexes within the deadline.
#
# The cache holds the Ubuntu package lists of the last refresh and the archives that apt
# selected for PACKAGES from them. A run verifies the signatures, list digests and archive
# hashes, resolves PACKAGES against those lists and installs only when the plan needs no
# download, so it never asks a mirror for anything. A miss, a failed check, a plan that
# needs a download (a changed package list or runner image) or a failed install discards
# the restored set, refreshes into empty job-private directories and saves a new entry.
# The key is unique per run attempt, so restore-keys load the newest entry and a refreshed
# set replaces a stale one.
#
# Every install runs with --no-download, so the network is reached only inside a bounded
# phase. Worst case: cached install lock wait 60s, refresh 2 x (60s + 5s kill grace),
# download 2 x (75s + 5s), final install lock wait 60s. That is 410s of the 540s step,
# which leaves 130s for dpkg (2-5s per run in CI), the checks and the cache copy. dpkg
# itself never runs under a deadline.
- name: Restore Linux desktop packages
if: steps.impact.outputs.run != 'false'
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
with:
path: ~/apt-cache
key: apt-cache-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: apt-cache-${{ runner.os }}-
- name: Install Linux desktop dependencies
id: apt-install
if: steps.impact.outputs.run != 'false'
timeout-minutes: 9
run: |
set -euo pipefail
CACHE="$HOME/apt-cache"
KEYRING=/usr/share/keyrings/ubuntu-archive-keyring.gpg
APT_OPTS=(
-o Acquire::Retries=2
-o Acquire::http::Timeout=15
-o Acquire::https::Timeout=15
# The runner's own unattended-upgrades timer holds the dpkg lock; wait, don't hang.
-o DPkg::Lock::Timeout=60
# Job-private lists and archives: the runner's periodic index update cannot change the
# plan between download and install, and a fallback never reuses a restored archive.
-o "Dir::State::Lists=$CACHE/lists/"
-o "Dir::Cache::Archives=$CACHE/archives/"
)
PACKAGES=(
xvfb
xdotool
scrot
at-spi2-core
python3-gi
gir1.2-atspi-2.0
libatk-adaptor
dbus-x11
gnome-calculator
wmctrl
)
stamp() { printf 'APT %s (UTC): %s\n' "$1" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"; }
all_installed() {
local missing
missing="$(dpkg-query -W -f='${db:Status-Status} ${Package}\n' "${PACKAGES[@]}" 2>&1 | grep -v '^installed ' || true)"
[ -z "$missing" ] || { printf 'Not installed:\n%s\n' "$missing"; return 1; }
}
# apt trusts a list by the presence of InRelease and an archive by its file name and size,
# so check the restored set: only InRelease and plain Packages lists, each InRelease
# against the Ubuntu keyring, each list against its signed digest, and each archive
# against the SHA-256 of the record whose escaped file name apt looks up.
# This runs in an if condition, where errexit is off, so every command checks its status.
verify_restored() {
local signed extra name suite path sha
signed="$(mktemp -d)" || return 1
extra="$(find "$CACHE/lists" -mindepth 1 ! -name '*_InRelease' ! -name '*_Packages' ! -path "$CACHE/lists/partial")" || return 1
[ -z "$extra" ] || { printf 'Unexpected list files:\n%s\n' "$extra"; return 1; }
compgen -G "$CACHE/lists/*_InRelease" > /dev/null && compgen -G "$CACHE/archives/*.deb" > /dev/null || return 1
for list in "$CACHE"/lists/*_InRelease; do
gpgv --quiet --keyring "$KEYRING" --output "$signed/${list##*/}" "$list" 2> /dev/null || { echo "Unverified: $list"; return 1; }
done
for list in "$CACHE"/lists/*_Packages; do
name="${list##*/}"
suite="${name#*_dists_}"
suite="${suite%%_*}"
path="$(tr _ / <<< "${name#*_dists_"$suite"_}")" || return 1
sha="$(sha256sum "$list")" || return 1
grep -qE "^ ${sha%% *} +[0-9]+ $path\$" "$signed/${name%%_dists_*}_dists_${suite}_InRelease" || { echo "Unverified: $list"; return 1; }
done
# apt stores an archive as Package_Version_Architecture.deb, escaping % and : in the version.
awk '/^Package:/{p=$2} /^Architecture:/{a=$2} /^Version:/{v=$2; gsub(/%/, "%25", v); gsub(/:/, "%3a", v)}
/^SHA256:/{print $2 " " p "_" v "_" a ".deb"}' "$CACHE"/lists/*_Packages > "$signed/records" || return 1
for deb in "$CACHE"/archives/*.deb; do
sha="$(sha256sum "$deb")" || return 1
grep -qxF "${sha%% *} ${deb##*/}" "$signed/records" || { echo "Unverified: $deb"; return 1; }
done
stamp "verified $(compgen -G "$CACHE/lists/*_Packages" | wc -l) lists and $(compgen -G "$CACHE/archives/*.deb" | wc -l) archives"
}
# Succeeds when apt can install PACKAGES from the archive directory without a download.
offline_plan() {
local uris
uris="$(sudo apt-get install -qq --print-uris --no-install-recommends "${APT_OPTS[@]}" "${PACKAGES[@]}")" || return 1
[ -z "$uris" ] || { printf 'Archives to download:\n%s\n' "$uris"; return 1; }
}
install_offline() {
sudo apt-get install -y --no-install-recommends --no-download "${APT_OPTS[@]}" "${PACKAGES[@]}"
}
# Retry a network phase under a per-attempt deadline. An attempt passes only when its check passes too.
apt_bounded() {
local seconds="$1" check="$2"
shift 2
for attempt in 1 2; do
stamp "$1 attempt $attempt start"
if sudo timeout --kill-after=5 "$seconds" apt-get "$@" "${APT_OPTS[@]}" && "$check"; then
return 0
fi
done
echo "::error::apt-get $1 did not finish within ${seconds}s on 2 attempts"
return 1
}
if all_installed > /dev/null; then
exit 0
fi
mkdir -p "$CACHE/lists/partial" "$CACHE/archives/partial"
stamp "cached install start"
cached_dpkg=false
if verify_restored && offline_plan && cached_dpkg=true && install_offline && all_installed; then
stamp "cached install complete"
exit 0
fi
echo "::notice::The cached Linux desktop packages cannot install the package set; refreshing the apt index."
# A killed or failed dpkg run leaves a journal that makes apt refuse every later command.
# Packages whose dependency that run never unpacked stay unconfigured, so this exits nonzero.
if [ "$cached_dpkg" = true ]; then
sudo dpkg --configure -a || true
fi
sudo rm -rf "$CACHE"
mkdir -p "$CACHE/lists/partial" "$CACHE/archives/partial"
apt_bounded 60 true update
if [ "$cached_dpkg" = true ]; then
# On a broken system apt resolves only the named packages, so name what --fix-broken would install.
mapfile -t -O "${#PACKAGES[@]}" PACKAGES < <(sudo apt-get install --fix-broken -s -qq "${APT_OPTS[@]}" | awk '/^Inst /{print $2}')
fi
apt_bounded 75 offline_plan install -y --no-install-recommends --download-only "${PACKAGES[@]}"
stamp "install start"
install_offline
all_installed
stamp "install complete"
sudo rm -rf "$CACHE/lists/partial" "$CACHE/lists/lock" "$CACHE/archives/partial" "$CACHE/archives/lock"
sudo chown -R "$(id -u):$(id -g)" "$CACHE"
# Save only Ubuntu lists, the ones verify_restored can check. After a repair the set holds only
# what the repair fetched, so the next run's plan needs a download and that run saves a full set.
for list in "$CACHE"/lists/*_InRelease; do
gpgv --quiet --keyring "$KEYRING" "$list" 2> /dev/null || rm -f "${list%InRelease}"*
done
find "$CACHE/lists" -mindepth 1 ! -name '*_InRelease' ! -name '*_Packages' -delete
if compgen -G "$CACHE/archives/*.deb" > /dev/null; then
echo "save=true" >> "$GITHUB_OUTPUT"
fi
- name: Save Linux desktop packages
if: steps.impact.outputs.run != 'false' && steps.apt-install.outputs.save == 'true'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.2.3
with:
path: ~/apt-cache
key: apt-cache-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Start Xvfb and D-Bus
if: steps.impact.outputs.run != 'false'
run: |
# Start virtual framebuffer (1280x1024, 24-bit color)
Xvfb :99 -screen 0 1280x1024x24 &
sleep 1
# Start a D-Bus session and export its env vars for subsequent steps.
# dbus-launch forks a persistent daemon, so it survives the step.
eval "$(dbus-launch --sh-syntax)"
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> "$GITHUB_ENV"
echo "DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID" >> "$GITHUB_ENV"
- name: Start AT-SPI2 registry
if: steps.impact.outputs.run != 'false'
run: |
# The registry must start AFTER DBUS_SESSION_BUS_ADDRESS is available
# (it was written to GITHUB_ENV in the previous step).
ATSPI_REG=$(find /usr -name at-spi2-registryd -type f 2>/dev/null | head -1)
if [ -z "$ATSPI_REG" ]; then
echo "::error::at-spi2-registryd not found. Install at-spi2-core."
exit 1
fi
"$ATSPI_REG" &
sleep 2
# Health probe: verify the registry is reachable on the a11y bus
if python3 -c "import gi; gi.require_version('Atspi','2.0'); from gi.repository import Atspi; d=Atspi.get_desktop(0); assert d is not None, 'desktop is None'; print(f'AT-SPI2 OK — {d.get_child_count()} apps')"; then
echo "AT-SPI2 registry healthy"
else
echo "::error::AT-SPI2 registry started but health probe failed"
exit 1
fi
- name: Verify environment
if: steps.impact.outputs.run != 'false'
run: |
echo "=== Display ==="
xdotool getdisplaygeometry
echo "=== D-Bus ==="
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS"
echo "=== AT-SPI2 Python bindings ==="
python3 -c "import gi; gi.require_version('Atspi', '2.0'); from gi.repository import Atspi; print('OK')"
echo "=== AT-SPI2 tree dump (quick test) ==="
python3 linux/atspi-dump.py --surface desktop --max-nodes 5 | python3 -m json.tool | head -20 || echo "::warning::AT-SPI2 tree dump returned no nodes (expected before any app is launched)"
echo "=== xdotool ==="
xdotool version
- name: Run Linux replay smoke test
if: steps.impact.outputs.run != 'false'
run: pnpm clean:daemon
- name: Execute Linux replay smoke test
if: steps.impact.outputs.run != 'false'
uses: ./.github/actions/run-gate
with:
gate: replay-linux
args: |
--retries
2
--report-junit
test/artifacts/replays-linux.junit.xml
- name: Reset daemon before Linux command evidence
if: steps.impact.outputs.run != 'false'
run: pnpm clean:daemon
- name: Execute Linux command evidence
if: steps.impact.outputs.run != 'false'
uses: ./.github/actions/run-gate
with:
gate: linux-command-evidence
- name: Upload Linux artifacts
if: always() && steps.impact.outputs.run != 'false'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: linux-artifacts
if-no-files-found: ignore
path: |
test/artifacts/**
test/screenshots/**