Skip to content

Use deterministic Go guide linting #60

Use deterministic Go guide linting

Use deterministic Go guide linting #60

Workflow file for this run

name: Go module CI
# Full drift + test gate for the published module (regen / go PRs).
# Guide-only PRs use go-module-guide-validate instead (no drift requirement).
on:
pull_request:
paths:
- 'go/**'
- 'schema/**'
- 'mise.toml'
- '.github/workflows/go-module-ci.yml'
push:
branches: [main]
paths:
- 'go/**'
- 'schema/**'
- 'mise.toml'
- '.github/workflows/go-module-ci.yml'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go/go.mod
cache-dependency-path: |
go/go.mod
go/internal/gen/go.sum
- name: Regenerate publishable tree
working-directory: go/internal/gen
run: go run .
- name: Fail on generated drift
run: |
set -euo pipefail
if [ -n "$(git status --porcelain -- go/)" ]; then
echo "go/ drift detected after regenerate:"
git status --porcelain -- go/
exit 1
fi
- name: gofmt
working-directory: go
run: |
out="$(gofmt -l .)"
if [ -n "$out" ]; then
echo "gofmt needed on:"
echo "$out"
exit 1
fi
- name: Size budget
run: |
set -euo pipefail
size_kb="$(du -sk go/generated | awk '{print $1}')"
echo "go/generated size: ${size_kb} KiB"
if [ "$size_kb" -gt 5120 ]; then
echo "publishable payload exceeds 5 MiB budget"
exit 1
fi
while IFS= read -r -d '' f; do
bytes="$(wc -c < "$f")"
if [ "$bytes" -gt 524288 ]; then
echo "file exceeds 512 KiB: $f ($bytes bytes)"
exit 1
fi
done < <(find go/generated -type f -print0)
- name: LICENSE present in module
run: test -f go/LICENSE
- name: go vet
working-directory: go
run: go vet .
- name: go test
working-directory: go
run: go test .
- name: generator tests
working-directory: go/internal/gen
run: go test .