ci(release): simplify tag pattern and bump action versions
This commit is contained in:
+22
-17
@@ -1,3 +1,4 @@
|
||||
# Test — Go. Runs on push and pull request to development. Never on main.
|
||||
name: Test
|
||||
|
||||
on:
|
||||
@@ -10,9 +11,9 @@ jobs:
|
||||
vet:
|
||||
runs-on: fedora
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.26"
|
||||
|
||||
@@ -20,12 +21,11 @@ jobs:
|
||||
run: go mod download
|
||||
|
||||
- name: gofmt
|
||||
# `gofmt -l` prints the names of unformatted files. An empty
|
||||
# output is the only acceptable result.
|
||||
# gofmt -l prints unformatted files; an empty output is the only pass.
|
||||
run: |
|
||||
unformatted=$(gofmt -l cmd internal pkg)
|
||||
unformatted=$(gofmt -l .)
|
||||
if [ -n "$unformatted" ]; then
|
||||
echo "The following files need gofmt:"
|
||||
echo "These files need gofmt:"
|
||||
echo "$unformatted"
|
||||
exit 1
|
||||
fi
|
||||
@@ -37,36 +37,44 @@ jobs:
|
||||
runs-on: fedora
|
||||
needs: vet
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.26"
|
||||
|
||||
- name: Download dependencies
|
||||
run: go mod download
|
||||
|
||||
- name: Install build tools
|
||||
# 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 ./...
|
||||
|
||||
- name: Check coverage threshold
|
||||
# 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/...
|
||||
go tool cover -func=coverage.out | grep '^total:' | python3 -c "import sys; pct=float(sys.stdin.read().split()[2].rstrip('%')); sys.exit(0 if pct >= 80 else 1)" || (echo "ERROR: coverage < 80%"; exit 1)
|
||||
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: go test ./examples
|
||||
- name: Build examples
|
||||
run: go build ./examples/...
|
||||
|
||||
build:
|
||||
runs-on: fedora
|
||||
needs: test
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: "1.26"
|
||||
|
||||
@@ -76,8 +84,5 @@ jobs:
|
||||
- name: Build
|
||||
run: go build -ldflags="-s -w" -o bin/nuntius ./cmd/server
|
||||
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
|
||||
- name: Smoke test
|
||||
run: ./bin/nuntius --version
|
||||
|
||||
Reference in New Issue
Block a user