Skip to content

ci: add test, vet and gofmt checks; format the tree - #52

Closed
dabeecao wants to merge 6 commits into
mainfrom
ci/backend-checks
Closed

dabeecao wants to merge 6 commits into
mainfrom
ci/backend-checks

Conversation

@dabeecao

Copy link
Copy Markdown
Owner

Adds CI so regressions are caught on pull requests instead of at release time. The repository previously had no CI at all — the only workflow was release.yml, which builds and publishes on tags, so broken code could reach main and only surface at release.

Jobs

Job What it does
Lint & Format A gofmt gate (fails on any unformatted file, naming them) plus go vet ./....
Test Build + go test -race -count=1 on Linux, Windows and macOS.
Coverage Writes a profile, prints a per-package summary into the step summary, uploads the artifact (14 days).

Makefile targets, so the same gate runs locally

make check       # fmt-check + vet + test  ← the full gate
make fmt-check   # verify only, no writes (what CI runs)
make test-race
make cover
make vet

make fmt now runs gofmt -w over the tracked Go files instead of go fmt ./..., which is more predictable for files in subpackages.

Docs

docs/Development.md gains a "Pre-Pull-Request Checks" section in both languages, documenting the gate and the requirements:

  • all Go files gofmt-clean (CI fails otherwise)
  • go vet ./... clean
  • no coverage regressions; add tests with new logic, especially in database/, s3/, webdav/
  • tests must pass on all three platforms — use t.TempDir() rather than /tmp or C:\

gofmt pass

Six files were not gofmt-formatted (52 lines). Fixed here. The diff is formatting only: trailing whitespace, var block alignment, comment-block indentation, blank lines. No behaviour change — go build, go vet and the full test suite pass identically before and after.

Files: api/handlers_settings.go, api/handlers_sharing.go, api/middleware.go, s3/server.go, tgclient/client.go, tgclient/uploader.go.

Verification

  • make check → pass on the committed tree
  • go test -race -count=1 ./... → pass (api 2.2s, tgclient 2.7s, utils 1.9s)
  • go build → OK
  • The gofmt gate was probed with a deliberately mis-formatted file: it was detected and named, then removed

Notes for the merge of #51

#51 touches api/middleware.go and tgclient/client.go, which are also reformatted here. Expect small conflicts in those two files when rebasing — mechanical, whitespace-only.

Landing this first means #51 gets CI coverage from its first run.

Not covered

  • No golangci-lint (would add more than go vet; separate decision).
  • No minimum coverage threshold — the current baseline is low (api 1.2%, tgclient 3.0%, utils 8.6%), so a threshold now would be noise. Better to ratchet once coverage grows.
  • No frontend build in this workflow; the web/ submodule is checked out but the Go tests do not need its build output.

Adds a GitHub Actions workflow so regressions are caught on pull requests
instead of at release time. The repository previously had no CI at all: the
only workflow was release.yml, which builds and publishes on tags.

Jobs:
- Lint & Format: a gofmt gate (fails on any unformatted file) plus go vet.
- Test: build and go test -race on Linux, Windows and macOS.
- Coverage: writes a profile, prints a per-package summary into the step
  summary and uploads the artifact.

Makefile gains matching targets so contributors can run the same gate
locally: fmt-check, vet, test-race, cover, and check (fmt-check + vet +
test). make fmt now runs gofmt -w over the tracked Go files rather than
"go fmt ./...".

docs/Development.md gains a "Pre-Pull-Request Checks" section in both
languages documenting the gate and the requirements: gofmt-clean, vet-clean,
no coverage regressions, and tests that pass on all three platforms.

.gitignore gains coverage.out, coverage.html and *.test.

The six remaining gofmt differences (52 lines) are formatting only:
trailing whitespace, var-block alignment, comment-block indentation and
blank lines. No behaviour change; build, vet and the full test suite pass
before and after.
main.go go:embed's the frontend build output (web/static/**/*.min.*), but
those files are gitignored and only exist after a frontend build. On a
fresh CI checkout the embed directive failed with:

    main.go:50:12: pattern web/static/css/*.min.css: no matching files found

which made both the lint and test jobs fail before compiling anything.

Fix: check out submodules recursively and run web/build-frontend.sh before
go vet / go build / go test, in all three jobs. The embedded assets are
platform-independent, so building them on Linux once per job is enough even
in the OS matrix.
The Windows job failed with a message that pointed at Go but was really a
frontend dependency problem:

    main.go:53:29: pattern web/static/webfonts: no matching files found

The frontend build on that runner installed @fortawesome/fontawesome-free
7.3.1 (bun.lock was gitignored, so the install was unpinned), and 7.3.1 no
longer ships webfonts/, so static/webfonts/ was never created.

The underlying dependency fix is in the frontend repo (committing bun.lock
and installing with --frozen-lockfile). This commit makes the failure
self-explanatory from the backend side: after building the frontend, assert
that every path main.go embeds actually exists, and name the likely cause
when one is missing.

Applied to all three jobs.
Picks up the frontend CI work merged as telecloud-frontend#15, which
includes the committed bun.lock. That lockfile is what makes the frontend
build reproducible: without it an unpinned install pulls Font Awesome
7.3.1, which no longer ships webfonts/, so web/static/webfonts/ is never
created and main.go's go:embed directive fails.

With the lockfile in place, the Windows CI job builds the frontend
correctly and the go:embed prerequisite check passes.
Picks up telecloud-frontend#16, which emits Font Awesome's font assets via
an outdir-relative assetNames instead of a parent-traversal one. The old
form produced no font files on the Windows runner, leaving
web/static/webfonts/ absent and breaking main.go's go:embed directive.
@dabeecao

Copy link
Copy Markdown
Owner Author

Closing and reverting — these changes are being rolled back at the author's request.

@dabeecao dabeecao closed this Nov 22, 2026
@dabeecao
dabeecao deleted the ci/backend-checks branch November 22, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant