68 lines
1.4 KiB
YAML
68 lines
1.4 KiB
YAML
# Docker-based dev workflow — no local tooling beyond Docker is required.
|
|
#
|
|
# docker compose run --rm test
|
|
# docker compose run --rm vet
|
|
# docker compose run --rm build
|
|
#
|
|
# The full gate — vet, formatting and tests — is `docker build .`, which is what
|
|
# CI runs.
|
|
#
|
|
# Build caches persist in the `gocache` volume, so re-runs are fast and the
|
|
# host tree stays clean. Commands that rewrite source (fmt, tidy) keep your
|
|
# ownership when run with `--user "$(id -u):$(id -g)"`.
|
|
#
|
|
# GO_VERSION picks the toolchain image (default: latest stable). Test the lowest
|
|
# supported Go with: GO_VERSION=1.22 docker compose run --rm test
|
|
|
|
x-go: &go
|
|
image: golang:${GO_VERSION:-1.26.4}
|
|
working_dir: /app
|
|
volumes:
|
|
- .:/app
|
|
- gocache:/cache
|
|
environment:
|
|
HOME: /cache
|
|
GOCACHE: /cache/build
|
|
GOMODCACHE: /cache/mod
|
|
|
|
services:
|
|
test:
|
|
<<: *go
|
|
command: go test -race ./...
|
|
|
|
cover:
|
|
<<: *go
|
|
command: go test -cover ./...
|
|
|
|
bench:
|
|
<<: *go
|
|
command: go test -run XXX -bench . -benchmem ./...
|
|
|
|
vet:
|
|
<<: *go
|
|
command: go vet ./...
|
|
|
|
cyclo:
|
|
<<: *go
|
|
command: go run github.com/fzipp/gocyclo/cmd/gocyclo@v0.6.0 -over 14 -ignore _test .
|
|
|
|
build:
|
|
<<: *go
|
|
command: go build ./...
|
|
|
|
fmt:
|
|
<<: *go
|
|
command: gofmt -w .
|
|
|
|
tidy:
|
|
<<: *go
|
|
command: go mod tidy
|
|
|
|
# Interactive shell for ad-hoc work: docker compose run --rm dev
|
|
dev:
|
|
<<: *go
|
|
command: sh
|
|
|
|
volumes:
|
|
gocache:
|