Files
uberbringer/docs/development.md
T
57_WolveandClaude Opus 5.5 60baa843ef Cross-compile the ARM targets in CI and the gate
Releases ship linux/arm (ARMv6 and ARMv7) and linux/arm64 binaries built
without cgo, but until now nothing compiled those targets before a tag
was pushed. The job store's SQLite driver is Go transpiled from C, with
code of its own for each architecture, so a build that works on amd64
can fail for ARM.

test.yml and make check now build the daemon for linux/arm with GOARM=6
and for linux/arm64, with CGO_ENABLED=0, and discard the binaries. The
ARMv6 build stands for ARMv7 as well. CLAUDE.md lists the two builds in
the gate, run from Git Bash, since PowerShell cannot set variables for
one command.

Part of stage 1d of docs/plans/job-store.md (decision 15).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 16:34:34 -06:00

131 lines
6.0 KiB
Markdown

# Development
## Contents
- [Running from source](#running-from-source)
- [Go version](#go-version)
- [Make targets](#make-targets)
- [Generated files](#generated-files)
- [Package layout](#package-layout)
- [CI and releases](#ci-and-releases)
## Running from source
Build from a clone of the repository.
```sh
cp configs/config.example.toml config.toml
go run ./cmd/uberbringer secret # paste into api.secret
$EDITOR config.toml # set printer.address
go run ./cmd/uberbringer token # prints a bearer token
make run
```
## Go version
The Go version is the `go 1.27.4` line in `go.mod`, the latest Go release:
- It is the minimum for building, and builds with `GOTOOLCHAIN=local` need at
least that. With the default `GOTOOLCHAIN=auto`, an older local Go
downloads go1.27.4 by itself.
- CI tests, scans and releases with exactly that release; the workflows read
it from `go.mod`. There is no separate `toolchain` line.
- To move to a new Go release, change the go line
(`go mod edit -go=1.27.5`). In the same commit, bump the tool modules
golang.org/x/tools, golang.org/x/vuln and honnef.co/go/tools.
## Make targets
```sh
make check # the CI gate, below
make build # bin/uberbringer
make build-arm # builds for linux/arm (ARMv6) and linux/arm64, then discards them
make fmt # gofmt + goimports
make vuln # govulncheck
make generate # regenerate docs/swagger.json and the license notices (go generate ./...)
make snapshot # release archives in dist/; publishes nothing
```
`make check` runs the same steps as `.gitea/workflows/test.yml`, in the same
order: gofmt and goimports, `go mod tidy -diff`, `go vet`, staticcheck, a
check that `go generate ./...` leaves the generated files unchanged,
`go test -race -timeout 5m`, builds for linux/arm (ARMv6) and linux/arm64
without cgo, as releases are built, whose binaries it discards, and
`goreleaser check`, which validates the release config without building.
It needs goreleaser installed.
govulncheck is not part of it; run `make vuln`. Run `make snapshot` after
changing `.goreleaser.yaml` or `packaging/`. `make` builds report the
version without the leading `v`, e.g. `0.1.2-3-gabc1234`, as release
binaries do.
The linters are pinned as Go tools in `go.mod`, so `go tool staticcheck`,
`go tool govulncheck` and `go tool goimports` need no separate install.
## Generated files
Never edit these by hand. Change their sources, run `go generate ./...`,
and commit the result with the change.
- `docs/swagger.json` is generated by `tools/genopenapi` from the route
table in `internal/app/uberbringer/server/routes.go`, which the server
also registers its routes from. The schemas come from the Go types the
routes name: their `json` and `jsonschema` tags and their doc comments.
- `THIRD-PARTY-LICENSES.md` and its copy
`internal/app/uberbringer/licenses_embed.md`, which the binary embeds and
`uberbringer licenses` prints, are generated by `tools/genlicenses`. They
hold the license and notice files of the Go distribution and of every
module that `./cmd/uberbringer` links on the release platforms; modules
that only the tools and tests use are left out. Regenerate them after
adding, bumping or dropping a dependency. The generator fails on a module
that ships no license file, or whose license it does not recognize; teach
`licenseMarkers` in `tools/genlicenses/notices.go` its wording once the
license is acceptable.
## Package layout
The module path is `uberbringer`, so packages import as
`uberbringer/internal/...`.
```text
cmd/uberbringer/ main: build info, signals, exit code
internal/app/uberbringer/ CLI commands and wiring
server/ Fiber HTTP API, auth, health
internal/pkg/config/ Config from TOML and UBERBRINGER_* variables (Viper): defaults, validation
internal/pkg/escpos/ ESC/POS command builder, code pages, barcodes, QR, raster, status, interpreter
internal/pkg/receipt/ Job format, validation, text folding, word wrap, blocks, rendering, preview
internal/pkg/modules/ Modules that build jobs from plain payloads: note, notify, ntfy; notification cards, markdown
internal/pkg/ntfy/ ntfy's message types; the subscriber: stream, cursor, repeats, paper budget, quiet hours
internal/pkg/raster/ Image decoding, scaling and dithering
internal/pkg/safehttp/ SSRF-guarded image fetching
internal/pkg/printer/ TCP printer client (port 9100) and status queries
internal/pkg/printqueue/ Job queue, worker and status history
configs/ Example configuration
examples/ Example jobs, such as the block calibration receipt
packaging/ systemd unit
tools/genlicenses/ Generates THIRD-PARTY-LICENSES.md and its embedded copy from the linked modules
tools/genopenapi/ Generates docs/swagger.json from the route table
docs/ User docs, API reference, OpenAPI document, design notes and feature plans
```
## CI and releases
CI runs on the Gitea runner from `.gitea/workflows/`. The repository has no
`.github/` directory.
- `test.yml` runs the `make check` gate on every branch push. It keeps none
of the binaries it builds for ARM, and it does not run on pull requests
or tags.
- `security.yml` runs govulncheck on pushes to main and every Monday at
06:00 UTC. Scheduled runs use main's copy of the workflow.
- `release.yml` builds and publishes a release with goreleaser 2.20.3 when a
`v*` tag is pushed.
- It runs only for tags whose commit is on main, and refuses any other tag.
- `vX.Y.Z-rc.N` tags are published as prereleases, so they never become the
latest release that `install.sh` installs.
- Each archive holds the binary, `LICENSE.txt`, `THIRD-PARTY-LICENSES.md`,
`README.md`, `CHANGELOG.md`, `configs/config.example.toml`,
`packaging/uberbringer.service`, `docs/swagger.json` and, from `docs/`,
`install.md`, `docker.md`, `configuration.md`, `security.md`, `api.md`,
`ntfy.md` and `cli.md`.
- The release notes link to `CHANGELOG.md` at the tag.