Skip to content

Add GitHub Actions for tests, coverage, lint and Docker - #4

Merged
tmphost-dev merged 1 commit into
mainfrom
ci/github-actions
Oct 23, 2026
Merged

tmphost-dev merged 1 commit into
mainfrom
ci/github-actions

Conversation

@tmphost-dev

@tmphost-dev tmphost-dev commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflows modelled on tmphost's:

Workflow Runs on What
Backend PR / main (backend paths) vet, CGO_ENABLED=0 build, go test -race with a Postgres 18 service so the driver tests run, coverage gate
Frontend PR / main (frontend paths) vitest with the thresholds in vitest.config.js, build
Lint PR / main golangci-lint v2.15.0 (backend/.golangci.yml), ESLint with --max-warnings 0
Docker PR builds the image (amd64, no push)
Build and Push Docker Image push to main <DOCKERHUB_USERNAME>/sql-mcp:latest + :<sha>, amd64 + arm64
Release Docker Image on Tag v* tag :<version> + :<major>.<minor>
Case collisions every PR scripts/check-case.sh

Coverage gate (scripts/coverage.sh): the backend total, measured with -coverpkg so the app's HTTP tests credit the handlers, may not drop below COVER_MIN (95% in CI, which measures 95.8% with the Postgres tests; make cover defaults to 92.5% because local runs usually skip them). On PRs, every Go line the PR adds must be run by a test, which matches the 100%-of-new-lines target in AGENTS.md. make cover BASE=main runs the same check locally.

Needs: repository secrets DOCKERHUB_USERNAME and DOCKERHUB_TOKEN.

Fixes needed to go green:

  • TestRunHTTPS read s.cert without the lock: a data race under -race, and flaky. It now waits for the cert under the lock.
  • Four golangci-lint findings (unchecked tx.Rollback, an ineffectual assignment, an invisible U+202E in a test literal, a tagged switch).
  • Five ESLint findings. Toast.vue was renamed to ToastStack.vue for vue/multi-word-component-names.
  • The Postgres driver tests counted rows in a seeded shop database that was never committed, so they failed against the README's empty database. The seed is now backend/internal/service/dbdriver/testdata/shop.sql, loaded by CI and by the README recipe.
  • Toast ids were Date.now() + Math.random(), which leaves only ~4096 distinct values per millisecond. Two toasts could share an id, so dismissing one removed both, and the useToasts test flaked in CI. Ids now come from a counter.
  • .dockerignore keeps .env, node_modules and build output out of the build context.

Checked locally: make test, make lint, make cover BASE=main, actionlint, docker build. The Postgres driver tests were also run in a container against the fixture, and every check on this PR passes.

🤖 Generated with Claude Code

GitHub Actions workflows:

- Backend: go vet, a CGO-free build, and race tests against a Postgres
  service seeded from testdata/shop.sql, so the driver tests run too.
- Coverage: scripts/coverage.sh fails a PR on any added Go line no test
  runs, or on a backend total below COVER_MIN (95%).
- Frontend: vitest with its coverage thresholds, then the Vite build.
- Lint: golangci-lint v2.15.0 and ESLint, warnings included.
- Docker: multi-arch images, latest and sha tags on main, semver tags on
  v*, and a build-only check on pull requests.
- Case collisions: scripts/check-case.sh on every PR.

Fixes needed for the tree to pass them:

- TestRunHTTPS read the certificate without holding the lock, a data race.
- Toast ids came from Date.now() + Math.random() and could collide, so
  dismissing one toast removed another. They now come from a counter.
- The Postgres fixture existed only on a dev machine; it is now committed.
- Four golangci-lint and five ESLint findings (Toast.vue is ToastStack.vue).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmphost-dev
tmphost-dev merged commit 64dc7f0 into main Oct 23, 2026
6 checks passed
@tmphost-dev
tmphost-dev deleted the ci/github-actions branch October 23, 2026 07:26
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