Contributing to BuildWarden
Thank you for your interest in contributing! This guide covers setup, building,
testing, and how a change gets merged. The standards a change is held to live in
docs/development/,
and the process for designing, reviewing and merging a feature is
process.md.
Setup
All platforms:
- Go at the version in
go.mod(we manage it with mise; runmise exec -- go ...if yourGOROOTis misconfigured) - golangci-lint v2
- A container runtime: finch, podman, or docker
- git 2.40 or later where the feature loop's
wfruns: its merge check proves a squash merge withgit merge-tree --merge-base, and with an older git it leaves the branch unconfirmed and says why
VZ driver (macOS 13+ on Apple Silicon):
- Xcode Command Line Tools, for cgo and Objective-C
- The host binary needs the virtualization entitlement.
make buildsigns it ad hoc; to sign by hand:codesign --sign - --entitlements entitlements.plist dist/warden
QEMU driver (any platform):
qemu-system-aarch64orqemu-system-x86_64, plusqemu-img(brew install qemuon macOS,apt install qemu-systemon Linux)
Hyper-V driver (Windows):
- Hyper-V and its management stack enabled
- Membership in Hyper-V Administrators, or an elevated terminal
- One-time network setup from an elevated terminal:
warden setup --driver hyperv
Firecracker driver (x86_64 Linux with KVM):
/dev/kvm, your user in thekvmgroup, andfirecrackerv1.17.0 or later onPATHiproute2,nftables,iptables,qemu-imgandgenisoimage(ormkisofs); the guest kernel build needsmake,gcc,flex,bison,bc,libelf-devandlibssl-dev- Boot assets and network slots, re-created after each host boot: installation.md
Building and testing
make build # Compile all binaries to dist/
make test # Unit tests: run on every platform, no external dependencies
make release-build # Compile what a release compiles: each target, without cgo
make lint # golangci-lint, then the tier-1 checks on your diff
make fmt # gofmt -s -w
make tidy # go mod tidy
make cover # Tests with a coverage report
make deadcode # Code unreachable on Linux, macOS and Windows
make integration-test # Real builds plus ledger checks; needs a container runtime
make driver-conformance # The driver suite's both tiers against DRIVER (default:
# dist/warden-driver-container, .exe on Windows); the lifecycle tier runs
# real builds; DRIVER_CONFORMANCE_FLAGS for the host;
# a case still running after the slowest case's
# worst path (3 h) fails as hung and ends the tier;
# --case-deadline <duration> changes it
make integration-test-vz # VZ end to end; needs macOS/arm64 and a prepared image
make clean # Remove built binaries
make build cross-compiles the relay and warden-io for linux/amd64 and
linux/arm64; on macOS/arm64 it also builds warden-io for darwin/arm64 and signs
the host binary. Run a development warden from its tree as dist/warden: it
finds its source only from where its executable is, never from the working
directory, so go run ./cmd/warden or a copy elsewhere stops at the first
thing it would build from source. Platform-specific code has build-tagged
stubs, so make test passes everywhere. The test tiers and what each one
needs are in
testing.md.
The warden-io keytool comparison skips where no JDK's keytool runs; CI's
keytool job installs Java and runs it on Linux, macOS and Windows.
Tier-1 checks
make lint ends by building dist/tier1 from tools/tier1/ and running it
over the diff from origin/main to HEAD (committed changes only). These are
the deterministic checks of the behavioral linter (LINT-02): the coupling
checks (a design in the diff, its drivers claim, the bootstrap surface, the
ledger schemas and their spec, the CLI and config surface and its guide
pages), go/analysis passes for the relay and the executor, and a
golangci-lint config limited to the lines you changed.
- The base is the merge base of
TIER1_BASE(defaultorigin/main) andHEAD. If it cannot be resolved, tier 1 exits 2 and prints the fix, usuallygit fetch origin main. It never falls back to checking the whole repository. Usemake tier1 TIER1_BASE=v0.5.0to check everything since a release. - Other platforms. The analyzers load packages for the host
GOOS. If you changed build-tagged files for another platform, also runGOOS=<os> make lint. - No design. A change that needs no design (FLOW-01) passes
TIER1_FLAGS=-no-design; in CI theno-designlabel does the same. A push, and a program sync's PR, are not judged on it (FLOW-01). - Design front-matter. Every
docs/design/*.mdthe change adds, modifies or renames must have front-matter that passes the same FLOW-02 validatorwfuses, with the file name (without.md) as thefeature. An existing design that never had front-matter predates FLOW-02 and is listed as a hint rather than failed (FLOW-12); a new design without front-matter fails.dist/tier1 designsprints the verdict for each touched design, anddist/tier1 designs -allfor every design. Archived designs kept as merged although they lack a later key are listed underdesign_tolerateintools/tier1/rules.yaml, and their tolerated problems are reported without failing. - Suppressing a finding. Add a trailer to any commit in the change:
Tier1-Allow: <RULE-ID> <path-glob>: <reason>, for exampleTier1-Allow: UX-01 cmd/warden/*: guide pages follow in #123. The reason is required. Every applied suppression is printed in its own section, so the review and the sign-off see it (LINT-05).*matches within one path element,**across elements, and a glob ending in/matches a whole directory. The trailer must reach the trunk, because tier 1 reads it from the commits in the range it judges: a merge commit keeps it, a squash merge keeps it only if the line is in the squash message, and a lost one failsmain'scion every push until a commit carrying it again lands (LINT-04). - Exit codes. 0 means clean, or only SHOULD findings and hints. 1 means an unsuppressed MUST or MUST-review finding. 2 means a usage or environment error, such as an unresolvable base or a missing golangci-lint. Hints never fail; they are signals for the tier-2 review, such as a package whose code changed with no test change (GLOBAL-04).
- Output.
dist/tier1 -jsonprints the report in the formtools/tier1/report.schema.jsondeclares, keyed by rule andfile:line. - Whole-tree audit.
dist/tier1 -allalso runs the checks of invariants that hold over the whole tree, today thespecs/layout (RELAY-05), even when the diff does not touch them. - The rule index.
dist/tier1 rules [-json]prints every rule parsed fromdocs/development/.tools/tier1/rules.yamlmaps eachautomated-tagged rule to a tier-1 check, an outside owner orfollow-up, and tier 1 fails a change to the standards that leaves a rule unmapped.
Local builds report version = "dev", which builds the relay from source. After
changing the relay or orchestrator, a quick end-to-end check is:
./warden build . # self-build: COPY provenance, Go modules, artifacts
./warden build examples/Dockerfile.simple # pip and Debian packages
./warden inspect warden-output # check the ledger
./warden clean # if a build crashed or was interrupted
Seam specifications and conformance
The specifications of the component seams (the claim, the collector, the
relay's guest API, the executor's initialize and the bootstrap config) live in
buildwarden/buildwarden-specs.
This repository pins one version of each in a Go module of its own,
tools/conformance/<directory>/go.mod, which the root module does not require;
Component seams shows each pin and links each
specification at it.
make conformance # Every pinned suite against every target this OS can run
make conformance TARGETS="relay-host collector-disk" # Exactly those targets
make conformance SUITES="relay-claim" # Exactly those specifications' suites
make conformance SPECS_DIR=../buildwarden-specs # Suites from a specs checkout, not the pins
OCI_RUNTIME=podman make conformance # relay-oci with podman in place of docker
make pin-specs SPECS="relay-claim@v0.2.0" # Move named pins to those releases
make pin-specs SPECS=latest # Move all six pins to their newest releases
make pin-specs REF=<commit> # Pin all six at one commit, on a branch only
make conformanceruns the seam specifications' suites against the relay and the disk collector built from this checkout. It builds each pinned specification's command,bw-conformance-<directory>, from its own module withGOWORK=off, so each runs with the harness its own release names, and builds what the targets run intodist/conformance/:relay,collectorand, forrelay-oci, the imagebuildwarden-relay:conformancefromDockerfile.relay. A target is a file intools/conformance/targets/(relay-host,relay-vm,relay-container,relay-oci,collector-disk) that declares the operating systems it runs on. WithTARGETSunset it runs every target that declares this host's, and prints a line for each one it leaves out; a target named inTARGETSthat cannot run here is an error. The relay targets run in the harness's sandbox, which needs Linux and root or unprivileged user namespaces;relay-ocineeds root and the runtime its file names, with the image built from this checkout. It prints one table per target, a row for each specification with its version, its harness's and its counts, and keeps each report indist/conformance/reports/. A failed case is not retried.SPECS_DIRruns the suites from a local checkout of the specifications instead, and says so. Theconformanceworkflow runs it on pull requests and on pushes to branches other thanmainthat change a path on its list, weekly and on demand: the relay targets as root on Linux,collector-diskon Linux, macOS and Windows.make pin-specsis the only way a pin moves. It takesSPECSorREF, never both and never neither. It writes each module it moves from nothing, builds every command in a scratch directory first, and only then moves the files into place and rewrites the refs on the seams page, so a failure changes nothing. Never move a pin withgo get: it keeps the old pin's harness version.mainpins releases only; the workflow'spinjob fails a pull request whose pins name a commit or carry areplaceline. A pull request to a program trunk (program/componentization, FLOW-20) may also pin a pre-release,vX.Y.Z-dev.Nor-rc.N, named inSPECS;SPECS=newestpins each specification at its highest version, pre-releases included, and is refused onmain.
Pull requests
- Fork the repo and branch from
main. - Changes that make design decisions start with a design document in
docs/design/, written fromTEMPLATE.md(FLOW-01). Dependency bumps, typo fixes and CI-only changes are labelledno-designinstead. - Run
make lint && make testbefore pushing. Keep commits focused: one logical change per commit. - Open a PR against
main. On a PR that changes code, CI runs lint, tests and cross-platform builds. A PR that changes onlydocs/(outsidedocs/development/) or top-level Markdown files runs tier 1, the FLOW-18 check and, when it touchesdocs/book/, an mdBook build. Theci-okcheck sums up the run. A maintainer signs off before merging (FLOW-08).
Cutting a release
- Make sure
make testpasses onmain. The release workflow runs tier 1 against the previousv*tag without a suffix and checks every design's front-matter (tier1 designs -all) before it publishes; every push tomainor a program trunk runs the same tier 1 and design check (CI'stier1job, LINT-04), so a green head has already passed it. Runmake tier1 TIER1_BASE=<previous tag>first to see what it will report. The full release gate (tier-1 checks, the test matrix, the security suite and the behavioral report) is described inbehavioral-linter.mdand is being built out. Runmake release-buildtoo: it compiles each program a release builds, for each release target, without cgo, as GoReleaser does (CI'sbuildjob runs it on every PR that changes code). A released macOS arm64wardentherefore has no vz driver, and says so. - Tag the commit and push the tag:
git tag v0.x.y && git push origin v0.x.y. - GoReleaser, run by GitHub Actions, builds and publishes the binaries.
A release without a suffix is cut from main by a maintainer, as above.
While the componentization program runs (FLOW-20), the loop also tags
pre-releases on a program trunk, vX.Y.Z-dev.N after a merge that changes
what the repository releases and -rc.N once a component's last phase has
merged, where X.Y.Z is the next minor after the latest release without a
suffix (v0.1.0 when there is none). Each publishes as a GitHub
pre-release that never becomes Latest and never moves the relay image's
latest, and is never moved or deleted (wf tag-next names the next one,
and wf tag-next -rc -feature <last phase> the next -rc.N).
Security
Report security issues as described in
SECURITY.md.
Do not open a public GitHub issue for them.
License
See the LICENSE file for details.