Adopt norn's CI, release, API and docs practices; bare module path
Test / Lint, test and build (push) Successful in 3m17s

Module
- The module path is now the bare "uberbringer"; imports read
  uberbringer/internal/... The banner keeps the Gitea URL.

CI and releases
- Workflows move to .gitea/workflows: test.yml (every branch push:
  gofmt, goimports, tidy, vet, staticcheck, race tests, goreleaser
  snapshot), security.yml (govulncheck weekly and on main) and a hardened
  release.yml (v* tags on main only, tags fetched, goreleaser pinned to
  2.20.3). The broken labeler workflow is removed.
- go.mod pins toolchain go1.27.4, which fixes GO-2026-6859; workflows
  check that the running Go matches it.
- .goreleaser.yaml: tidy check that never writes, reproducible file times,
  prerelease: auto, a release header linking CHANGELOG.md, and archives
  that ship CHANGELOG.md, the example config and the systemd unit.
- Makefile mirrors the CI gate; .dockerignore is an allowlist.

API and tests
- Every error answers {"error", "code", "details"} with a stable code from
  server/errors.go; the framework's own error text is never sent.
- Panics and unexpected errors are logged and reported to Sentry once;
  refusals are not logged as failures. /healthz sends no-store.
- TestRoutesConform requires auth, rate limiting and the body limit on
  every /api/v1 route.
- Race-prone tests no longer rely on freed ports or sleeps; serve takes
  an injected listener.
- The test config uses a placeholder secret instead of a real one.

Install and packaging
- install.sh resolves the latest release through the Gitea API, verifies
  checksums, requests a certificate only when none exists, installs the
  hardened packaging/uberbringer.service and writes the first token to a
  0600 file instead of printing it. It is now executable in git.

Docs
- CLAUDE.md, CHANGELOG.md (0.2.0 with breaking changes and upgrade
  steps), docs/design.md, and docs/plans/formatters.md for the planned
  CP437 blocks, modules and ntfy printing. README updated throughout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-11-29 23:27:48 -06:00
1 parent afcf96431f
commit 9b91109550
39 files changed
+3197 -433

No files matched your search

