Pipelines
Caches and artifacts
Keep dependency caches between runs, and hand built files from one job to the jobs that need it.
Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its
.forge-ci.yamlor.xeonr-ci.yaml. See What is available.
# .branchd/pipelines/ci.yaml
# A cache keeps Go's module and build caches between runs; artifacts carry
# the built binary from the build job to the jobs that need it.
name: CI
on: [push, pull_request]
jobs:
build:
image: golang:1.26
cache:
- key: go-mod
files: [go.sum]
paths: [.cache/mod]
- key: go-build-${{ branch }}
fallback-keys: [go-build-main]
paths: [.cache/build]
steps:
# Steps share one shell, so these exports reach the next step.
- run: |
export GOMODCACHE="$PWD/.cache/mod"
export GOCACHE="$PWD/.cache/build"
- run: go build -o dist/server ./cmd/server
artifacts:
paths: [dist/server]
when: success
expire-in: 1 week
test-binary:
needs: [build]
image: debian:stable-slim
steps:
- run: ./dist/server --version
lint:
# Only the order: this job does not download build's files.
needs: [{job: build, artifacts: false}]
image: golangci/golangci-lint:v2.1
steps:
- run: golangci-lint run
A cache is a best-effort copy of some paths, kept between runs and looked up by key. A job may find it empty, so never depend on it for correctness.
files: [go.sum]keys the cache on that file's contents, withkeyas the prefix.key: go-build-${{ branch }}gives each branch its own cache;fallback-keysare tried, in order, when that key has none yet.policy:pull-push(the default) restores and saves,pullonly restores,pushonly saves.when:success(the default) oralwayssaves after a failure too.cache:takes one cache or a list.
Artifacts are files a job keeps after it ends. Every job that needs it finds them in its own working directory, at the same paths.
artifacts: [dist]keepsdist. The long form is{paths, when, expire-in}:whenissuccess(the default),failureoralways, andexpire-inhow long they are kept (1 week,30 days).needs: [{job: build, artifacts: false}]waits forbuildwithout downloading its artifacts.- No artifact path may be, hold or match
.branchd/run/(.,*,**and.branchdare refused): branchd keeps a run's own files there.