Skip to content

Contributing

Where Barn’s code lives, the checks a change must pass, how to edit these docs, and how releases and the image catalog are maintained.

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 changeWhere to work
CLI behavior, VM lifecycle, native macOS component (Barn.app), installer, and packagespgsty/barn
Documentation site, guides, command reference, and translationspgsty/barn.pgsty.com
Official Linux image definitions or offline normalization rulespackaging/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-helper or the reviewed network plan, nowhere else.
  • barn mac stays separate: it never reads the Linux inventory and runs entirely as the invoking user.

Find the implementation

SubsystemSource paths
CLI commands, flags, JSON/YAML output, and error renderingcmd/barn/, internal/failure/
Inventory parsing, defaults, and resolved node specsinternal/config/, internal/spec/
Linux lifecycle: convergence, journals, disks, and SSH readinessinternal/linuxvm/ (internal/private/ in v1.3.0 and earlier), internal/vm/, internal/cloudinit/, internal/state/
Host platform and QEMU argumentsinternal/platform/, internal/qemu/
Host preparation, networking, process identity, and /etc/hostsinternal/setup/, internal/network/, internal/process/, internal/hostconfig/, cmd/barn-hosts-helper/
Deployment SSH keys and the ~/.ssh/config integrationinternal/sshkeys/, internal/sshconfig/
Guest clock checks and scheduled syncinternal/timesync/, internal/timejob/
Image catalog trust, qcow2 verification, and catalog toolsinternal/image/, tools/catalogcheck/, tools/catalogexport/, tools/catalogsign/
Native macOS VMs and the desktop appinternal/macvm/, native/mac-runner/
Packaging, image pipeline, CI workflows, and integration testspackaging/, .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:

go install honnef.co/go/tools/cmd/staticcheck@v0.8.2
go install golang.org/x/tools/cmd/deadcode@v0.53.0
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0
go install golang.org/x/vuln/cmd/govulncheck@v1.10.0

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.

TargetWhat it doesRun it
make buildBuilds bin/barn and its matching bin/barn-hosts-helper for this hostWhile iterating (details)
make testgo test ./...While iterating
make racego test -race ./...For concurrency changes
make checkEverything CI runs (below)Before every pull request; it must pass
make mac-native-testC and Swift tests for the native runner; needs Apple Silicon, macOS 27+, and Xcode 27+For native Mac changes
make release-snapshotBuilds and verifies a complete snapshot release without uploading anythingFor 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:

make release-snapshot SNAPSHOT_DIST=.goreleaser-review

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.

ContentLocation
Task guidesversions/manuals/1.5/docs/start/ for 1.5-specific changes
Command and configuration referenceversions/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 statuscontent/blog/design/
Release notescontent/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:

make check

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.gz archives for darwin and linux on amd64 and arm64, each with bin/barn, bin/barn-hosts-helper, and licenses/. Since 0.9.2 the Darwin arm64 archive also carries bin/Barn.app, with the CLI, helper, and app signed with Developer ID and notarized.
  • Linux .deb and .rpm packages that install /usr/bin/barn and /opt/barn/libexec/barn-hosts-helper.
  • checksums.txt, its detached checksums.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:

  1. Move the Unreleased entries in CHANGELOG.md into a dated section, update the README installation links, and add an English release note without a top-level heading at .github/releases/<version>.md.
  2. Pass the catalog gate with make catalog-check, synchronizing the embedded catalog first if it changed (below).
  3. Require source CI to pass on the release commit, and a packaging snapshot to pass on the latest packaging changes.
  4. 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.
  5. Run live Linux VM acceptance, plus Mac acceptance when shipping Barn.app.
  6. 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
  7. 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:

  1. Verify the new signed catalog, then copy it to internal/image/default-catalog.json.

  2. Update EmbeddedManifestVersion in internal/image/catalog.go and the embedded catalog date in internal/image/manifest.go; update packaging/image-repository/repo.yaml if the repository sources changed.

  3. Run the catalog tests (go test ./internal/image/...), and barn update with a fresh temporary BARN_HOME to confirm the remote catalog verifies and activates.

  4. Run the online gate:

    make catalog-check
    go run ./tools/catalogcheck -verify-bytes

    make catalog-check activates 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-bytes also downloads and hashes every stable image (several GB, nothing kept). Formal native builds and both release paths run catalog-check automatically; never bypass it to ship references to removed images.

Client-side verification and the repository format are in Linux Images.

Table reader