Files
uberbringer/.gitea/workflows/test.yml
T
57_WolveandClaude Opus 5.5 bdd337e2dc
Security / Vulnerability check (push) Successful in 38s
Test / Lint and test (push) Successful in 1m53s
Generate the OpenAPI document from a route table
The server registers its routes from one table in server/routes.go, and
tools/genopenapi (run by go generate) writes docs/swagger.json, an
OpenAPI 3.1 document, from the same table and the Go types it names.
Schemas are reflected with invopop/jsonschema: descriptions from the
first paragraph of the doc comments, enums and limits from jsonschema
tags. Request schemas are strict, as the decoder is; response schemas
allow fields added later. The daemon serves the embedded document at
GET /openapi.json without a token, internal/app passes it to the server
in its config, and release archives and the Docker build include it.

Tests keep it honest: a golden test and a CI step fail when the
document is stale, every registered route must be in the table, and the
tags are held to validation, to the Go constants and to the values the
handlers send. receipt.Element and printqueue.Status gain field doc
comments for the descriptions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 09:30:42 -06:00

81 lines
2.6 KiB
YAML

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.
on:
push:
branches: ['**']
jobs:
check:
name: Lint and test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
# setup-go@v5 installs the release named by go.mod's go line; with a
# toolchain line, the go command switches to that instead. Fail unless
# the running Go is the one go.mod names.
- name: Check the Go toolchain
run: |
want="$(sed -n 's/^toolchain //p' go.mod)"
[ -n "$want" ] || want="go$(sed -n 's/^go //p' go.mod)"
have="$(go env GOVERSION)"
echo "go.mod names: $want; running: $have"
[ "$have" = "$want" ]
# The gofmt on PATH is setup-go's; the one under GOROOT belongs to the
# toolchain the go command switched to.
- name: gofmt
run: |
unformatted="$("$(go env GOROOT)/bin/gofmt" -l .)"
if [ -n "$unformatted" ]; then
echo "These files need gofmt:"; echo "$unformatted"; exit 1
fi
- name: goimports
run: |
unformatted="$(go tool goimports -l .)"
if [ -n "$unformatted" ]; then
echo "These files need goimports:"; echo "$unformatted"; exit 1
fi
# Prints the change and fails, without writing, if go.mod or go.sum
# is not tidy.
- name: go mod tidy
run: go mod tidy -diff
- name: go vet
run: go vet ./...
- name: staticcheck
run: go tool staticcheck ./...
# docs/swagger.json is generated from the route table and its types; a
# change to either must come with the regenerated document.
- name: OpenAPI document up to date
run: |
go generate ./...
git diff --exit-code -- docs/swagger.json
# The limit is per package: a hung test fails with every goroutine's
# stack instead of being killed by the runner.
- name: Test (race detector)
run: go test -race -timeout 5m ./...
# 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
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '2.20.3'
args: check