.hearthforge-ci.toml
| 1 | # Checks and build. Runs on every push to master and on every tag. |
| 2 | image = "docker.io/golang:1.27" |
| 3 | work_dir = "/ci/build" |
| 4 | clone_project_to = "/ci/build/project" |
| 5 | shell_setup = "set -euo pipefail" |
| 6 | timeout = 1800 |
| 7 | memory_limit = "3g" |
| 8 | |
| 9 | cache = [ |
| 10 | { path = "/go/pkg/mod", max_size = "1g" }, |
| 11 | { path = "/root/.cache/go-build", max_size = "1g" }, |
| 12 | ] |
| 13 | |
| 14 | [on] |
| 15 | push = ["master", "main"] |
| 16 | tag = true |
| 17 | |
| 18 | [[steps]] |
| 19 | name = "tools" |
| 20 | run_sh = """ |
| 21 | go install mvdan.cc/gofumpt@latest |
| 22 | go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest |
| 23 | go install golang.org/x/vuln/cmd/govulncheck@latest |
| 24 | """ |
| 25 | |
| 26 | [[steps]] |
| 27 | name = "tidy" |
| 28 | # The checkout has no .git, so compare copies instead of using git diff. |
| 29 | run_sh = "cd project && cp go.mod /tmp/go.mod && cp go.sum /tmp/go.sum && go mod tidy && diff /tmp/go.mod go.mod && diff /tmp/go.sum go.sum" |
| 30 | |
| 31 | [[steps]] |
| 32 | name = "format" |
| 33 | run_sh = "cd project && test -z \"$(gofumpt -l -extra .)\" || (gofumpt -l -extra . && exit 1)" |
| 34 | |
| 35 | [[steps]] |
| 36 | name = "lint" |
| 37 | run_sh = "cd project && golangci-lint run ./..." |
| 38 | |
| 39 | [[steps]] |
| 40 | name = "vulncheck" |
| 41 | warn_on_fail = true |
| 42 | run_sh = "cd project && govulncheck ./..." |
| 43 | |
| 44 | [[steps]] |
| 45 | name = "test" |
| 46 | run_sh = "cd project && go test -race -count=1 ./..." |
| 47 | |
| 48 | [[steps]] |
| 49 | name = "build" |
| 50 | run_sh = "cd project && CGO_ENABLED=0 go build -trimpath -ldflags='-s -w' -o physiobase ./cmd/physiobase" |
| 51 | publish_file = ["/ci/build/project/physiobase"] |
| 52 |