modernc.org/sqlite is C transpiled to Go against one version of modernc.org/libc, and its go.mod names that version exactly: v1.80.1 for v1.64.0, while libc's latest is v1.82.14. A newer libc breaks the driver without a compile error, and a routine go get -u would move it. The owner accepted holding libc there as the one exception to taking each dependency at its latest stable release; it moves only with the driver. tools/libcpin compares the libc that go list -m selects with the one go mod graph shows the selected modernc.org/sqlite requiring, and fails with the go get that restores it. It runs as go run ./tools/libcpin, so it works from PowerShell and in CI alike. test.yml and make check run it after go mod tidy -diff, CLAUDE.md lists it in the gate and records the exception beside the dependency rule, and design.md records it under the stack choices. Moving libc to v1.82.14 with go get made the check fail as it should; the change was not kept. Part of stage 1d of docs/plans/job-store.md (decision 13). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
135 lines
6.3 KiB
Markdown
135 lines
6.3 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 run ./tools/libcpin`,
|
|
which fails unless `modernc.org/libc` is the exact version
|
|
`modernc.org/sqlite` requires, `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
|
|
internal/pkg/jobstore/ The job store on disk: one SQLite database, through modernc.org/sqlite
|
|
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
|
|
tools/libcpin/ Checks that modernc.org/libc is the version modernc.org/sqlite requires
|
|
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.
|