File tree 3 files changed +50
-0
lines changed 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -479,3 +479,29 @@ jobs:
479
479
# For gh CLI. We need a real token since we're commenting on a PR in a
480
480
# different repo.
481
481
GH_TOKEN : ${{ secrets.CDRCI_GITHUB_TOKEN }}
482
+
483
+ # publish-sqlc pushes the latest schema to sqlc cloud.
484
+ # At present these pushes cannot be tagged, so the last push is always the latest.
485
+ publish-sqlc :
486
+ name : " Publish to schema sqlc cloud"
487
+ runs-on : " ubuntu-latest"
488
+ needs : release
489
+ if : ${{ !inputs.dry_run }}
490
+ steps :
491
+ - name : Checkout
492
+ uses : actions/checkout@v4
493
+ with :
494
+ fetch-depth : 1
495
+
496
+ # We need golang to run the migration main.go
497
+ - name : Setup Go
498
+ uses : ./.github/actions/setup-go
499
+
500
+ - name : Setup sqlc
501
+ uses : ./.github/actions/setup-sqlc
502
+
503
+ - name : Push schema to sqlc cloud
504
+ # Don't block a release on this
505
+ continue-on-error : true
506
+ run : |
507
+ make sqlc-push
Original file line number Diff line number Diff line change @@ -708,6 +708,27 @@ test:
708
708
gotestsum --format standard-quiet -- -v -short -count=1 ./...
709
709
.PHONY : test
710
710
711
+ # sqlc-cloud-is-setup will fail if no SQLc auth token is set. Use this as a
712
+ # dependency for any sqlc-cloud related targets.
713
+ sqlc-cloud-is-setup :
714
+ if [[ " $( SQLC_AUTH_TOKEN) " == " " ]]; then
715
+ echo " ERROR: 'SQLC_AUTH_TOKEN' must be set to auth with sqlc cloud before running verify." 1>&2
716
+ exit 1
717
+ fi
718
+ .PHONY : sqlc-cloud-is-setup
719
+
720
+ sqlc-push : sqlc-cloud-is-setup test-postgres-docker
721
+ echo " --- sqlc push"
722
+ SQLC_DATABASE_URL=" postgresql://postgres:postgres@localhost:5432/$( shell go run scripts/migrate-ci/main.go) " \
723
+ sqlc push -f coderd/database/sqlc.yaml && echo " Passed sqlc push"
724
+ .PHONY : sqlc-push
725
+
726
+ sqlc-verify : sqlc-cloud-is-setup test-postgres-docker
727
+ echo " --- sqlc verify"
728
+ SQLC_DATABASE_URL=" postgresql://postgres:postgres@localhost:5432/$( shell go run scripts/migrate-ci/main.go) " \
729
+ sqlc verify -f coderd/database/sqlc.yaml && echo " Passed sqlc verify"
730
+ .PHONY : sqlc-verify
731
+
711
732
sqlc-vet : test-postgres-docker
712
733
echo " --- sqlc vet"
713
734
SQLC_DATABASE_URL=" postgresql://postgres:postgres@localhost:5432/$( shell go run scripts/migrate-ci/main.go) " \
Original file line number Diff line number Diff line change 2
2
# It was chosen to ensure type-safety when interacting with
3
3
# the database.
4
4
version : " 2"
5
+ cloud :
6
+ # This is the static ID for the coder project.
7
+ project : " 01HEP08N3WKWRFZT3ZZ9Q37J8X"
5
8
# Ideally renames & overrides would go under the sql section, but there is a
6
9
# bug in sqlc that only global renames & overrides are currently being applied.
7
10
overrides :
You can’t perform that action at this time.
0 commit comments