From db0ec104cd03b2e7e2af2c93445f931221cfb6de Mon Sep 17 00:00:00 2001 From: ZanzyTHEbar Date: Wed, 18 Feb 2026 13:06:55 +0000 Subject: [PATCH] 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. --- .github/workflows/pr.yml | 18 ++++++++++++++++++ Makefile | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b6684aacf..062224172 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -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 diff --git a/Makefile b/Makefile index ff280e3e4..61784d3e9 100644 --- a/Makefile +++ b/Makefile @@ -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