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

+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)