Repository navigation
259 lines (247 loc) · 11.8 KB
/
Copy pathshell.yml
File metadata and controls
259 lines (247 loc) · 11.8 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
name: Shell
# Split out of ci.yml by #2048, where one serial job decided CI's wall clock. lint-sh (~90 s, #2632) and
# the standalone suites (~110 s) share nothing with `tests/stack/run.sh` but the generated CLI,
# which each job builds for itself. run.sh itself runs as a matrix of contiguous blocks (#2631):
# each leg is `run.sh <block>` in a fresh runner. The nine #2048 prerequisite fragments also
# run individually with lib.sh, independently of the ordered battery. run.sh refuses to start when
# this matrix and its STACK_BLOCKS disagree.
# No `schedule:` here: the Monday CVE sweep stays in ci.yml, which is what every shell job used to
# gate itself off one `if:` at a time.
on:
push:
branches: [main, develop]
pull_request:
# Least privilege (#282): these jobs only read the repo.
permissions:
contents: read
# Cancel superseded PR runs; never cancel push runs on main/develop — they are required checks on
# the protected branch. #415.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
shell-block:
name: Shell tests (pithead suite, block ${{ matrix.block }})
runs-on: ubuntu-latest
timeout-minutes: 12
strategy:
fail-fast: false # a red block should not hide the verdicts of the other blocks
matrix:
block: [1, 2, 3, 4, 5] # run.sh's STACK_BLOCKS; stack_blocks_audit holds the two equal
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/docker-registry-mirror
- name: Build the generated CLI
# run.sh sources the generated root `pithead` (git-ignored). Until #2048 split `lint-sh`
# off, the build came in free as that target's prerequisite.
run: make pithead
- name: Hold the default stratum port
run: |
nohup python3 -c 'import socket,time; s=socket.socket(); s.bind(("0.0.0.0",3333)); s.listen(1); time.sleep(3600)' >"$RUNNER_TEMP/hold-3333.log" 2>&1 &
for _ in $(seq 50); do (exec 3<>/dev/tcp/127.0.0.1/3333) 2>/dev/null && exit 0; sleep 0.1; done
cat "$RUNNER_TEMP/hold-3333.log" >&2
echo "nothing listens on 3333" >&2
exit 1
- name: Run pithead test suite block
run: bash tests/stack/run.sh "$BLOCK"
env:
BLOCK: ${{ matrix.block }}
shell-fragment:
name: Shell prerequisite (${{ matrix.fragment }})
runs-on: ubuntu-latest
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
fragment:
- control/test-control-editable-allowlist.sh
- control/test-control-add-only-ssrf.sh
- secrets/test-secrets-masking.sh
- test-backup-recovery.sh
- test-cli-restore-hardening.sh
- test-confirm-approval.sh
- test-data-management.sh
- test-spool-audit.sh
- test-worker-config.sh
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build the generated CLI
run: make pithead
- name: Hold the default stratum port
run: |
nohup python3 -c 'import socket,time; s=socket.socket(); s.bind(("0.0.0.0",3333)); s.listen(1); time.sleep(3600)' >"$RUNNER_TEMP/hold-3333.log" 2>&1 &
for _ in $(seq 50); do (exec 3<>/dev/tcp/127.0.0.1/3333) 2>/dev/null && exit 0; sleep 0.1; done
cat "$RUNNER_TEMP/hold-3333.log" >&2
echo "nothing listens on 3333" >&2
exit 1
- name: Run prerequisite fragment in a fresh process
shell: bash
run: |
set -uo pipefail
source tests/stack/lib.sh
if ! source "tests/stack/$FRAGMENT"; then
echo "prerequisite fragment failed to complete: $FRAGMENT" >&2
exit 1
fi
printf 'Independent fragment: %s passed, %s failed\n' "$PASS" "$FAIL"
[ "$PASS" -gt 0 ] && [ "$FAIL" -eq 0 ]
env:
FRAGMENT: ${{ matrix.fragment }}
coreutils-fileops:
name: Coreutils file-ops (Ubuntu 26.04, unstubbed)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build the generated CLI
run: make pithead
- name: Run the file-operations self-test on the runner image
run: bash tests/integration/selftest/selftest-coreutils-fileops.sh
shell:
# The required status check. Branch protection names this context, so it stays one job that is
# green only when every block and independent prerequisite passes.
name: Shell tests (pithead suite)
needs: [shell-block, shell-fragment, coreutils-fileops]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Every block passed
run: '[ "$RESULT" = success ] && [ "$FRAGMENTS" = success ] && [ "$FILEOPS" = success ] || { echo "the pithead suite ended: blocks=$RESULT prerequisites=$FRAGMENTS fileops=$FILEOPS"; exit 1; }'
env:
RESULT: ${{ needs.shell-block.result }}
FRAGMENTS: ${{ needs.shell-fragment.result }}
FILEOPS: ${{ needs.coreutils-fileops.result }}
shell-standalone:
name: Shell tests (standalone suites + tooling)
runs-on: ubuntu-24.04
timeout-minutes: 15 # ~110 s of the old `shell` job, the first-boot journal suite being 60 s of it (#2048)
# Each suite is named outright rather than globbed: standalone/ also holds test_compose.sh,
# which belongs to the `compose` job and which sources test_dotenv.sh itself, so a glob would
# run both twice. `make test-stack` names these suites and never runs in CI — a suite added
# to standalone/ must be wired here as well, or it runs nowhere.
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build the generated CLI
run: make pithead
- name: Run Tor recovery contracts
env:
TMPDIR: ${{ runner.temp }}
run: |
bash tests/stack/standalone/test_tor_recovery.sh
bash tests/stack/standalone/test_tor_bootstrap_recovery.sh
bash tests/stack/standalone/test_tor_heal_outage_recovery.sh
bash tests/stack/standalone/test_tor_unsaturated_reset.sh
bash tests/stack/standalone/test_tor_reset.sh
- name: Run real-image data-reset suite
# Real ext4 damage against the product's own repair escalation (#1062). Unprivileged —
# e2fsprogs on plain files — and it hard-fails rather than skips when CI lacks the tools.
run: bash tests/stack/standalone/test_data_reset.sh
- name: Run directory line-break regression
run: bash tests/stack/standalone/test_directory_linebreaks.sh
- name: Run OS-update recovery suite
# #1050 dead-end states re-arm and report.
run: bash tests/stack/standalone/test_os_update_recovery.sh
- name: Run first-boot journal suite
# #1030 journal persistence across interrupts.
run: bash tests/stack/standalone/test_firstboot_journal.sh
- name: Run appliance hugepages suite
# #1103 co-location refusal on the reduced tier.
run: bash tests/stack/standalone/test_appliance_hugepages.sh
- name: Run clearnet marker attestation contract
run: python3 tests/stack/standalone/test_clearnet_attestation.py
- name: Run stratum port preflight contract
run: python3 tests/stack/standalone/test_stratum_port.py
- name: Run Quadlet image provenance contract
run: python3 tests/stack/standalone/test_quadlet_provenance.py
- name: Test-inventory drift check
run: bash tests/inventory.sh > /dev/null
- name: Run integration harness self-test
run: make test-integration-selftest
- name: Run repository tooling checks
run: make test-tools
bridge-awk:
name: Container bridge awk portability (Debian 12)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- uses: ./.github/actions/docker-registry-mirror
- name: Run bridge and Caddy regressions in the pinned test runner
run: |
bash scripts/test-container.sh true
docker run --rm --user root -v "$PWD:$PWD" -w "$PWD" \
pithead-test-runner:local bash -euc '
apt-get update
apt-get install -y --no-install-recommends mawk gawk busybox
make test-bridge-awk
'
soak-macos:
name: Soak self-test (macOS, ${{ matrix.bash }})
runs-on: macos-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
bash: [system, homebrew]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install jq and Homebrew Bash
run: brew install jq bash
- name: Run soak self-test with BSD userland
env:
BASH_FLAVOR: ${{ matrix.bash }}
TMPDIR: ${{ runner.temp }}
run: |
tools="$RUNNER_TEMP/soak-tools"
mkdir -p "$tools"
ln -s "$(command -v jq)" "$tools/jq"
if [ "$BASH_FLAVOR" = homebrew ]; then
ln -s "$(brew --prefix bash)/bin/bash" "$tools/bash"
else
ln -s /bin/bash "$tools/bash"
fi
# Keep GNU coreutils, sed and timeout off PATH, including in driver children.
export PATH="$tools:/usr/bin:/bin:/usr/sbin:/sbin"
bash --version
bash tests/os/soak-probe.sh --self-test
shell-lint:
name: Shell lint (shellcheck + shfmt)
runs-on: ubuntu-latest
timeout-minutes: 15 # lint-sh took 87 s when measured in #2632
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: "Install shellcheck + shfmt (pinned + sha256-verified, #286)"
# Direct upstream-release downloads with a sha256 check (RigForge convention) instead of the
# runner's preinstalled shellcheck / apt — reproducible, and immune to the apt-mirror
# flakiness of #64. Both versions come from the Makefile — shellcheck's since #1679, shfmt's since #1688.
run: |
SF=$(make -s print-shfmt-version) # the Makefile is the pin; `make lint-sh` below refuses any other version (#1688)
curl -fsSL -o /tmp/shfmt "https://github.com/mvdan/sh/releases/download/v$SF/shfmt_v${SF}_linux_amd64"
echo "fb096c5d1ac6beabbdbaa2874d025badb03ee07929f0c9ff67563ce8c75398b1 /tmp/shfmt" | sha256sum -c -
sudo install -m 0755 /tmp/shfmt /usr/local/bin/shfmt
SC=$(make -s print-shellcheck-version) # the Makefile is the pin; `make lint-sh` below refuses any other version (#1679)
curl -fsSL -o /tmp/sc.tar.xz "https://github.com/koalaman/shellcheck/releases/download/v$SC/shellcheck-v$SC.linux.x86_64.tar.xz"
echo "8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 /tmp/sc.tar.xz" | sha256sum -c -
tar -xJf /tmp/sc.tar.xz -C /tmp
sudo install -m 0755 "/tmp/shellcheck-v$SC/shellcheck" /usr/local/bin/shellcheck
- name: Lint pithead, build/* + dashboard/ container scripts, and test scripts (shellcheck + shfmt)
# Single source of truth: the Makefile `lint-sh` target (so the file list can't drift
# between here and the Makefile). Covers build/*/*.sh and dashboard/*.sh — the entrypoints
# + healthchecks that run in every container (#124). Gate on warnings+errors; info-level
# style nits vary by shellcheck version.
run: make lint-sh