mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
The signing design's first phase. The same tag, built by two builders, now gives byte-identical archives, source tarball, install.sh, SHA256SUMS and formulas. - scripts/release.sh builds every file but the signature in one container, release_image (Debian's buildpack-deps:trixie-scm, pinned by its index's digest), under podman or Docker (DEVVM_RELEASE_RUNTIME), on this machine's processor. The image and the code that runs in the build's container (_build) are the built commit's copies, so a tag builds the same from any checkout; a commit whose release.sh pins no release_image is refused. Everything outside the build's container is the checkout's: the tag's checks, the downloads, the modules' container, the checks on what the build wrote, and the signature. - The build has no network (--network none). The Go modules come first, in a container of their own, the only one with the network, which runs only the checkout's code: its release_image, its release.sh _modules and the Go its mise.lock pins, given only the commit's go.mod and go.sum, read-only, and downloading from proxy.golang.org alone (GOVCS=*:off, GOWORK=off). The checkout's Go rather than the commit's, so a commit can't pick an old Go with a known flaw for the step with the network, and rather than refusing a commit whose Go is older than the checkout's, which would refuse every old tag once mise.lock moves on, though rebuilding old tags is what --tag is for; go.sum pins the module files, so the bytes don't depend on which Go downloaded them. A commit whose go.mod needs a newer Go than the checkout's is refused before anything runs. Every module path the commit's go.mod names is looked up on Google's proxy and checksum database, which the docs say. The build reads the modules read-only as a GOPROXY's files (file:///mod). - Every container runs with --cap-drop ALL, --security-opt no-new-privileges, --pids-limit 8192, --memory 8g and --entrypoint bash, so a setuid file in the commit's image gives no privileges under a rootful runtime, root in it can't chown, a fork bomb or a runaway allocation stops at the container's limits, and the image's entrypoint never runs; Go and GoReleaser are unpacked with tar --no-same-owner. Both runtimes take both limits; rootless podman applies them on cgroups v2 with the pids and memory controllers delegated, as systemd does, and CI's runner needs the same. A full build peaked at 330 processes and 1.8 GiB under Docker Desktop on 10 CPUs. Neither runtime can bound a bind mount's disk use, so the docs say that a running build can fill the temp folder's disk until the time limit. - Each container is named for its run (devvm-release-<the temp folder's suffix>-<n>), so no other run's container, even one left over, has the name, and it's removed (rm -f, then its client ended, then rm -f again): after two hours (DEVVM_RELEASE_TIMEOUT seconds) by a watchdog, and as soon as release.sh stops early. The client runs in the background, so Ctrl+C (INT), a closed terminal (HUP) and kill (TERM) run release.sh's traps at once, which exit through the EXIT trap that removes the container; in the foreground, bash would wait for the client, and the client for the container's PID 1, bash, which ignores them. After kill -9, the watchdog, which outlives release.sh and ignores INT and HUP, removes the container and the temp folder. - Go and GoReleaser are the built commit's mise.lock downloads for linux-arm64 or linux-x64, kept in ~/.cache/devvm-release by SHA-256 and checked before each use, as is the modules' Go from the checkout's mise.lock. A URL has to start with https://dl.google.com/go/ or GoReleaser's releases/download/, can't hold .. or %, which curl decodes (so %2e%2e can't be ..), and goes to curl as --url's value (a lock URL of -K<file> was curl options, run on the host); file:// only from the folder that DEVVM_RELEASE_TEST_FILE_URLS names, which only the tests set, and only when it exists and isn't /. curl: HTTPS redirects only, 30 s to connect, 15 minutes, 1 GiB. A lock with two entries for a tool, or two downloads for the platform, is refused. - The build's repository is new (git init --template=), holding only the commit and, for a tag, the tag, fetched into a pack: no other branches, tags or objects of the maintainer's, no hardlinked files the container could write, and origin set to devvm's GitHub URL, which GoReleaser needs and nothing fetches. Go stamps the binary from the tags it finds, so it finds only the release's. - The container runs as root under a rootless runtime and as you under a rootful one, from the runtime's info (podman's Host.Security.Rootless, Docker's security options), never its name; a runtime that doesn't answer stops the build. Inside: umask 022, TZ=UTC, LC_ALL=C.UTF-8, GOTOOLCHAIN=local, -mod=readonly, no git config but safe.directory, and Go's caches in a container-local folder (Docker Desktop's share lost files that parallel module downloads renamed). - The build writes its files to /out, a mount of its own that it can't swap for a link. Before anything is copied, signed or kept, the folder has to be the one release.sh made, not a link, and everything in it a file or a folder, never a link, yours, and neither setuid, setgid, sticky nor world-writable, and 2 GiB at most, counted as read (sparse files whole) and read no further. The files are then copied to dist/, never moved, as yours with mode 0755 or 0644. minisign signs outside, after the containers are gone. - release.sh --commit COMMIT builds any commit as --head does, with its VERSION; release.sh --tag TAG builds a tag as its release, with its checks, unsigned, to compare with a published SHA256SUMS. An unsigned build never replaces a dist/ that holds SHA256SUMS.minisig, and a build signed with a test key never replaces one whose SHA256SUMS verifies with the checkout's packaging/minisign.pub, the release key. - .goreleaser.yaml: builds_info and every file's info set owner and group root, mode 0755/0644 and the commit's time. - scripts/repro-check.sh [COMMIT | TAG] builds twice with the checkout's release.sh, so no commit's code runs on the host directly. Build 2 fetches from a repository with a stray tag, v0.0.0-stray, at the commit, and runs under Docker where build 1 runs under podman when both are installed (root against your user); every platform archive's files have to be root's with mode 0755 or 0644 (tar -tv). A build that leaves no release fails, whatever its exit status. CI's repro job runs it under the runner's podman and Docker, with a 45-minute limit. The docs say that building a commit runs its code, in a container only as isolated as the runtime keeps it, so an outside commit is built only with the maintainer's go-ahead, and that rebuilding an old tag needs proxy.golang.org to still serve its modules. - scripts/bump.sh release-image moves the container's digest, the SHA-256 of the index it fetched, after checking the index lists linux/amd64 and linux/arm64; TestBumpCoversPins finds the pin. - Tests: release_head.txtar, publish.txtar and the new repro_check.txtar run the scripts through podman and docker stubs and a mise.lock of file:// tarballs. New cases: -K, http://, another host, .. and a percent-encoded .. in a lock URL refused before curl runs, file:// refused without the switch, with it set to 1, to a folder that doesn't exist, to / and from another folder, curl's bounds, two go entries, the build's repository's tags, refs, objects, hardlinks and origin, a stray tag kept out, the image and build code taken from the commit, a commit with no release_image, each runtime's user (rootless and rootful podman and Docker, podman behind docker, no answer), both containers' run lines (security options, limits, entrypoint, --network none, mounts), each container's name its run's (the stub checks it against the run's temp folder), the modules' container getting only go.mod, go.sum, Go and the checkout's release.sh, in the checkout's image, with the checkout's Go, a go.mod newer than the checkout's Go refused before any container, and the build reading its modules; refused output: a link in it, the output folder swapped for a link, a mode 4755, 2755 or 0666 file, a mode 1755 or 0777 folder, a sparse file a byte over 2 GiB (a file of another user's needs root to test, which the test says); a mode 0600 file copied as 0644; a build past DEVVM_RELEASE_TIMEOUT removed by name; release.sh sent INT, HUP and TERM mid-build, ending within 10 s through its trap, and kill -9, each leaving no container, process or temp folder; an unsigned --head and --tag refused over a signed dist/, and a test-key build over a release-key one; --commit never running the commit's host code, --tag's unsigned build matching the signed SHA256SUMS, and repro-check catching a build that records its user, archives that aren't root's, and a release.sh that builds nothing; bump.txtar covers the platform check. Each fails with its fix taken out, which was checked for every fix of the third review: the name, the limits, the test-key refusal, %, the folder's existence and /, the size cap, setgid, sticky, the signal traps, the EXIT trap's removal, the watchdog's removal after kill -9, the client in the background (in the foreground, INT took 60 s), the checkout's Go and the Go version check. Proof, with a throwaway commit whose _build probes its container and leaves a mode 4755 copy of bash and a mode 0666 file in /out, built by this release.sh under Docker Desktop on an arm64 Mac, and under rootful Docker and rootless podman on x86_64 Fedora: every build ran with CapEff and CapBnd 0, NoNewPrivs 1 and no network, couldn't write /mod or rename /out, and was refused before anything was kept; rootful Docker refused its chown to root. The same image under the old run line, on Fedora's rootful Docker: CapBnd a80425fb, NoNewPrivs 0, and proxy.golang.org reachable. Real builds of this commit, stopped 20 s into the build's container: under Docker Desktop, INT, TERM and HUP ended release.sh within 3 s (exit 130, 143, 129) with no container left at once, and kill -9 left the container running for the watchdog, which had removed it and the temp folder 5 s later. The same on Fedora under rootless podman (INT, kill -9, TERM, HUP) and rootful Docker (INT, kill -9). Afterwards no devvm-release container or temp folder was left on either machine. repro-check on this commit, a prerelease (no devvm.rb), agreed on all eight files on the Mac (Docker Desktop, both builds) and on Fedora (rootless podman as root, then rootful Docker as cj), and the two machines' printouts were the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
174 lines
6.7 KiB
YAML
174 lines
6.7 KiB
YAML
name: CI
|
|
|
|
# Docs-only changes run only the Docs workflow's checks. Later patterns win:
|
|
# the CLI reference is generated, and a test checks it is current.
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- "**"
|
|
- "!docs/**"
|
|
- "!**.md"
|
|
- "docs/content/docs/cli/**"
|
|
pull_request:
|
|
paths:
|
|
- "**"
|
|
- "!docs/**"
|
|
- "!**.md"
|
|
- "docs/content/docs/cli/**"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
check:
|
|
# The tests run on macOS in UTC and on Linux in a zone with DST, so a
|
|
# test that depends on the zone fails here, not only on a laptop. Lint
|
|
# runs on both, because golangci-lint checks only the files built for
|
|
# the runner's OS, such as internal/platform's *_darwin.go or *_linux.go.
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- { os: ubuntu-latest, tz: America/Los_Angeles }
|
|
- { os: macos-latest, tz: UTC }
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
|
with:
|
|
version: 2026.11.14
|
|
# npm's downloads for the docs' diagrams (lint:docs runs docs:diagrams), keyed on the lock. npm ci
|
|
# checks each package against the lock's integrity, and the Docs workflow, which publishes, keeps
|
|
# no cache.
|
|
- name: Cache npm downloads
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
with:
|
|
path: ~/.npm
|
|
key: npm-${{ runner.os }}-${{ hashFiles('docs/package-lock.json') }}
|
|
- run: mise run lint
|
|
- run: mise run test
|
|
env:
|
|
TZ: ${{ matrix.tz }}
|
|
|
|
# Its own job, so a newly published vulnerability fails this check alone,
|
|
# and lint and test still report. The Vulnerabilities workflow scans main
|
|
# and the releases' binaries each week.
|
|
vuln:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
# Only Go and govulncheck, cached apart from the check jobs' full set.
|
|
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
|
with:
|
|
version: 2026.11.14
|
|
install_args: go go:golang.org/x/vuln/cmd/govulncheck
|
|
cache_key_prefix: mise-v1-vuln
|
|
# mise run would install the rest of mise.toml's tools first.
|
|
- run: mise run vuln
|
|
env:
|
|
MISE_TASK_RUN_AUTO_INSTALL: "false"
|
|
|
|
# A release builds to the same bytes twice: scripts/repro-check.sh builds
|
|
# the commit with scripts/release.sh in the release's pinned container,
|
|
# once under the runner's podman, as root, and once under its Docker, as
|
|
# the runner's user, from a repository with a stray tag, then compares
|
|
# every file and checks that every archive's files are root's. It needs
|
|
# no mise: the container gets Go and GoReleaser from mise.lock. The
|
|
# containers' process and memory limits need cgroups v2, with the pids
|
|
# and memory controllers delegated to the runner's user for podman.
|
|
repro:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- run: scripts/repro-check.sh
|
|
|
|
# Without cgo, as devvm ships. On Linux the proxy's child confines every
|
|
# thread of itself through syscall.AllThreadsSyscall, which a build with
|
|
# cgo, such as the race detector's in the check jobs, refuses: here a
|
|
# child of the confinement's own tests confines itself on the runner's
|
|
# kernel, Landlock and the seccomp filter, and is refused what it must
|
|
# be. (The CLI tests' devvm is built without cgo in the check jobs too.)
|
|
nocgo:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
# Only Go, cached apart from the check jobs' full set.
|
|
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
|
with:
|
|
version: 2026.11.14
|
|
install_args: go
|
|
cache_key_prefix: mise-v1-nocgo
|
|
- run: go test -count=1 ./internal/landlock/... ./internal/proxy/...
|
|
env:
|
|
CGO_ENABLED: "0"
|
|
|
|
# Advisory: nilaway's findings include false positives, so they never fail
|
|
# CI. A finding testdata/nilaway-baseline.txt hasn't triaged is a warning
|
|
# on the run, and the run's summary lists the new ones, then every
|
|
# finding. The job fails only when the check itself breaks (nilaway
|
|
# can't run, its output can't be read, a stale baseline line), and that
|
|
# blocks nothing either.
|
|
nilaway:
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
# Only Go and nilaway, cached apart from the other jobs' tools.
|
|
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
|
with:
|
|
version: 2026.11.14
|
|
install_args: go go:go.uber.org/nilaway/cmd/nilaway
|
|
cache_key_prefix: mise-v1-nilaway
|
|
# scripts/nilaway.sh exits 3 on a finding the baseline hasn't, and
|
|
# otherwise non-zero when nilaway couldn't run, its output couldn't be
|
|
# read or a baseline line is stale: the job fails then, after the
|
|
# summary.
|
|
- name: Run nilaway
|
|
env:
|
|
MISE_TASK_RUN_AUTO_INSTALL: "false"
|
|
run: |
|
|
set -uo pipefail
|
|
out=$RUNNER_TEMP/nilaway.txt
|
|
mise run nilaway 2>&1 | tee "$out"
|
|
status=${PIPESTATUS[0]}
|
|
n=$(grep -c '^new: ' "$out" || true)
|
|
{
|
|
echo "## nilaway: $n new findings"
|
|
echo
|
|
echo "A new finding needs triage: see [Nil checks](https://next.devvm.dev/docs/contributing/#nil-checks)."
|
|
echo
|
|
# Four backticks: nilaway's own backticks can't end the block.
|
|
echo '````'
|
|
grep -E '^(new|stale): |^nilaway: ' "$out" || echo "none"
|
|
echo '````'
|
|
echo
|
|
echo "Every finding, the triaged ones included:"
|
|
echo
|
|
echo '````'
|
|
cat "$out"
|
|
echo '````'
|
|
} >> "$GITHUB_STEP_SUMMARY"
|
|
if (( n > 0 )); then
|
|
echo "::warning title=nilaway::$n new possible nil dereferences: see the run's summary"
|
|
fi
|
|
if (( status != 0 && status != 3 )); then
|
|
echo "nilaway's check failed with status $status: see the run's summary" >&2
|
|
exit "$status"
|
|
fi
|