89 lines
2.1 KiB
YAML
89 lines
2.1 KiB
YAML
# Test — Go. Runs on push and pull request to development. Never on main.
|
|
name: Test
|
|
|
|
on:
|
|
push:
|
|
branches: [development]
|
|
pull_request:
|
|
branches: [development]
|
|
|
|
jobs:
|
|
vet:
|
|
runs-on: fedora
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: "1.26"
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: gofmt
|
|
# gofmt -l prints unformatted files; an empty output is the only pass.
|
|
run: |
|
|
unformatted=$(gofmt -l .)
|
|
if [ -n "$unformatted" ]; then
|
|
echo "These files need gofmt:"
|
|
echo "$unformatted"
|
|
exit 1
|
|
fi
|
|
|
|
- name: go vet
|
|
run: go vet ./...
|
|
|
|
test:
|
|
runs-on: fedora
|
|
needs: vet
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: "1.26"
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
# The runner images have no gcc; the race detector needs CGO.
|
|
- name: Install gcc
|
|
run: dnf install -y gcc
|
|
|
|
- name: go test -race
|
|
run: go test -race -count=1 ./...
|
|
|
|
# Coverage is measured over the library packages; cmd/ is thin glue.
|
|
- name: Coverage gate — 80 % minimum
|
|
run: |
|
|
set -euo pipefail
|
|
go test -coverprofile=coverage.out ./internal/... ./pkg/...
|
|
coverage=$(go tool cover -func=coverage.out | awk '/^total:/ { gsub("%", "", $3); print $3 }')
|
|
echo "Total coverage: ${coverage}%"
|
|
if awk -v c="$coverage" 'BEGIN { exit !(c+0 < 80) }'; then
|
|
echo "ERROR: coverage ${coverage}% is below the 80% threshold"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Build examples
|
|
run: go build ./examples/...
|
|
|
|
build:
|
|
runs-on: fedora
|
|
needs: test
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: "1.26"
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: Build
|
|
run: go build -ldflags="-s -w" -o bin/nuntius ./cmd/server
|
|
|
|
- name: Smoke test
|
|
run: ./bin/nuntius --version
|