fix(ci): verify installer provenance in build workflows (#4677)

## Current maintainer status (2026-11-10, current-main refresh)

Published head: `db4bdd71e7ddc1a72316445ef0d16a7d90b62951`, containing
upstream main `a385ea8e60a14c1511d82b21d518421af35deab2` through a clean
mechanical merge. All 13 remediation files are byte-identical to
reviewed head `81ff3ed384afbd404c48fd79d6bed41e8d647a99`; no installer,
action metadata, or checksum selection changed.

Fresh focused Windows checks: 61 passed and 23 platform skips. Fresh WSL
offline bootstrap/hook fixtures: 23 passed, with one pytest
configuration warning. These local checks use fixtures and do not claim
live vendor, provider, or native GUI execution.

Exact-head CI, including Docker-native, and the Init, Wrap, Rust,
governance, changelog, and merge-conflict workflows succeeded. Security
remains FAILURE: the OpenCode npm audit reports two moderate findings
through Effect advisory GHSA-chp3-j5qr-2vfr. The security workflow and
affected OpenCode package manifest/lock are byte-identical to current
main, establishing an inherited dependency finding. This is not an
all-green result or a fresh audit of main. No workflow rerun, dependency
downgrade, or advisory override was performed on this branch.

Independent human review and integration remain required. No
self-approval or merge was performed. Other branch publication and
execution holds remain active. All older qualification below belongs to
its recorded historical heads.

---



## Description

Build validation jobs fetched mutable installer scripts, and the pinned
commitlint action still declared a mutable Docker image tag. This pins
that image digest, verifies workflow-tool archives and cached binaries,
and replaces the Docker bootstrap scripts with pinned, verified sources.


## Type of Change

- [x] Bug fix



## Changes Made

- Preserve Rust 1.95.0, minimal/rustfmt/clippy options, Node 24, npm
12.2.1, and OpenCode 1.17.8.
- Preserve Debian userland architecture detection, Rustup ARM fallback,
and OpenCode x64 AVX2/baseline selection.
- Use an official Node image pinned by manifest digest; retain
npm/corepack trees and explicit runtime libraries.
- Add offline bootstrap tests for failed downloads, corrupt bytes,
unsupported targets, symlinks, and option forwarding.


## Testing

- [x] Offline bootstrap tests pass (stdlib unittest, 16 cases).

- [x] Ruff lint/format pass for the two new test files; shell syntax and
whitespace checks pass.
- [x] Exact-head hosted CI passed, including platform tests and
Docker-native, Init, and Wrap build/container checks.


### Test Output

```text

python3 -m unittest discover -s tests/test_install -p 'test_*bootstrap.py'

................

Ran 16 tests in 0.770s

OK

```



## Real Behavior Proof

- Environment: Ubuntu 24.04 under WSL, exact candidate
4ee38e8619.
- Exact command / steps: Run the unittest discovery command above.
Separately stream the recorded release archives and official Node image
layer through SHA-256 and inspect their tar headers.
- Observed result: Invalid bytes stop before extraction/execution;
fixture platform and CPU cases select the intended archives. Actual
workflow-tool/OpenCode archives and the Node layer match published
digests. The Rustup x64 binary matches its vendor checksum; all nine
embedded target checksums match vendor records.
- Not tested: No live model/provider behavior or unexercised
architecture is claimed. Local bootstrap fixtures use mocks; the hosted
Docker/build checks below exercised the actual pinned installation
paths.


## Runtime Rollout Safety

- Rollout-managed feature(s): None; CI/build bootstrap only.

- Minimum rollout channel: Not applicable.

- Stable/default behavior changed: Build inputs become pinned; proxy
defaults, Rust 1.95.0/components, npm 12.2.1 and OpenCode 1.17.8 stay
unchanged. Node remains on the 24 LTS line with a fixed image digest.
- Kill switch / disable path: Revert the maintenance change through
review; do not bypass checksum failures.
- Unsafe override required: None for this exact reviewed candidate.

- Qualification impact: The exact-head hosted checks below passed.
Existing PR heads retain their separate security/qualification holds
until main is remediated and their own gates are refreshed.
- Rollback path: Revert this maintenance PR if build compatibility
regresses.


## Review Readiness

- [x] I performed a self-review.

- [x] This PR is ready for human review.



## Checklist

- [x] New security regression tests are included.

- [x] CHANGELOG.md is unchanged.



## Additional Notes

Static independent code review found no defects. No merge or
self-approval is requested. Completed historical CI evidence is retained
within its original scope; this change qualifies future installer
execution separately.


Initial hosted validation of b2592de8d stopped at rustup filename
dispatch. Follow-up 4ee38e861 retains the required rustup-init basename
in a private directory and adds the reproducing regression test. All
nine latest applicable hosted workflows passed on the corrected head.


### Hosted validation on 4ee38e861

- [CI: platform tests and Docker-native
build/install/compose/wrap/init](https://github.com/headroomlabs-ai/headroom/actions/runs/42352878789):
success.
- [Wrap
E2E](https://github.com/headroomlabs-ai/headroom/actions/runs/42352878762),
[Init
E2E](https://github.com/headroomlabs-ai/headroom/actions/runs/42352878760),
[Init Native
E2E](https://github.com/headroomlabs-ai/headroom/actions/runs/42352878767),
and
[Security](https://github.com/headroomlabs-ai/headroom/actions/runs/42352878768):
success.
- Governance, changelog, Rust and merge-conflict checks also passed. The
older cancelled governance duplicate was superseded by a successful run.


Independent human review is required. No self-approval or merge has been
performed.




### Local-action metadata coverage follow-up



`38337d8be` adds `.github/actions/**` to both code and workflow filters.
The normal pytest suite now checks the vendored commitlint metadata
structure and immutable Docker digest; this is separate from actionlint
workflow parsing. Six focused CI regression tests pass, including a
filter regression that failed before the fix. Independent delta review
found no issues. `38337d8be` now has successful latest applicable CI,
Wrap E2E, Init E2E, Init Native E2E, Security, Rust, Changelog Guard,
Merge Conflicts, and PR Governance runs. The successful runs above
remain historical evidence for `4ee38e861`.




Current-head
[CI](https://github.com/headroomlabs-ai/headroom/actions/runs/42360858297),
[Wrap](https://github.com/headroomlabs-ai/headroom/actions/runs/42360858271),
[Init](https://github.com/headroomlabs-ai/headroom/actions/runs/42360858296),
[Init
Native](https://github.com/headroomlabs-ai/headroom/actions/runs/42360858178),
and
[Security](https://github.com/headroomlabs-ai/headroom/actions/runs/42360858352)
passed. Independent human review remains required; no self-approval or
merge.


<!-- maintainer-current-main-qualification -->

## Current-main qualification



Published head `9381378ffb07e466acef6a57eb39322aa84d4582` includes
upstream main `bb8d18a56abb07ca7e811235c86ea6b626eb1f8b` and is
mergeable. All nine exact-head workflows succeeded; all 53 jobs are
terminal success or explicit skips, including CI Docker-native,
wrap/init and native-init validation. Local metadata/release checks: 61
passed; 16 Linux-only bootstrap tests skipped on Windows. Remediation
installer/action sources are unchanged by the clean main integration.


Independent human review and merge are required. No self-approval or
merge performed. This PR does not lift the inherited
execution-provenance hold on main or other branches before human
integration.
<!-- /maintainer-current-main-qualification -->



### Maintainer current-main refresh (a2bcbd101)

Published `a20f072a238a1f8de422adf6a25d3f9d664151e4` incorporates
upstream main `a2bcbd101b1391debfd218ec8c63cb72d2bc240a` through a clean
merge. All 13 previously screened CI provenance remediation files are
byte-identical to prior published head
`9381378ffb07e466acef6a57eb39322aa84d4582`; no
installer/action/remediation logic was rewritten. Fresh focused checks:
61 passed, 23 platform-specific shell cases skipped on Windows. No
vendor installer, Docker image or downloaded binary was executed
locally. Earlier Linux bootstrap and hosted evidence retain their
original scope.

Fresh exact-head hosted validation completed successfully: all 10
observed workflow runs succeeded; all 56 checks are terminal successful
or explicitly skipped. Ready for independent human review on this
head/current main. This remediation branch alone is permitted to run its
screened checks; inherited execution/publication holds on main and other
PRs remain until independent human integration. Independent review is
required; no self-approval, merge or release publication.

---------

Co-authored-by: Jerrett Davis <JerrettDavis@users.noreply.github.com>
This commit is contained in:
JD Davis
2026-11-10 21:02:42 -06:00
committed by GitHub
co-authored by Jerrett Davis
parent 19d439f7b0
commit b235bc2d27
13 changed files with 532 additions and 18 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Wagner Santos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+13
View File
@@ -0,0 +1,13 @@
# Commitlint action provenance
`action.yml` is vendored from [wagoid/commitlint-github-action](https://github.com/wagoid/commitlint-github-action/blob/b948419dd99f3fd78a6548d48f94e3df7f6bf3ed/action.yml) at `b948419dd99f3fd78a6548d48f94e3df7f6bf3ed` (v6.2.1). The upstream MIT license is preserved in `LICENSE`.
The only metadata change replaces the mutable `docker://wagoid/commitlint-github-action:6.2.1` reference with the immutable image digest observed in completed CI job `128302466922`, run `42339062117`:
```text
sha256:86a04e0a99128551a7555c269d2b675c3c85f61358cf7dd558f6b873b66f561a
```
All upstream inputs, defaults, outputs, and Docker execution metadata are preserved. Keeping action metadata preserves GitHub input default expansion and `INPUT_*` environment variables; using an image directly in the workflow would omit that contract. The workflow checkout must precede this local action.
This pins historical execution provenance; it does not attest to image contents or authorize CI execution. Future upgrades must review both the upstream metadata and immutable container digest.
+41
View File
@@ -0,0 +1,41 @@
name: Commit Linter
description: Lints Pull Request commit messages with commitlint
author: Wagner Santos
inputs:
configFile:
description: Commitlint config file. If the file doesn't exist, config-conventional settings will be
loaded as a fallback.
default: ./commitlint.config.mjs
required: false
failOnWarnings:
description: Whether you want to fail on warnings or not
default: "false"
required: false
failOnErrors:
description: Whether you want to fail on errors or not
default: "true"
required: true
helpURL:
description: Link to a page explaining your commit message convention
default: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
required: false
commitDepth:
description: When set to a valid Integer value - X, considers only the latest X number of commits.
default: ""
required: false
token:
description: >
Personal access token (PAT) used to interact with the GitHub API. By default, the automatic
token provided by GitHub is used. You can see more info about GitHub's default token here:
https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
default: ${{ github.token }}
required: false
outputs:
results:
description: The error and warning messages for each one of the analyzed commits
runs:
using: docker
image: docker://wagoid/commitlint-github-action@sha256:86a04e0a99128551a7555c269d2b675c3c85f61358cf7dd558f6b873b66f561a
branding:
icon: check-square
color: blue
+23 -5
View File
@@ -63,6 +63,7 @@ jobs:
- 'tests/**'
- 'scripts/**'
- '.github/workflows/**'
- '.github/actions/**'
# native = anything that can change the compiled wrapper, the native
# install flow, or the docker image (drives the scarce macOS/Windows
# runners + docker E2E). A pure-Python logic change hits none of these.
@@ -99,6 +100,7 @@ jobs:
- '.github/workflows/**'
workflows:
- '.github/workflows/**'
- '.github/actions/**'
lint:
needs: changes
@@ -611,7 +613,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
- uses: ./.github/actions/commitlint
with:
configFile: .commitlintrc.json
@@ -672,14 +674,30 @@ jobs:
- name: Install actionlint
if: steps.tools-cache.outputs.cache-hit != 'true'
run: |
curl -fsSL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash | bash
sudo mv ./actionlint /usr/local/bin/actionlint
archive="$RUNNER_TEMP/actionlint.tar.gz"
curl --proto '=https' --tlsv1.2 -fsSL \
https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz \
--output "$archive"
printf '%s %s\n' '8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8' "$archive" | sha256sum --check --strict -
tar --extract --gzip --file "$archive" --directory "$RUNNER_TEMP" actionlint
sudo install -m 0755 -- "$RUNNER_TEMP/actionlint" /usr/local/bin/actionlint
- name: Install act
if: steps.tools-cache.outputs.cache-hit != 'true'
run: |
curl -fsSL https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
sudo install ./bin/act /usr/local/bin/act
archive="$RUNNER_TEMP/act.tar.gz"
curl --proto '=https' --tlsv1.2 -fsSL \
https://github.com/nektos/act/releases/download/v0.2.97/act_Linux_x86_64.tar.gz \
--output "$archive"
printf '%s %s\n' '67b4976a56f33ea7870b798912e738ec44eef38e7578ae7b532f2def1c73a5ad' "$archive" | sha256sum --check --strict -
tar --extract --gzip --file "$archive" --directory "$RUNNER_TEMP" act
sudo install -m 0755 -- "$RUNNER_TEMP/act" /usr/local/bin/act
- name: Verify installed workflow tools
run: |
printf '%s %s\n' \
'c872d6db8c6bf83a8eaa704fc93999f027d55dffbc63b8a6abdccb47df5f4cd4' /usr/local/bin/actionlint \
'c4d4728b7375fad11980456249edeb3a4ca48ba4e785cb8100ad14bd53e77056' /usr/local/bin/act \
| sha256sum --check --strict -
- name: Validate workflow files
run: bash scripts/validate-workflows.sh
+2
View File
@@ -12,6 +12,8 @@ scripts/
!scripts/
scripts/*
!scripts/install.sh
!scripts/install-rustup.sh
!scripts/install-opencode.sh
!scripts/install.ps1
!scripts/version-sync.py
!scripts/sync-plugin-versions.py
+2 -2
View File
@@ -34,8 +34,8 @@ RUN python -m pip install --no-cache-dir uv==${UV_VERSION}
ENV CARGO_HOME=/usr/local/cargo \
RUSTUP_HOME=/usr/local/rustup \
PATH=/usr/local/cargo/bin:${PATH}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path --profile minimal -c rustfmt -c clippy --default-toolchain 1.95.0
COPY scripts/install-rustup.sh /tmp/install-rustup.sh
RUN sh /tmp/install-rustup.sh -y --no-modify-path --profile minimal -c rustfmt -c clippy --default-toolchain 1.95.0
WORKDIR /build
+2 -2
View File
@@ -12,8 +12,8 @@ FROM quay.io/pypa/manylinux_2_28_x86_64 AS builder
ENV CARGO_HOME=/usr/local/cargo \
RUSTUP_HOME=/usr/local/rustup \
PATH=/usr/local/cargo/bin:/opt/python/cp311-cp311/bin:${PATH}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path --profile minimal -c rustfmt -c clippy --default-toolchain 1.95.0
COPY scripts/install-rustup.sh /tmp/install-rustup.sh
RUN sh /tmp/install-rustup.sh -y --no-modify-path --profile minimal -c rustfmt -c clippy --default-toolchain 1.95.0
WORKDIR /build
+18 -9
View File
@@ -25,8 +25,8 @@ FROM quay.io/pypa/manylinux_2_28_x86_64 AS builder
ENV CARGO_HOME=/usr/local/cargo \
RUSTUP_HOME=/usr/local/rustup \
PATH=/usr/local/cargo/bin:/opt/python/cp311-cp311/bin:${PATH}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path --profile minimal -c rustfmt -c clippy --default-toolchain 1.95.0
COPY scripts/install-rustup.sh /tmp/install-rustup.sh
RUN sh /tmp/install-rustup.sh -y --no-modify-path --profile minimal -c rustfmt -c clippy --default-toolchain 1.95.0
WORKDIR /build
@@ -55,6 +55,9 @@ RUN /opt/python/cp311-cp311/bin/pip install 'maturin>=1.5,<2.0' && \
# headers). Bookworm's libc.so.6 doesn't export these wrappers, so
# `import headroom._core` fails at runtime. Trixie's glibc 2.41 does.
#
# Node 24.22.2 from the official multi-platform image; no NodeSource setup script.
FROM node:24-bookworm-slim@sha256:01d566e8d94d8c619591d78652babfccd3c6992a3dffa9ed5ab39e11cf6c70e9 AS wrap-node
# We need Python 3.11 here (aider-chat==0.86.2 requires Python <3.12).
# Trixie's default `python3` is 3.13 — too new for aider. python:3.11-slim
# gives us Python 3.11 + trixie glibc + apt access for installing Node.
@@ -77,11 +80,17 @@ RUN apt-get update && \
ca-certificates \
curl \
git \
gnupg && \
curl -fsSL https://deb.nodesource.com/setup_24.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
gnupg \
libstdc++6 \
libatomic1 && \
rm -rf /var/lib/apt/lists/*
COPY --from=wrap-node /usr/local/bin/node /usr/local/bin/node
COPY --from=wrap-node /usr/local/lib/node_modules/ /usr/local/lib/node_modules/
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx && \
ln -s ../lib/node_modules/corepack/dist/corepack.js /usr/local/bin/corepack
# npm 10.9.8 crashes in Arborist's peer-set resolver when installing the local
# OpenClaw plugin (Cannot read properties of null, reading 'edgesOut'). Pin the
# tested npm version so both wrap-e2e callers use the same working installer.
@@ -110,6 +119,7 @@ COPY --from=builder /dist/*.whl /tmp/wheels/
# triggering the same `ModuleNotFoundError` the wheel install fixes.
COPY sdk/typescript ./sdk/typescript
COPY plugins/openclaw ./plugins/openclaw
COPY scripts/install-opencode.sh /tmp/install-opencode.sh
# Install the prebuilt manylinux wheel with [proxy] extras. Pip resolves
# extras from the wheel's metadata and pulls deps from public PyPI. The
@@ -122,11 +132,10 @@ RUN python -m venv /opt/headroom-venv && \
python -m venv /opt/aider-venv && \
/opt/aider-venv/bin/python -m pip install --upgrade pip && \
/opt/aider-venv/bin/python -m pip install "aider-chat==${AIDER_CHAT_VERSION}" && \
curl -fsSL https://opencode.ai/install | VERSION="${OPENCODE_VERSION}" bash
sh /tmp/install-opencode.sh "${OPENCODE_VERSION}"
# The opencode installer adds its bin dir to .bashrc. Non-login shells
# (including CMD, docker run, and e2e shims spawned by subprocess) won't
# source .bashrc, so add the dir to PATH explicitly. The e2e shim shadows
# Expose the installed binary to non-login shells (including CMD, docker run,
# and e2e shims spawned by subprocess). The e2e shim shadows
# opencode anyway, but this guarantees `which opencode` works for
# diagnostics.
ENV PATH="/root/.opencode/bin:${PATH}"
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
# Install the pinned OpenCode release into the glibc Wrap E2E runtime.
# Archive digests are from the GitHub v1.17.8 release asset metadata.
set -eu
version=${1:?OpenCode version is required}
if [ "$version" != 1.17.8 ]; then
printf 'Unsupported unreviewed OpenCode version: %s\n' "$version" >&2
exit 1
fi
case "$(uname -m)" in
x86_64)
target=linux-x64
# Preserve the vendor installer's fallback on CPUs without AVX2.
if ! grep -qwi avx2 /proc/cpuinfo 2>/dev/null; then
target=linux-x64-baseline
fi
;;
aarch64|arm64) target=linux-arm64 ;;
*) printf 'Unsupported OpenCode Docker architecture\n' >&2; exit 1 ;;
esac
case "$target" in
linux-x64) checksum=13fffc29227093462b7d14777ea6b804cfd94c2612819c101bbf933d862b1e5f ;;
linux-x64-baseline) checksum=9b34bf34bdc66ea34ddd5858a131febf28b6247693acbfb5fb5c9ad94d90388b ;;
linux-arm64) checksum=cfb34a6a9a40f9a2adb0d0f3ab387b97307823d075572bfb54a553228adcebbd ;;
esac
temporary=$(mktemp -d)
trap 'rm -rf -- "$temporary"' EXIT
archive="$temporary/opencode.tar.gz"
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fsSL \
"https://github.com/anomalyco/opencode/releases/download/v$version/opencode-$target.tar.gz" \
--output "$archive"
printf '%s %s\n' "$checksum" "$archive" | sha256sum --check --strict -
tar --extract --gzip --file "$archive" --directory "$temporary" --no-same-owner opencode
if [ ! -f "$temporary/opencode" ] || [ -L "$temporary/opencode" ]; then
printf 'Expected a regular OpenCode binary in the verified archive\n' >&2
exit 1
fi
mkdir -p "$HOME/.opencode/bin"
install -m 0755 -- "$temporary/opencode" "$HOME/.opencode/bin/opencode"
+54
View File
@@ -0,0 +1,54 @@
#!/bin/sh
# Bootstrap the Linux/glibc Docker builders without executing a mutable script.
# Digest source: https://static.rust-lang.org/rustup/archive/1.29.3/<target>/rustup-init.sha256
# Update the version and all target digests together after provenance review.
set -eu
version=1.29.3
if command -v dpkg >/dev/null 2>&1 && architecture=$(dpkg --print-architecture); then
: # Debian's userland architecture can differ from the host kernel's.
else
architecture=$(uname -m)
fi
case "$architecture" in
amd64|x86_64) target=x86_64-unknown-linux-gnu ;;
arm64|aarch64) target=aarch64-unknown-linux-gnu ;;
i386|i486|i586|i686) target=i686-unknown-linux-gnu ;;
armel|armv5tel|armv5tejl|arm|xscale) target=arm-unknown-linux-gnueabi ;;
armv6l) target=arm-unknown-linux-gnueabihf ;;
armhf|armv7l|armv8l)
target=armv7-unknown-linux-gnueabihf
# Match upstream rustup's fallback for ARM CPUs without NEON/SIMD.
if ! (grep '^Features' /proc/cpuinfo | grep -E -q 'neon|simd'); then
target=arm-unknown-linux-gnueabihf
fi
;;
ppc64el|ppc64le) target=powerpc64le-unknown-linux-gnu ;;
riscv64) target=riscv64gc-unknown-linux-gnu ;;
s390x) target=s390x-unknown-linux-gnu ;;
*) printf 'Unsupported Docker builder architecture: %s\n' "$architecture" >&2; exit 1 ;;
esac
case "$target" in
x86_64-unknown-linux-gnu) checksum=b1c8cb14e30889e7e2999e6b69e62d9e9b9ffc0f4df8180564d306d9680e6c55 ;;
aarch64-unknown-linux-gnu) checksum=9f608c142e0e38a78957d0661ba1dfaf0b6fb37184cfaa4b9a0aa57af6184282 ;;
i686-unknown-linux-gnu) checksum=ef58377096e940ed8ba0d7f8841e6d125922d9d218e04897a05b7f667cf6f5c5 ;;
arm-unknown-linux-gnueabi) checksum=4053cbe46140f8c6dd9c657e0b8fead09ec35f77bcd740c8a32f8ce54a80eb57 ;;
arm-unknown-linux-gnueabihf) checksum=56319bf0c965276fac4c5be99241782d03b647cc79af8934ba9afda0351288cc ;;
armv7-unknown-linux-gnueabihf) checksum=3d5771c716551ee55368be40e02859705f06d725b31df07c15e3593be2d2a5de ;;
powerpc64le-unknown-linux-gnu) checksum=d5b321db031525fbee38b736846f07a16df22b354a1964bbb79ff83495dbc0c9 ;;
riscv64gc-unknown-linux-gnu) checksum=e4a960952692ac3dfb5fa4f74e593517241b83e43a93fbdcf2213c811748f1ae ;;
s390x-unknown-linux-gnu) checksum=df1762614062280a326ac988019ed1f8ceebeafa5fac95164a7201ff10e31d4b ;;
esac
temporary=$(mktemp -d)
trap 'rm -rf -- "$temporary"' EXIT
# rustup dispatches installer/proxy mode by argv[0], so retain this basename.
installer="$temporary/rustup-init"
curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fsSL \
"https://static.rust-lang.org/rustup/archive/$version/$target/rustup-init" \
--output "$installer"
printf '%s %s\n' "$checksum" "$installer" | sha256sum --check --strict -
chmod 700 "$installer"
"$installer" "$@"
@@ -0,0 +1,136 @@
"""Offline archive verification and CPU selection checks for the Docker helper."""
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
@unittest.skipUnless(os.name == "posix", "Docker bootstrap runs on Linux")
class OpenCodeBootstrapTests(unittest.TestCase):
def setUp(self):
self.fixture = tempfile.TemporaryDirectory(prefix="headroom-opencode-test-")
self.addCleanup(self.fixture.cleanup)
self.root = Path(self.fixture.name)
self.bin = self.root / "bin"
self.bin.mkdir()
self.trace = self.root / "trace"
self.env = dict(
os.environ,
PATH=f"{self.bin}:{os.environ['PATH']}",
HOME=str(self.root / "home"),
TMPDIR=str(self.root),
PROBE_TRACE=str(self.trace),
PROBE_ARCH="x86_64",
PROBE_AVX2="1",
PROBE_SYMLINK="0",
)
self.stub("uname", 'printf "%s\\n" "$PROBE_ARCH"')
self.stub("grep", '[ "$PROBE_AVX2" = 1 ]')
self.stub(
"curl",
"""printf 'download\\n' >> "$PROBE_TRACE"
while [ "$#" -gt 0 ]; do
case "$1" in
--output) printf 'untrusted archive fixture' > "$2"; shift 2;;
https://*) printf '%s\\n' "$1" > "$PROBE_TRACE.url"; shift;;
*) shift;;
esac
done""",
)
self.stub(
"tar",
"""printf 'extract\\n' >> "$PROBE_TRACE"
while [ "$#" -gt 0 ]; do
case "$1" in --directory) destination="$2"; shift 2;; *) shift;; esac
done
if [ "$PROBE_SYMLINK" = 1 ]; then
ln -s /bin/sh "$destination/opencode"
else
printf 'inert fixture' > "$destination/opencode"
fi""",
)
self.stub(
"install",
'printf "install\\n" >> "$PROBE_TRACE"\nprintf "%s\\n" "$@" > "$PROBE_TRACE.args"',
)
self.script = Path(__file__).resolve().parents[2] / "scripts/install-opencode.sh"
def stub(self, name, body):
path = self.bin / name
path.write_text("#!/bin/sh\nset -eu\n" + body + "\n")
path.chmod(0o755)
def run_bootstrap(self, version="1.17.8"):
self.assertTrue(self.script.is_file(), "checksum bootstrap helper is required")
return subprocess.run(
["sh", str(self.script), version], env=self.env, capture_output=True, text=True
)
def allow_fixture_checksum(self):
self.stub("sha256sum", 'cat > "$PROBE_TRACE.checksum"')
def assert_target(self, target):
self.allow_fixture_checksum()
result = self.run_bootstrap()
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(
Path(str(self.trace) + ".url").read_text().strip(),
f"https://github.com/anomalyco/opencode/releases/download/v1.17.8/opencode-{target}.tar.gz",
)
self.assertEqual(self.trace.read_text().splitlines(), ["download", "extract", "install"])
self.assertEqual(
Path(str(self.trace) + ".args").read_text().splitlines()[-1],
str(self.root / "home/.opencode/bin/opencode"),
)
def test_corrupt_archive_stops_before_extraction(self):
result = self.run_bootstrap()
self.assertNotEqual(result.returncode, 0)
self.assertIn("sha256sum", result.stderr)
self.assertEqual(self.trace.read_text().splitlines(), ["download"])
self.assertFalse((self.root / "home").exists())
def test_failed_download_stops_before_extraction(self):
self.stub("curl", "exit 22")
result = self.run_bootstrap()
self.assertNotEqual(result.returncode, 0)
self.assertFalse(self.trace.exists())
self.assertEqual(list(self.root.iterdir()), [self.bin])
def test_x64_without_avx2_keeps_baseline_binary(self):
self.env["PROBE_AVX2"] = "0"
self.assert_target("linux-x64-baseline")
def test_x64_with_avx2_keeps_standard_binary(self):
self.assert_target("linux-x64")
def test_arm64_keeps_arm64_binary(self):
self.env["PROBE_ARCH"] = "aarch64"
self.assert_target("linux-arm64")
def test_unsupported_version_stops_before_download(self):
result = self.run_bootstrap("unreviewed-version")
self.assertNotEqual(result.returncode, 0)
self.assertIn("Unsupported", result.stderr)
self.assertFalse(self.trace.exists())
def test_unsupported_architecture_stops_before_download(self):
self.env["PROBE_ARCH"] = "unknown-fixture"
result = self.run_bootstrap()
self.assertNotEqual(result.returncode, 0)
self.assertIn("Unsupported", result.stderr)
self.assertFalse(self.trace.exists())
def test_symlink_archive_member_is_not_installed(self):
self.allow_fixture_checksum()
self.env["PROBE_SYMLINK"] = "1"
result = self.run_bootstrap()
self.assertNotEqual(result.returncode, 0)
self.assertEqual(self.trace.read_text().splitlines(), ["download", "extract"])
self.assertFalse((self.root / "home").exists())
if __name__ == "__main__":
unittest.main()
+143
View File
@@ -0,0 +1,143 @@
"""Offline shell bootstrap checks; no vendor installer or network is executed."""
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
@unittest.skipUnless(os.name == "posix", "Docker bootstrap runs on Linux")
class RustupBootstrapTests(unittest.TestCase):
def setUp(self):
self.fixture = tempfile.TemporaryDirectory(prefix="headroom-rustup-test-")
self.addCleanup(self.fixture.cleanup)
self.root = Path(self.fixture.name)
self.bin = self.root / "bin"
self.bin.mkdir()
self.trace = self.root / "trace"
self.env = dict(
os.environ,
PATH=f"{self.bin}:{os.environ['PATH']}",
TMPDIR=str(self.root),
PROBE_TRACE=str(self.trace),
PROBE_ARCH="amd64",
PROBE_KERNEL="x86_64",
PROBE_NEON="neon",
PROBE_ARGS=str(self.root / "args"),
PROBE_INSTALL_NAME=str(self.root / "installer-name"),
)
self.stub("dpkg", 'printf "%s\\n" "$PROBE_ARCH"\n[ -n "$PROBE_ARCH" ]')
self.stub("uname", 'printf "%s\\n" "$PROBE_KERNEL"')
self.stub(
"grep",
'case "$*" in *"/proc/cpuinfo"*) printf "Features : %s\\n" "$PROBE_NEON";; '
'*) exec /bin/grep "$@";; esac',
)
self.stub(
"curl",
"""printf 'download\\n' >> "$PROBE_TRACE"
out=''
while [ "$#" -gt 0 ]; do
case "$1" in
--output) out="$2"; shift 2;;
https://*) printf '%s\\n' "$1" > "$PROBE_TRACE.url"; shift;;
*) shift;;
esac
done
cat > "$out" <<'INSTALLER'
#!/bin/sh
printf '%s' "${0##*/}" > "$PROBE_INSTALL_NAME"
printf 'executed\\n' >> "$PROBE_TRACE"
printf '%s\\n' "$@" > "$PROBE_ARGS"
INSTALLER
""",
)
self.script = Path(__file__).resolve().parents[2] / "scripts/install-rustup.sh"
def stub(self, name, body):
path = self.bin / name
path.write_text("#!/bin/sh\nset -eu\n" + body + "\n")
path.chmod(0o755)
def run_bootstrap(self, *args):
self.assertTrue(self.script.is_file(), "checksum bootstrap helper is required")
return subprocess.run(
["sh", str(self.script), *args], env=self.env, text=True, capture_output=True
)
def allow_fixture_checksum(self):
# Platform/argument tests execute our inert fixture, never vendor bytes.
self.stub("sha256sum", 'cat > "$PROBE_TRACE.checksum"')
def assert_target(self, expected):
self.allow_fixture_checksum()
result = self.run_bootstrap("-y", "--default-toolchain", "1.95.0")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(
Path(str(self.trace) + ".url").read_text().strip(),
f"https://static.rust-lang.org/rustup/archive/1.29.3/{expected}/rustup-init",
)
self.assertEqual(self.trace.read_text().splitlines(), ["download", "executed"])
def test_bad_archive_is_rejected_before_execution(self):
result = self.run_bootstrap("-y")
self.assertNotEqual(result.returncode, 0)
self.assertIn("sha256sum", result.stderr)
self.assertEqual(self.trace.read_text().splitlines(), ["download"])
self.assertEqual(sorted(p.name for p in self.root.iterdir()), ["bin", "trace", "trace.url"])
def test_failed_download_never_executes_installer(self):
self.stub("curl", "exit 22")
result = self.run_bootstrap("-y")
self.assertNotEqual(result.returncode, 0)
self.assertFalse(self.trace.exists())
self.assertEqual(list(self.root.iterdir()), [self.bin])
def test_userland_architecture_wins_over_64_bit_kernel(self):
self.env["PROBE_ARCH"] = "i386"
self.assert_target("i686-unknown-linux-gnu")
def test_arm_without_neon_uses_supported_fallback(self):
self.env.update(PROBE_ARCH="armhf", PROBE_NEON="")
self.assert_target("arm-unknown-linux-gnueabihf")
def test_manylinux_without_dpkg_uses_kernel_architecture(self):
self.env["PROBE_ARCH"] = ""
self.assert_target("x86_64-unknown-linux-gnu")
def test_unknown_architecture_stops_before_download(self):
self.env["PROBE_ARCH"] = "unknown-fixture"
result = self.run_bootstrap("-y")
self.assertNotEqual(result.returncode, 0)
self.assertIn("Unsupported", result.stderr)
self.assertFalse(self.trace.exists())
def test_toolchain_options_are_forwarded_verbatim(self):
self.allow_fixture_checksum()
args = [
"-y",
"--no-modify-path",
"--profile",
"minimal",
"-c",
"rustfmt",
"-c",
"clippy",
"--default-toolchain",
"1.95.0",
]
result = self.run_bootstrap(*args)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(Path(self.env["PROBE_ARGS"]).read_text().splitlines(), args)
def test_binary_keeps_rustup_init_dispatch_name(self):
# rustup-init selects installer/proxy mode from argv[0], before options.
self.allow_fixture_checksum()
result = self.run_bootstrap("-y")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(Path(self.env["PROBE_INSTALL_NAME"]).read_text(), "rustup-init")
if __name__ == "__main__":
unittest.main()
+36
View File
@@ -0,0 +1,36 @@
"""Keep local Docker action metadata and its CI coverage valid."""
import re
from pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parents[1]
def test_local_action_edits_trigger_code_and_workflow_checks() -> None:
workflow = yaml.safe_load((ROOT / ".github/workflows/ci.yml").read_text())
filters = yaml.safe_load(workflow["jobs"]["changes"]["steps"][1]["with"]["filters"])
for group in ("code", "workflows"):
assert ".github/actions/**" in filters[group], group
def test_vendored_commitlint_action_metadata() -> None:
actions = [ROOT / ".github/actions/commitlint/action.yml"]
for path in actions:
action = yaml.safe_load(path.read_text())
assert isinstance(action, dict), path
for key in ("name", "description"):
assert isinstance(action.get(key), str) and action[key].strip(), (path, key)
runs = action["runs"]
assert runs["using"] == "docker", path
assert re.fullmatch(r"docker://[^\s@]+@sha256:[0-9a-f]{64}", runs["image"]), path
for name, definition in action.get("inputs", {}).items():
assert re.fullmatch(r"[A-Za-z_][A-Za-z0-9_-]*", name), path
assert isinstance(definition["description"], str), (path, name)
if "default" in definition:
assert isinstance(definition["default"], str), (path, name)
if "required" in definition:
assert isinstance(definition["required"], bool), (path, name)
for name, definition in action.get("outputs", {}).items():
assert isinstance(definition["description"], str), (path, name)