Files
uberbringer/.gitea/workflows/test.yml
T
57_WolveandClaude Opus 5.5 eacd0bfd27
Security / Vulnerability check (push) Successful in 41s
Test / Lint and test (push) Successful in 1m54s
Read the config with Viper and environment variables, on Go 1.27.4
The config loader uses Viper instead of BurntSushi/toml. Every setting
can also come from UBERBRINGER_<SECTION>_<KEY>, which wins over the
file, and UBERBRINGER_CONFIG sets the default of --config; set empty, no
file is read, so a container can run from the environment alone. Each
setting is bound to its own variable, so a variable named after a
section changes nothing.

The file is parsed with go-toml and checked as written: unknown keys,
empty tables and keys that differ only in case are errors, a UTF-8 BOM
is skipped and a UTF-16 file is refused. Values are decoded strictly:
durations are strings, numbers decimal, flags true or false, and a
fraction for a whole number is refused. Errors name the file, the line
of a syntax error and the variables that were set, never their values.

`uberbringer config get <key>` prints one setting as the daemon would
use it. install.sh reads body_limit, bind_ip and port through it, so the
config is checked before the service restarts and Caddy proxies to the
configured address. The script then waits for the daemon to answer,
downloads Caddy's key and source list before replacing them, requires
Caddy's own repository, keeps the Caddyfile during dpkg upgrades,
detects an existing import loosely, logs Caddy's other errors, drops
query strings from the access log and validates the domain and printer
address more tightly.

go.mod names Go 1.27.4 with no toolchain line, and the workflows check
against the go line. The changelog folds the unreleased entries into
0.2.0, which is not tagged yet.

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

74 lines
2.3 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 ./...
# 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