+6 -4
View File
@@ -7,10 +7,11 @@ import (
"testing"
"time"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/config"
"uberbringer/internal/pkg/config"
)
const validSecret = "xTw8qdxTy7Ng4DiptTqmeVy506xWLht3OhFn4kdawmM="
// validSecret is a placeholder that satisfies the 32-byte minimum.
const validSecret = "test-only-secret-test-only-secret-0123"
func writeConfig(t *testing.T, body string) string {
t.Helper()
@@ -21,9 +22,10 @@ func writeConfig(t *testing.T, body string) string {
return path
}
func TestLoadLegacyConfigGetsDefaults(t *testing.T) {
func TestLoadInstallScriptConfigGetsDefaults(t *testing.T) {
t.Setenv("SENTRY_DSN", "")
// The exact shape written by the original install.sh, plus a printer.
// The shape install.sh writes; every other setting comes from the
// defaults.
path := writeConfig(t, `
[webserver]
bind_ip = "127.0.0.1"
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"strings"
"testing"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/escpos"
"uberbringer/internal/pkg/escpos"
)
// Byte-exact checks against the Epson ESC/POS command reference.
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"net"
"time"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/escpos"
"uberbringer/internal/pkg/escpos"
)
// statusTimeout bounds how long the printer may take to answer one real-time
+17 -6
View File
@@ -9,8 +9,8 @@ import (
"testing"
"time"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/escpos"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/printer"
"uberbringer/internal/pkg/escpos"
"uberbringer/internal/pkg/printer"
)
// fakePrinter accepts one connection per handle call.
@@ -71,8 +71,10 @@ func TestSendUnreachable(t *testing.T) {
}
func TestSendRespectsCancelledContextWhileBusy(t *testing.T) {
accepted := make(chan struct{}, 1)
release := make(chan struct{})
addr := fakePrinter(t, func(conn net.Conn) {
accepted <- struct{}{}
<-release
_, _ = io.Copy(io.Discard, conn)
})
@@ -80,9 +82,15 @@ func TestSendRespectsCancelledContextWhileBusy(t *testing.T) {
client := printer.NewClient(addr, time.Second, 5*time.Second)
// Hold the single connection slot with a status query that never gets
// an answer, then try to send with a short deadline.
// an answer, then try to send with a short deadline. The client takes
// the slot before it dials, so once the printer has accepted the status
// query's connection the slot is held.
go func() { _, _ = client.Status(context.Background()) }()
time.Sleep(100 * time.Millisecond)
select {
case <-accepted:
case <-time.After(5 * time.Second):
t.Fatal("the status query never connected")
}
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
@@ -168,14 +176,17 @@ func TestStatusUnsupported(t *testing.T) {
func TestStatusContextDeadlineIsNotUnsupported(t *testing.T) {
// A printer that answers, just later than the caller is willing to wait,
// e.g. while it works through a large buffered image.
// e.g. while it works through a large buffered image. It answers only
// once the test is over, after the caller's deadline has passed.
late := make(chan struct{})
t.Cleanup(func() { close(late) })
addr := fakePrinter(t, func(conn net.Conn) {
req := make([]byte, 3)
for {
if _, err := io.ReadFull(conn, req); err != nil {
return
}
time.Sleep(300 * time.Millisecond)
<-late
_, _ = conn.Write([]byte{0x1A}) // offline
}
})
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"go.jetify.com/typeid"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/receipt"
"uberbringer/internal/pkg/receipt"
)
// jobTimeout bounds rendering and sending one job, including retries.
+32 -29
View File
@@ -10,8 +10,8 @@ import (
"testing"
"time"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/printqueue"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/receipt"
"uberbringer/internal/pkg/printqueue"
"uberbringer/internal/pkg/receipt"
)
type fakeRenderer struct{ err error }
@@ -72,11 +72,11 @@ func newQueue(r printqueue.Renderer, s printqueue.Sender, opts printqueue.Option
return printqueue.New(r, s, discardLogger(), opts)
}
// startQueue runs q until the test ends and returns a func that stops it and
// waits for Run to return.
func startQueue(t *testing.T, q *printqueue.Queue) (stop func()) {
// startQueue runs q until the test ends. cancel cancels Run's context and
// wait blocks until Run has returned.
func startQueue(t *testing.T, q *printqueue.Queue) (cancel, wait func()) {
t.Helper()
ctx, cancel := context.WithCancel(context.Background())
ctx, cancelRun := context.WithCancel(context.Background())
done := make(chan struct{})
go func() {
defer close(done)
@@ -84,10 +84,9 @@ func startQueue(t *testing.T, q *printqueue.Queue) (stop func()) {
t.Error(err)
}
}()
var once sync.Once
stop = func() { once.Do(func() { cancel(); <-done }) }
t.Cleanup(stop)
return stop
wait = func() { <-done }
t.Cleanup(func() { cancelRun(); wait() })
return cancelRun, wait
}
func waitForState(t *testing.T, q *printqueue.Queue, id printqueue.JobID, want printqueue.State) printqueue.Status {
@@ -145,27 +144,31 @@ func TestRetriesThenSucceeds(t *testing.T) {
}
func TestFailsAfterRetries(t *testing.T) {
var reported []printqueue.JobID
var mu sync.Mutex
reported := make(chan printqueue.JobID, 2)
sender := &fakeSender{failures: 10}
q := newQueue(fakeRenderer{}, sender, printqueue.Options{
Retries: 2,
OnFailure: func(id printqueue.JobID, _ error) {
mu.Lock()
defer mu.Unlock()
reported = append(reported, id)
},
Retries: 2,
OnFailure: func(id printqueue.JobID, _ error) { reported <- id },
})
startQueue(t, q)
cancel, wait := startQueue(t, q)
st, _ := q.Submit(job("x"))
failed := waitForState(t, q, st.ID, printqueue.StateFailed)
if failed.Attempts != 3 || !strings.Contains(failed.Error, "printer offline") {
t.Errorf("failed status = %+v", failed)
}
mu.Lock()
defer mu.Unlock()
if len(reported) != 1 || reported[0] != st.ID {
t.Errorf("OnFailure got %v", reported)
// OnFailure runs after the job is marked failed, so wait for it.
select {
case id := <-reported:
if id != st.ID {
t.Errorf("OnFailure got %s, want %s", id, st.ID)
}
case <-time.After(5 * time.Second):
t.Fatal("OnFailure was not called")
}
cancel()
wait()
if n := len(reported); n != 0 {
t.Errorf("OnFailure called %d more times, want once", n)
}
}
@@ -199,17 +202,17 @@ func TestQueueFull(t *testing.T) {
func TestShutdownFinishesCurrentJobAndFailsWaiting(t *testing.T) {
sender := &fakeSender{block: make(chan struct{})}
q := newQueue(fakeRenderer{}, sender, printqueue.Options{})
stop := startQueue(t, q)
cancel, wait := startQueue(t, q)
first, _ := q.Submit(job("first"))
waitForState(t, q, first.ID, printqueue.StatePrinting)
second, _ := q.Submit(job("second"))
stopped := make(chan struct{})
go func() { stop(); close(stopped) }()
time.Sleep(20 * time.Millisecond) // let Run observe the cancellation
close(sender.block) // the in-flight send completes
<-stopped
// Cancel while the first send is still blocked, so Run is shutting down
// by the time that send completes.
cancel()
close(sender.block)
wait()
if st, _ := q.Status(first.ID); st.State != printqueue.StateDone {
t.Errorf("in-flight job state = %s, want done", st.State)
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"image/png"
"testing"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/raster"
"uberbringer/internal/pkg/raster"
)
func encodePNG(t *testing.T, img image.Image) []byte {
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"net/url"
"strings"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/escpos"
"uberbringer/internal/pkg/escpos"
)
// Element types.
+1 -1
View File
@@ -3,7 +3,7 @@ package receipt
import (
"strings"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/escpos"
"uberbringer/internal/pkg/escpos"
)
// tabWidth matches the printer's default horizontal tab stops.
+2 -2
View File
@@ -11,8 +11,8 @@ import (
"strings"
"testing"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/escpos"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/receipt"
"uberbringer/internal/pkg/escpos"
"uberbringer/internal/pkg/receipt"
)
type fakeFetcher struct {
+2 -2
View File
@@ -8,8 +8,8 @@ import (
"strings"
"unicode/utf8"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/escpos"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/raster"
"uberbringer/internal/pkg/escpos"
"uberbringer/internal/pkg/raster"
)
// Fetcher downloads remote image data.
+1 -1
View File
@@ -11,7 +11,7 @@ import (
"testing"
"time"
"git.anomalous.dev/57_Wolve/uberbringer/internal/pkg/safehttp"
"uberbringer/internal/pkg/safehttp"
)
func newServer(t *testing.T, body string) *httptest.Server {