Contributing
7 minute read
Start here to change Barn: find the code, run the checks a pull request must pass, and edit these docs. The last two sections are for maintainers cutting a release or refreshing the image catalog. Barn is Apache-2.0; for a large change, open an issue first to agree on the design.
Choose a repository
| What you want to change | Where to work |
|---|---|
CLI behavior, VM lifecycle, native macOS component (Barn.app), installer, and packages | pgsty/barn |
| Documentation site, guides, command reference, and translations | pgsty/barn.pgsty.com |
| Official Linux image definitions or offline normalization rules | packaging/image-repository/ and packaging/image-pipeline/ in pgsty/barn |
A useful bug report has barn version, the host OS and architecture, the exact command, and the error output with private keys and passwords removed. Report security problems privately. Coding style, error-message rules, and commit conventions are in CONTRIBUTING.md.
Keep the product model
Barn keeps a deliberately small product model, and changes should preserve it:
- One Linux deployment per
BARN_HOME: no projects, leases, or workspaces (scope, rationale). - One inventory format: a Pigsty-compatible Ansible inventory; an unknown
vm_*key is an error. - Absence never destroys: removing a host from the inventory does not delete its VM; destruction is always an explicit command.
- One privileged path: root work goes through
barn-hosts-helperor the reviewed network plan, nowhere else. barn macstays separate: it never reads the Linux inventory and runs entirely as the invoking user.
Find the implementation
| Subsystem | Source paths |
|---|---|
| CLI commands, flags, JSON/YAML output, and error rendering | cmd/barn/, internal/failure/ |
| Inventory parsing, defaults, and resolved node specs | internal/config/, internal/spec/ |
| Linux lifecycle: convergence, journals, disks, and SSH readiness | internal/linuxvm/ (internal/private/ in v1.3.0 and earlier), internal/vm/, internal/cloudinit/, internal/state/ |
| Host platform and QEMU arguments | internal/platform/, internal/qemu/ |
Host preparation, networking, process identity, and /etc/hosts | internal/setup/, internal/network/, internal/process/, internal/hostconfig/, cmd/barn-hosts-helper/ |
Deployment SSH keys and the ~/.ssh/config integration | internal/sshkeys/, internal/sshconfig/ |
| Guest clock checks and scheduled sync | internal/timesync/, internal/timejob/ |
Image catalog trust, qcow2 verification, and catalog tools | internal/image/, tools/catalogcheck/, tools/catalogexport/, tools/catalogsign/ |
| Native macOS VMs and the desktop app | internal/macvm/, native/mac-runner/ |
| Packaging, image pipeline, CI workflows, and integration tests | packaging/, .github/workflows/, tests/ |
Read each package’s tests alongside the code: they pin down which failures Barn recovers from automatically and which ones must stop safely.
Build and test
Install Go 1.27.4 and the linters pinned in packaging/toolchain.env; CI asserts these exact versions:
Put GOBIN (or $(go env GOPATH)/bin) on your PATH. make check also needs Python 3, jq, and a C compiler for the race detector.
| Target | What it does | Run it |
|---|---|---|
make build | Builds bin/barn and its matching bin/barn-hosts-helper for this host | While iterating (details) |
make test | go test ./... | While iterating |
make race | go test -race ./... | For concurrency changes |
make check | Everything CI runs (below) | Before every pull request; it must pass |
make mac-native-test | C and Swift tests for the native runner; needs Apple Silicon, macOS 27+, and Xcode 27+ | For native Mac changes |
make release-snapshot | Builds and verifies a complete snapshot release without uploading anything | For changes under tools/, packaging/, .goreleaser.yaml, or the Makefile |
make check runs module verification (go mod verify, go mod tidy -diff), shell syntax checks, the maintenance-ownership check, unit and race tests, go vet, Staticcheck, the four-target deadcode intersection, errcheck through golangci-lint, govulncheck, cross-compilation for darwin/arm64, darwin/amd64, linux/amd64, and linux/arm64, the image-pipeline and installer tests (including tests/mac-release-test.py), and the dependency-license check. The maintenance check fails when a new file under tools/ or packaging/ is not referenced by a Make target, a workflow, or CONTRIBUTING.md.
Changes to virtualization, networking, or disk behavior also need a live run on the target host (Linux KVM, macOS HVF, or Virtualization.framework for barn mac); name the host in the pull request.
Packaging changes also run the packaging workflow. To reproduce it locally, install GoReleaser, nFPM, and Syft at the versions in packaging/toolchain.env, then run:
release-snapshot first runs make release-check (toolchain versions and goreleaser check), then builds and verifies archives, .deb/.rpm packages, SBOMs, and checksums. SNAPSHOT_DIST (default .goreleaser-snapshot) must name one new directory directly under the repository root. To include the native Mac payload, see Mac Release.
Edit the documentation
The site is Hugo with the OINK theme, in pgsty/barn.pgsty.com; the source repository keeps no docs/ directory.
| Content | Location |
|---|---|
| Task guides | versions/manuals/1.5/docs/start/ for 1.5-specific changes |
| Command and configuration reference | versions/manuals/1.5/docs/reference/ for 1.5-specific changes |
| Project pages (this section) | versions/manuals/1.5/docs/about/ for 1.5-specific changes |
| Design decisions and research, with date and implementation status | content/blog/design/ |
| Release notes | content/release/ |
Every page is an English/Chinese pair, page.md and page.zh.md, with the same front matter routing fields and the same explicit {#id} on every heading, which OINK’s Duo View uses to align the two languages. Follow STYLE_GUIDE.md. Check CLI examples against barn <command> --help, and inventory examples with barn validate and barn plan under a temporary BARN_HOME.
Validate the site before committing:
The check verifies Go modules and builds both editions with the pinned OINK theme. It checks internal links, anchors, assets and search indexes before replacing public/. Use make dev to live-edit the 1.5 manual with a sibling ../oink checkout, or make preview to browse both editions with the pinned theme.
Release outputs and gates
Each release publishes:
.tar.gzarchives fordarwinandlinuxonamd64andarm64, each withbin/barn,bin/barn-hosts-helper, andlicenses/. Since 0.9.2 the Darwin arm64 archive also carriesbin/Barn.app, with the CLI, helper, and app signed with Developer ID and notarized.- Linux
.deband.rpmpackages that install/usr/bin/barnand/opt/barn/libexec/barn-hosts-helper. checksums.txt, its detachedchecksums.txt.sig,release.json, SPDX SBOMs, the Homebrew formula, and the installer.
Stable versions from 1.0.0 on become GitHub’s latest release. Versions below 1.0.0 and versions with a prerelease suffix are GitHub pre-releases, and the installer needs an explicit BARN_VERSION for them.
Cut a release in this order:
- Move the
Unreleasedentries inCHANGELOG.mdinto a dated section, update the README installation links, and add an English release note without a top-level heading at.github/releases/<version>.md. - Pass the catalog gate with
make catalog-check, synchronizing the embedded catalog first if it changed (below). - Require source CI to pass on the release commit, and a packaging snapshot to pass on the latest packaging changes.
- Build the assets from the tag: push
v<version>to run the tag workflow, which needs all six Apple signing secrets, or use the local release path. Both verify archives, packages, SBOMs, checksums, and CLI/helper pairing before creating a draft release. - Run live Linux VM acceptance, plus Mac acceptance when shipping
Barn.app. - Sign the draft checksum manifest, upload the final metadata and signature, and run
make release-publish RELEASE_TAG=v<version>. Update Homebrew and the bilingual site after publication. Signing procedure - Verify anonymous downloads, the installer, and the Homebrew upgrade against the published bytes.
Maintain the image catalog
The catalog embedded in barn and the one published on the mirrors must be byte-identical at every revision; Barn rejects two different catalogs with the same revision as signed equivocation. Never republish a revision with different bytes.
Build and normalize candidate qcow2 images with the Image Pipeline (packaging/image-pipeline/build-official.py --list shows the ten-image matrix). The pipeline produces an unsigned candidate repository for barn repo build and barn repo verify; it never edits repo.yaml, signs, or publishes, so promotion stays a separate step. Promote an image only after native startup and SSH checks on each changed architecture.
Sign the same catalog.json bytes twice. Barn 1.5.0 verifies the ML-DSA-87 .sig sidecar. Barn 1.4.0 verifies .minisig with the existing Minisign key. Maintainer commands and key fingerprints
When the published catalog changes, bring the source in line before the next release:
Verify the new signed catalog, then copy it to
internal/image/default-catalog.json.Update
EmbeddedManifestVersionininternal/image/catalog.goand the embedded catalog date ininternal/image/manifest.go; updatepackaging/image-repository/repo.yamlif the repository sources changed.Run the catalog tests (
go test ./internal/image/...), andbarn updatewith a fresh temporaryBARN_HOMEto confirm the remote catalog verifies and activates.Run the online gate:
make catalog-checkactivates each official mirror’s signed catalog in a fresh temporary data root, requires exact byte agreement with the embedded catalog, and checks every stable artifact’s availability and size.-verify-bytesalso downloads and hashes every stable image (several GB, nothing kept). Formal native builds and both release paths runcatalog-checkautomatically; never bypass it to ship references to removed images.
Client-side verification and the repository format are in Linux Images.