File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -908,3 +908,27 @@ jobs:
908
908
909
909
echo "::endgroup::"
910
910
done
911
+
912
+ # sqlc-vet runs a postgres docker container, runs Coder migrations, and then
913
+ # runs sqlc-vet to ensure all queries are valid. This catches any mistakes
914
+ # in migrations or sqlc queries that makes a query unable to be prepared.
915
+ sqlc-vet :
916
+ runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
917
+ needs : changes
918
+ # TODO: We should do this on any migration or query changes.
919
+ # if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
920
+ steps :
921
+ - name : Checkout
922
+ uses : actions/checkout@v4
923
+ with :
924
+ fetch-depth : 1
925
+ # We need golang to run the migration main.go
926
+ - name : Setup Go
927
+ uses : ./.github/actions/setup-go
928
+
929
+ - name : Setup sqlc
930
+ uses : ./.github/actions/setup-sqlc
931
+
932
+ - name : Setup and run sqlc vet
933
+ run : |
934
+ make sqlc-vet
Original file line number Diff line number Diff line change @@ -708,6 +708,11 @@ test:
708
708
gotestsum --format standard-quiet -- -v -short -count=1 ./...
709
709
.PHONY : test
710
710
711
+ sqlc-vet : test-postgres-docker
712
+ echo " --- sqlc vet"
713
+ SQLC_DATABASE_URL=" postgresql://postgres:postgres@localhost:5432/$( shell go run scripts/migrate-ci/main.go) " \
714
+ sqlc vet -f coderd/database/sqlc.yaml
715
+
711
716
# When updating -timeout for this test, keep in sync with
712
717
# test-go-postgres (.github/workflows/coder.yaml).
713
718
# Do add coverage flags so that test caching works.
Original file line number Diff line number Diff line change 82
82
- schema : " ./dump.sql"
83
83
queries : " ./queries"
84
84
engine : " postgresql"
85
+ # This only works if you are running a local postgres database with the
86
+ # schema loaded and migrations run.
87
+ database :
88
+ uri : " ${SQLC_DATABASE_URL}"
89
+ rules :
90
+ - sqlc/db-prepare
85
91
gen :
86
92
go :
87
93
package : " database"
You can’t perform that action at this time.
0 commit comments