ci: measure native bootstrap while preserving workspace features (#284)

* ci: guard a bounded native geometry measurement with exact planned closure

* ci: preserve workspace features while measuring native browser bootstrap
This commit is contained in:
FredApps authored and GitHub committed 2026-11-19 12:20:14 +07:00
1 parent b5c6f5913e
commit 0be61baefd
3 files changed
+268

No files matched your search

@@ -0,0 +1,133 @@
name: Photo FreeBSD browser bootstrap measurement
on:
pull_request:
paths:
- .github/workflows/photo-boot-measurement.yml
- scripts/compare_cargo_unit_closure.py
- tests/test_compare_cargo_unit_closure.py
permissions:
contents: read
jobs:
bootstrap:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- run: python3 -m unittest discover -s tests -p test_compare_cargo_unit_closure.py -v
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: storytold/photocraft
ref: 057297bb0b0872244ac0910e640db8d87e46572f
path: photo
persist-credentials: false
- name: Verify pinned checkout before VM transfer
run: |
test "$(git -C photo rev-parse HEAD)" = 057297bb0b0872244ac0910e640db8d87e46572f
python3 - <<'PYCODE'
import hashlib, json, os, pathlib, subprocess
names = subprocess.check_output(['git', '-C', 'photo', 'ls-files', '-z']).split(bytes([0]))
identity = {}
for raw_name in filter(None, names):
name = os.fsdecode(raw_name)
path = pathlib.Path('photo') / name
kind = 'symlink' if path.is_symlink() else 'file'
data = os.readlink(path).encode() if kind == 'symlink' else path.read_bytes()
identity[str(path)] = [kind, hashlib.sha256(data).hexdigest()]
assert identity, 'empty source inventory'
pathlib.Path('photo-source-identity.json').write_text(json.dumps(identity, sort_keys=True))
PYCODE
- name: Prepare native FreeBSD host, without application compilation
uses: step-security/freebsd-vm@a2f5754275f7b0d5cea7f2762c9960727950f128
with:
release: '15.1'
usesh: 'true'
cpu: '4'
mem: '12288'
copyback: 'false'
prepare: pkg install -y git curl python3
- name: Install official pinned nightly planner and stable compiler
shell: freebsd {0}
run: |
set -eu
test "$(uname -s)" = FreeBSD
curl --proto '=https' --tlsv1.2 --retry 2 --connect-timeout 15 --max-time 60 -fsS https://sh.rustup.rs -o /tmp/photo-install-rustup.sh
timeout 180s sh /tmp/photo-install-rustup.sh -y --profile minimal --default-toolchain nightly-2026-11-18 --no-modify-path
"$HOME/.cargo/bin/cargo" +nightly-2026-11-18 -Vv
"$HOME/.cargo/bin/rustc" +nightly-2026-11-18 -Vv
timeout 180s "$HOME/.cargo/bin/rustup" toolchain install 1.100.0 --profile minimal
"$HOME/.cargo/bin/rustc" +1.100.0 -Vv
- name: Verify planned closure, then measure only native browser bootstrap
shell: freebsd {0}
run: |
set -eu
export PATH="$HOME/.cargo/bin:$PATH"
cd photo
python3 - <<'PYCODE'
import hashlib, json, os, pathlib
identity = json.loads(pathlib.Path('../photo-source-identity.json').read_text())
for name, expected in identity.items():
path = pathlib.Path('..') / name
kind = 'symlink' if path.is_symlink() else 'file'
data = os.readlink(path).encode() if kind == 'symlink' else path.read_bytes()
assert [kind, hashlib.sha256(data).hexdigest()] == expected, name
print('All tracked source files match host-verified pinned checkout')
PYCODE
sha256 Cargo.toml Cargo.lock
mkdir /tmp/photo-unit-graphs
timeout 60s cargo +nightly-2026-11-18 metadata --offline --no-deps --format-version 1 > /tmp/photo-unit-graphs/metadata.json
timeout 120s cargo +nightly-2026-11-18 test --locked --workspace --features heif --target x86_64-unknown-freebsd --unit-graph -Z unstable-options > /tmp/photo-unit-graphs/full.json
timeout 120s cargo +nightly-2026-11-18 test --locked --workspace --features heif --bin photocraft-web-boot --target x86_64-unknown-freebsd --unit-graph -Z unstable-options > /tmp/photo-unit-graphs/isolated.json
timeout 30s python3 ../scripts/compare_cargo_unit_closure.py /tmp/photo-unit-graphs/full.json /tmp/photo-unit-graphs/isolated.json /tmp/photo-unit-graphs/metadata.json photocraft-web-boot bin
echo 'Stable compile begins: browser bootstrap only; not the full application'
/usr/bin/time -l timeout 420s cargo +1.100.0 test --locked --workspace --features heif --bin photocraft-web-boot --target x86_64-unknown-freebsd --no-run --jobs 2 --message-format=json > /tmp/photo-boot-artifacts.jsonl
cat /tmp/photo-boot-artifacts.jsonl
python3 - <<'PYCODE'
import json, pathlib
metadata = json.loads(pathlib.Path('/tmp/photo-unit-graphs/metadata.json').read_text())
package_ids = [p['id'] for p in metadata['packages'] if p['name'] == 'photocraft-web-boot']
assert len(package_ids) == 1
artifacts = [json.loads(line) for line in pathlib.Path('/tmp/photo-boot-artifacts.jsonl').read_text().splitlines()]
executables = [a['executable'] for a in artifacts if a.get('reason') == 'compiler-artifact'
and a.get('package_id') == package_ids[0] and a.get('profile', {}).get('test')
and a.get('target', {}).get('kind') == ['bin'] and a.get('executable')]
assert len(executables) == 1, executables
executable = pathlib.Path(executables[0])
assert executable.is_file()
pathlib.Path('/tmp/photo-boot-executable').write_text(str(executable))
PYCODE
executable="$(cat /tmp/photo-boot-executable)"
sha256 "$executable"
timeout 30s "$executable" --list --format pretty --color never > /tmp/photo-boot-list.txt
cat /tmp/photo-boot-list.txt
/usr/bin/time -l timeout 60s "$executable" --test-threads=1 --format pretty --color never > /tmp/photo-boot-result.txt
cat /tmp/photo-boot-result.txt
python3 - <<'PYCODE'
import pathlib, re
listed = pathlib.Path('/tmp/photo-boot-list.txt').read_text()
result = pathlib.Path('/tmp/photo-boot-result.txt').read_text()
totals = re.findall(r'(?m)^(\d+) tests?, (\d+) benchmarks?$', listed)
outcomes = re.findall(r'test result: ok\. (\d+) passed; (\d+) failed; (\d+) ignored; (\d+) measured; (\d+) filtered out;', result)
assert len(totals) == len(outcomes) == 1, 'missing or ambiguous libtest summary'
total, benches = map(int, totals[0])
passed, failed, ignored, measured, filtered = map(int, outcomes[0])
assert total > 0 and passed > 0 and total == passed + ignored
assert not (benches or failed or measured or filtered)
print(f'Validated nonzero native bootstrap coverage: {passed} passed, {ignored} ignored')
PYCODE
python3 - <<'PYCODE'
import hashlib, json, os, pathlib
identity = json.loads(pathlib.Path('../photo-source-identity.json').read_text())
for name, expected in identity.items():
path = pathlib.Path('..') / name
kind = 'symlink' if path.is_symlink() else 'file'
data = os.readlink(path).encode() if kind == 'symlink' else path.read_bytes()
assert [kind, hashlib.sha256(data).hexdigest()] == expected, name
print('Planning left all tracked source files unchanged')
PYCODE
echo 'Only browser-bootstrap binary libtest compiled/executed. No UI, application, doctest or full-gate coverage claim.'
echo 'Nightly closure equality is planned evidence only; stable measurement is limited to browser bootstrap.'