ci: add sqlc generation gate to PR workflow

New sqlc-check Makefile target runs sqlc generate and fails if generated
code differs from committed files (git diff --exit-code). CI job installs
sqlc and runs the check after fmt-check, preventing schema/query drift.
This commit is contained in:
ZanzyTHEbar 2026-02-18 13:06:55 +00:00
parent e126808864
commit db0ec104cd
2 changed files with 50 additions and 1 deletions

View file

@ -20,6 +20,24 @@ jobs:
make fmt
git diff --exit-code || (echo "::error::Code is not formatted. Run 'make fmt' and commit the changes." && exit 1)
sqlc-check:
runs-on: ubuntu-latest
needs: fmt-check
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install sqlc
run: go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
- name: Check sqlc generated code
run: make sqlc-check
vet:
runs-on: ubuntu-latest
needs: fmt-check

View file

@ -1,4 +1,5 @@
.PHONY: all build install uninstall clean help test
.PHONY: all build install uninstall clean help test \
fantasy-check fantasy-diff fantasy-sync fantasy-patch
# Build variables
BINARY_NAME=picoclaw
@ -144,6 +145,36 @@ update-deps:
@$(GO) get -u ./...
@$(GO) mod tidy
## sqlc-check: Verify sqlc-generated code is up to date
sqlc-check:
@echo "Checking sqlc generation..."
@sqlc generate -f pkg/memory/sqlc/sqlc.yaml
@git diff --exit-code -- pkg/memory/sqlc/ || (echo "::error::sqlc generated code is stale. Run 'sqlc generate -f pkg/memory/sqlc/sqlc.yaml' and commit." && exit 1)
@echo "sqlc OK"
# ---------------------------------------------------------------------------
# Fantasy SDK vendor management
# Usage: make fantasy-diff FANTASY_VERSION=v0.9.0
# make fantasy-sync FANTASY_VERSION=v0.9.0
# ---------------------------------------------------------------------------
FANTASY_VERSION ?=
## fantasy-check: Compare vendored Fantasy SDK against latest upstream
fantasy-check:
@./scripts/sync-fantasy.sh --check
## fantasy-diff: Show diff between vendored and upstream (optional FANTASY_VERSION=vX.Y.Z)
fantasy-diff:
@./scripts/sync-fantasy.sh --diff $(FANTASY_VERSION)
## fantasy-sync: Full sync of vendored Fantasy SDK (optional FANTASY_VERSION=vX.Y.Z)
fantasy-sync:
@./scripts/sync-fantasy.sh --sync $(FANTASY_VERSION)
## fantasy-patch: Save local modifications as a patch (requires NAME=description)
fantasy-patch:
@./scripts/sync-fantasy.sh --save-patch $(NAME)
## check: Run vet, fmt, and verify dependencies
check: deps fmt vet test