diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index c9f5e9b..a3c1fa1 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -1,8 +1,9 @@ name: Test # Every branch push, and no pull_request trigger: branches are pushed -# directly, so each commit runs once. Branch pushes lint and test but build -# no binaries; binaries are built only by release.yml, for tags on main. +# directly, so each commit runs once. Branch pushes lint, test and +# cross-compile for ARM, but keep no binaries; release binaries are built +# only by release.yml, for tags on main. on: push: branches: ['**'] @@ -72,6 +73,14 @@ jobs: - name: Test (race detector) run: go test -race -timeout 5m ./... + # Release binaries are built for ARM without cgo, and the tests run on + # amd64 only, so code that builds there but not for 32-bit or 64-bit + # ARM fails here rather than on a tag. The binaries are discarded. + - name: Build for ARM + run: | + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -o /dev/null ./cmd/uberbringer + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /dev/null ./cmd/uberbringer + # Validates .goreleaser.yaml without building anything, so a config # error fails here rather than on a tag. Same pin as release.yml. - name: GoReleaser config check diff --git a/CLAUDE.md b/CLAUDE.md index 331d187..87a3b17 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -78,18 +78,22 @@ works from PowerShell and fails from Git Bash. go tool staticcheck ./... go generate ./... && git diff --exit-code -- docs/swagger.json THIRD-PARTY-LICENSES.md internal/app/uberbringer/licenses_embed.md # generated files are up to date go test -race -timeout 5m ./... *> "$env:TEMP\uberbringer-test.txt"; "exit $LASTEXITCODE" + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -o /dev/null ./cmd/uberbringer # in Git Bash + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /dev/null ./cmd/uberbringer # in Git Bash go tool govulncheck ./... # after any dependency or toolchain change, and before a tag goreleaser release --snapshot --clean # into dist/; after a change to .goreleaser.yaml or packaging/ Read the test output back from the file. The per-package `-timeout 5m` makes a hung test fail with every goroutine's stack. Without it, the tool's own time -limit would kill the run first. staticcheck, goimports and govulncheck are -pinned as tools in `go.mod`, so never install them separately. -`.gitea/workflows/test.yml` runs the same gate, with `goreleaser check` in -place of the snapshot, on every branch push. It builds no binaries: only -`release.yml` does, for `v*` tags on main. `security.yml` runs govulncheck -weekly and on pushes to main. A change is done when the gate passes and the -docs under `docs/` (or `README.md`) and CHANGELOG.md say what changed. +limit would kill the run first. The ARM builds set their variables inline, +which PowerShell cannot; they need no cgo, so Git Bash runs them. +staticcheck, goimports and govulncheck are pinned as tools in `go.mod`, so +never install them separately. `.gitea/workflows/test.yml` runs the same +gate, with `goreleaser check` in place of the snapshot, on every branch +push. It keeps no binaries: only `release.yml` builds release binaries, for +`v*` tags on main. `security.yml` runs govulncheck weekly and on pushes to +main. A change is done when the gate passes and the docs under `docs/` (or +`README.md`) and CHANGELOG.md say what changed. ## Go version diff --git a/Makefile b/Makefile index 8479ce8..325ef06 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build test lint fmt fmt-check vet tidy tidy-check vuln generate generate-check release-check snapshot check run +.PHONY: build build-arm test lint fmt fmt-check vet tidy tidy-check vuln generate generate-check release-check snapshot check run # Without the leading v, as goreleaser's {{ .Version }} reports it. VERSION ?= $(patsubst v%,%,$(shell git describe --tags --always --dirty 2>/dev/null || echo dev)) @@ -11,6 +11,12 @@ GENERATED := docs/swagger.json THIRD-PARTY-LICENSES.md internal/app/uberbringer/ build: go build -trimpath -ldflags "$(LDFLAGS)" -o bin/ ./cmd/... +# Cross-compiles the daemon for 32-bit (ARMv6) and 64-bit ARM without cgo, +# as releases are built, and discards the binaries. +build-arm: + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -o /dev/null ./cmd/uberbringer + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /dev/null ./cmd/uberbringer + # The limit is per package: a hung test fails with every goroutine's stack. test: go test -race -timeout 5m ./... @@ -56,13 +62,13 @@ release-check: # Cross-compiles every shipped target and packs the release archives into # dist/, publishing nothing. Run it after changing .goreleaser.yaml or -# packaging/; CI builds binaries only for release tags. +# packaging/; CI builds release binaries only for tags. snapshot: goreleaser release --snapshot --clean # The gate .gitea/workflows/test.yml runs, in the same order. # .gitea/workflows/security.yml runs vuln. -check: fmt-check tidy-check vet lint generate-check test release-check +check: fmt-check tidy-check vet lint generate-check test build-arm release-check run: go run ./cmd/uberbringer --config config.toml diff --git a/docs/development.md b/docs/development.md index dffc9d8..b22ddd5 100644 --- a/docs/development.md +++ b/docs/development.md @@ -39,6 +39,7 @@ The Go version is the `go 1.27.4` line in `go.mod`, the latest Go release: ```sh make check # the CI gate, below make build # bin/uberbringer +make build-arm # builds for linux/arm (ARMv6) and linux/arm64, then discards them make fmt # gofmt + goimports make vuln # govulncheck make generate # regenerate docs/swagger.json and the license notices (go generate ./...) @@ -48,8 +49,10 @@ make snapshot # release archives in dist/; publishes nothing `make check` runs the same steps as `.gitea/workflows/test.yml`, in the same order: gofmt and goimports, `go mod tidy -diff`, `go vet`, staticcheck, a check that `go generate ./...` leaves the generated files unchanged, -`go test -race -timeout 5m`, and `goreleaser check`, which validates the -release config without building. It needs goreleaser installed. +`go test -race -timeout 5m`, builds for linux/arm (ARMv6) and linux/arm64 +without cgo, as releases are built, whose binaries it discards, and +`goreleaser check`, which validates the release config without building. +It needs goreleaser installed. govulncheck is not part of it; run `make vuln`. Run `make snapshot` after changing `.goreleaser.yaml` or `packaging/`. `make` builds report the version without the leading `v`, e.g. `0.1.2-3-gabc1234`, as release @@ -109,8 +112,9 @@ docs/ User docs, API reference, OpenAPI document, design n CI runs on the Gitea runner from `.gitea/workflows/`. The repository has no `.github/` directory. -- `test.yml` runs the `make check` gate on every branch push. It builds no - binaries, and it does not run on pull requests or tags. +- `test.yml` runs the `make check` gate on every branch push. It keeps none + of the binaries it builds for ARM, and it does not run on pull requests + or tags. - `security.yml` runs govulncheck on pushes to main and every Monday at 06:00 UTC. Scheduled runs use main's copy of the workflow. - `release.yml` builds and publishes a release with goreleaser 2.20.3 when a