-
-
Notifications
You must be signed in to change notification settings - Fork 14
363 lines (315 loc) · 14.9 KB
/
Copy pathpr-validation.yml
File metadata and controls
363 lines (315 loc) · 14.9 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
name: HolyCode - PR Validation
on:
pull_request:
workflow_dispatch:
concurrency:
group: pr-validation-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Manual main-branch validation requires DOCKERHUB_USERNAME and
# DOCKERHUB_TOKEN so Docker Scout can query its current advisory database.
jobs:
static-validation:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Require main for manual validation
if: github.event_name == 'workflow_dispatch'
run: test "$GITHUB_REF" = 'refs/heads/main'
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node for Renovate validation
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24.19.0
- name: Python version policy tests
run: python -m unittest discover -s tests
- name: Static action pin checks
run: python scripts/validate_workflow_pins.py
- name: Chromium seccomp profile
run: python scripts/validate_chromium_seccomp.py
- name: JSON syntax
run: python -m json.tool renovate.json >/tmp/renovate.json
- name: Workflow YAML syntax
run: ruby -e 'require "yaml"; Dir[".github/workflows/*.yml"].each { |path| YAML.load_file(path) }'
- name: Compose config
run: |
set -eu
docker compose -f docker-compose.yaml config --no-interpolate >/tmp/docker-compose.yaml
docker compose -f docker-compose.full.yaml config --no-interpolate >/tmp/docker-compose.full.yaml
if docker compose -f docker-compose.full.yaml config --services | grep -Fx cliproxyapi; then
echo "bundled CLIProxyAPI service must remain removed until its fixed image is verified" >&2
exit 1
fi
- name: Renovate configuration
run: bash scripts/validate_renovate_extraction.sh 44.24.2
build-and-smoke-test:
needs: static-validation
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
platform: linux/amd64
suffix: amd64
scout_arch: amd64
scout_sha256: f4e2814bd61040365153d5b964b144cb2dc6ee536a68b5bac4cadf00fc0ec34b
trivy_arch: 64bit
trivy_sha256: 2edd39da482bb4e9831962487b68f68e3928ec3137794757f54d00383d79547b
- runner: ubuntu-24.04-arm
platform: linux/arm64
suffix: arm64
scout_arch: arm64
scout_sha256: 8b21594c72d4d9403a82a49e9dbdfc04c27c6a21933906f1eefbb0beabe22d58
trivy_arch: ARM64
trivy_sha256: 13833d97e8a1a5367471c372a173180157f593bece570e20d5d925fef552f5dd
runs-on: ${{ matrix.runner }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Build image
run: docker build --platform "${{ matrix.platform }}" -t "holycode-pr-test:${{ matrix.suffix }}" .
- name: Smoke test image tools and secret hygiene
run: bash scripts/smoke_image.sh "holycode-pr-test:${{ matrix.suffix }}"
- name: Validate Drizzle esbuild remediation
run: |
docker run --rm --entrypoint sh "holycode-pr-test:${{ matrix.suffix }}" -lc '
set -eu
test ! -e /usr/local/lib/node_modules/drizzle-kit/node_modules/@esbuild-kit
jq -e ".version == \"0.28.1\"" /usr/local/lib/node_modules/drizzle-kit/node_modules/esbuild/package.json >/dev/null
drizzle-kit --version
drizzle-kit --help >/dev/null
'
- name: Validate plugin pin modes
run: bash scripts/test_plugin_modes.sh "holycode-pr-test:${{ matrix.suffix }}"
- name: Smoke test Paperclip skills catalog
run: |
set -eu
docker run --rm --entrypoint sh "holycode-pr-test:${{ matrix.suffix }}" -lc "
set -eu
test -f /usr/local/lib/node_modules/paperclipai/node_modules/@paperclipai/skills-catalog/generated/catalog.json
node --input-type=module -e '
import { listCatalogSkills } from \"/usr/local/lib/node_modules/paperclipai/node_modules/@paperclipai/server/dist/services/skills-catalog.js\";
const skills = listCatalogSkills();
if (Array.isArray(skills) === false || skills.length < 1) {
throw new Error(\"Skills catalog is empty\");
}
console.log(\"skills=\" + skills.length);
'
"
- name: Smoke test Paperclip runtime environment
run: |
set -eu
docker run -d --name holycode-paperclip-test \
-e ENABLE_PAPERCLIP=true \
"holycode-pr-test:${{ matrix.suffix }}"
cleanup() {
docker logs holycode-paperclip-test || true
docker rm -f holycode-paperclip-test || true
}
trap cleanup EXIT
ready=false
for _ in $(seq 1 90); do
if docker exec holycode-paperclip-test sh -lc 'curl -fsS http://localhost:3100/ >/dev/null' 2>/dev/null; then
ready=true
break
fi
if docker logs holycode-paperclip-test 2>&1 | grep -Eq '/root/.config/opencode|EACCES: permission denied'; then
exit 1
fi
sleep 2
done
[ "$ready" = true ]
docker exec -u opencode holycode-paperclip-test sh -lc '
pid="$(pgrep -u opencode -f "^node.*/paperclipai" | head -n 1)"
test -n "$pid"
xargs -0 -n 1 < "/proc/$pid/environ" > /tmp/paperclip-env
grep -Fx "HOME=/home/opencode" /tmp/paperclip-env
grep -Fx "XDG_CONFIG_HOME=/home/opencode/.config" /tmp/paperclip-env
grep -Fx "XDG_CACHE_HOME=/home/opencode/.cache" /tmp/paperclip-env
grep -Fx "XDG_DATA_HOME=/home/opencode/.local/share" /tmp/paperclip-env
grep -Fx "XDG_STATE_HOME=/home/opencode/.local/state" /tmp/paperclip-env
'
docker logs holycode-paperclip-test > /tmp/holycode-paperclip.log 2>&1 || true
if grep -F "/root/.config/opencode" /tmp/holycode-paperclip.log; then
exit 1
fi
if grep -F "EACCES: permission denied" /tmp/holycode-paperclip.log; then
exit 1
fi
if grep -F "Skills catalog manifest not found" /tmp/holycode-paperclip.log; then
exit 1
fi
- name: Validate Hermes migration guard
run: |
set -eu
docker volume create holycode-hermes-data >/dev/null
trap 'docker volume rm holycode-hermes-data >/dev/null 2>&1 || true' EXIT
docker run --rm --entrypoint sh -v holycode-hermes-data:/home/opencode "holycode-pr-test:${{ matrix.suffix }}" \
-lc 'mkdir -p /home/opencode/.hermes && touch /home/opencode/.hermes/preserved'
if docker run --rm -v holycode-hermes-data:/home/opencode \
-e ENABLE_HERMES=true "holycode-pr-test:${{ matrix.suffix }}" >/tmp/holycode-hermes.log 2>&1; then
echo "ENABLE_HERMES=true unexpectedly started the removed bundled service" >&2
exit 1
fi
grep -F "bundled Hermes is temporarily unavailable" /tmp/holycode-hermes.log
grep -F "/home/opencode/.hermes is preserved" /tmp/holycode-hermes.log
docker run --rm --entrypoint test -v holycode-hermes-data:/home/opencode \
"holycode-pr-test:${{ matrix.suffix }}" -f /home/opencode/.hermes/preserved
- name: Install Trivy CLI
if: github.event_name == 'workflow_dispatch'
env:
TRIVY_SHA256: ${{ matrix.trivy_sha256 }}
TRIVY_VERSION: 0.73.0
run: |
set -euo pipefail
archive="$RUNNER_TEMP/trivy_${TRIVY_VERSION}_Linux-${{ matrix.trivy_arch }}.tar.gz"
bin_dir="$RUNNER_TEMP/trivy-bin"
curl --disable --proto '=https' --tlsv1.2 --retry 8 --retry-all-errors \
--retry-max-time 300 --remove-on-error --connect-timeout 15 --max-time 300 \
--fail --silent --show-error --location --output "$archive" \
"https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-${{ matrix.trivy_arch }}.tar.gz"
printf '%s %s\n' "$TRIVY_SHA256" "$archive" | sha256sum --check --strict
mkdir -p "$bin_dir"
tar -xzf "$archive" -C "$bin_dir" trivy
chmod 0755 "$bin_dir/trivy"
echo "$bin_dir" >> "$GITHUB_PATH"
"$bin_dir/trivy" --version
- name: Generate pre-tag SPDX SBOM for Docker Scout
if: github.event_name == 'workflow_dispatch'
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
version: v0.73.0
skip-setup-trivy: true
image-ref: holycode-pr-test:${{ matrix.suffix }}
format: spdx-json
output: holycode-${{ matrix.suffix }}.spdx.json
- name: Install Docker Scout CLI for pre-tag validation
if: github.event_name == 'workflow_dispatch'
env:
SCOUT_SHA256: ${{ matrix.scout_sha256 }}
SCOUT_VERSION: 1.24.0
run: |
set -euo pipefail
archive="$RUNNER_TEMP/docker-scout_${SCOUT_VERSION}_linux_${{ matrix.scout_arch }}.tar.gz"
bin_dir="$RUNNER_TEMP/docker-scout-bin"
curl --disable --proto '=https' --tlsv1.2 --retry 8 --retry-all-errors \
--retry-max-time 300 --remove-on-error --connect-timeout 15 --max-time 300 \
--fail --silent --show-error --location --output "$archive" \
"https://github.com/docker/scout-cli/releases/download/v${SCOUT_VERSION}/docker-scout_${SCOUT_VERSION}_linux_${{ matrix.scout_arch }}.tar.gz"
printf '%s %s\n' "$SCOUT_SHA256" "$archive" | sha256sum --check --strict
mkdir -p "$bin_dir"
tar -xzf "$archive" -C "$bin_dir" docker-scout
chmod 0755 "$bin_dir/docker-scout"
echo "$bin_dir" >> "$GITHUB_PATH"
"$bin_dir/docker-scout" version
- name: Login to Docker Hub for pre-tag Docker Scout
if: github.event_name == 'workflow_dispatch'
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Generate pre-tag Docker Scout vulnerability reports
if: github.event_name == 'workflow_dispatch'
env:
SCOUT_FIXABLE_REPORT: holycode-${{ matrix.suffix }}.scout-fixable.sarif
SCOUT_REPORT: holycode-${{ matrix.suffix }}.scout.sarif
SCOUT_SBOM: holycode-${{ matrix.suffix }}.spdx.json
run: |
set -euo pipefail
docker-scout cves "sbom://$SCOUT_SBOM" \
--only-severity critical,high \
--format sarif \
--output "$SCOUT_REPORT"
docker-scout cves "sbom://$SCOUT_SBOM" \
--only-severity critical,high \
--only-fixed \
--format sarif \
--output "$SCOUT_FIXABLE_REPORT"
- name: Docker Scout pre-tag fixable critical and high gate
id: scout_gate
if: github.event_name == 'workflow_dispatch'
continue-on-error: true
env:
SCOUT_FIXABLE_REPORT: holycode-${{ matrix.suffix }}.scout-fixable.sarif
run: |
set -euo pipefail
jq -e '.runs | type == "array" and length > 0' "$SCOUT_FIXABLE_REPORT" >/dev/null
python scripts/validate_scanner_findings.py \
--scanner scout \
--report "$SCOUT_FIXABLE_REPORT" \
--as-of "$(date -u +%F)"
- name: Generate pre-tag Trivy vulnerability report
if: github.event_name == 'workflow_dispatch'
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
version: v0.73.0
skip-setup-trivy: true
image-ref: holycode-pr-test:${{ matrix.suffix }}
format: json
scanners: vuln,secret
severity: CRITICAL,HIGH
exit-code: 0
output: holycode-${{ matrix.suffix }}.trivy.json
- name: Trivy pre-tag fixable critical and high gate
if: github.event_name == 'workflow_dispatch'
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
version: v0.73.0
skip-setup-trivy: true
image-ref: holycode-pr-test:${{ matrix.suffix }}
format: json
scanners: vuln,secret
severity: CRITICAL,HIGH
exit-code: 0
ignore-unfixed: true
output: holycode-${{ matrix.suffix }}.trivy-fixable.json
- name: Validate pre-tag Trivy fixable critical and high findings
id: trivy_gate
if: github.event_name == 'workflow_dispatch'
continue-on-error: true
run: |
set -euo pipefail
python scripts/validate_scanner_findings.py \
--scanner trivy \
--report "holycode-${{ matrix.suffix }}.trivy-fixable.json" \
--as-of "$(date -u +%F)"
- name: Collect pre-tag architecture evidence
if: always() && github.event_name == 'workflow_dispatch'
run: |
set -euo pipefail
docker run --rm --entrypoint cat \
"holycode-pr-test:${{ matrix.suffix }}" \
/usr/local/share/holycode/dpkg-inventory.txt \
> "holycode-${{ matrix.suffix }}.dpkg-inventory.txt"
docker image inspect \
--format '{{.Id}}' \
"holycode-pr-test:${{ matrix.suffix }}" \
> "holycode-${{ matrix.suffix }}.image-id.txt"
printf '%s\n' "$GITHUB_SHA" > "holycode-${{ matrix.suffix }}.commit-sha.txt"
- name: Upload pre-tag architecture evidence
if: always() && github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: holycode-pretag-${{ github.sha }}-${{ matrix.suffix }}-evidence
if-no-files-found: error
path: |
holycode-${{ matrix.suffix }}.commit-sha.txt
holycode-${{ matrix.suffix }}.dpkg-inventory.txt
holycode-${{ matrix.suffix }}.image-id.txt
holycode-${{ matrix.suffix }}.scout-fixable.sarif
holycode-${{ matrix.suffix }}.scout.sarif
holycode-${{ matrix.suffix }}.spdx.json
holycode-${{ matrix.suffix }}.trivy-fixable.json
holycode-${{ matrix.suffix }}.trivy.json
- name: Enforce pre-tag scanner gates
if: always() && github.event_name == 'workflow_dispatch'
env:
SCOUT_GATE_OUTCOME: ${{ steps.scout_gate.outcome }}
TRIVY_GATE_OUTCOME: ${{ steps.trivy_gate.outcome }}
run: |
set -eu
test "$SCOUT_GATE_OUTCOME" = "success"
test "$TRIVY_GATE_OUTCOME" = "success"