mirror of https://github.com/coder/coder.git
chore: add sqlc push action on releases (#11171)
* add sqlc push action on releases * Make sqlc push optional
This commit is contained in:
parent
c1451ca4da
commit
e8be092af0
|
@ -479,3 +479,29 @@ jobs:
|
|||
# For gh CLI. We need a real token since we're commenting on a PR in a
|
||||
# different repo.
|
||||
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
|
||||
|
||||
# publish-sqlc pushes the latest schema to sqlc cloud.
|
||||
# At present these pushes cannot be tagged, so the last push is always the latest.
|
||||
publish-sqlc:
|
||||
name: "Publish to schema sqlc cloud"
|
||||
runs-on: "ubuntu-latest"
|
||||
needs: release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
# We need golang to run the migration main.go
|
||||
- name: Setup Go
|
||||
uses: ./.github/actions/setup-go
|
||||
|
||||
- name: Setup sqlc
|
||||
uses: ./.github/actions/setup-sqlc
|
||||
|
||||
- name: Push schema to sqlc cloud
|
||||
# Don't block a release on this
|
||||
continue-on-error: true
|
||||
run: |
|
||||
make sqlc-push
|
||||
|
|
21
Makefile
21
Makefile
|
@ -708,6 +708,27 @@ test:
|
|||
gotestsum --format standard-quiet -- -v -short -count=1 ./...
|
||||
.PHONY: test
|
||||
|
||||
# sqlc-cloud-is-setup will fail if no SQLc auth token is set. Use this as a
|
||||
# dependency for any sqlc-cloud related targets.
|
||||
sqlc-cloud-is-setup:
|
||||
if [[ "$(SQLC_AUTH_TOKEN)" == "" ]]; then
|
||||
echo "ERROR: 'SQLC_AUTH_TOKEN' must be set to auth with sqlc cloud before running verify." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
.PHONY: sqlc-cloud-is-setup
|
||||
|
||||
sqlc-push: sqlc-cloud-is-setup test-postgres-docker
|
||||
echo "--- sqlc push"
|
||||
SQLC_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/$(shell go run scripts/migrate-ci/main.go)" \
|
||||
sqlc push -f coderd/database/sqlc.yaml && echo "Passed sqlc push"
|
||||
.PHONY: sqlc-push
|
||||
|
||||
sqlc-verify: sqlc-cloud-is-setup test-postgres-docker
|
||||
echo "--- sqlc verify"
|
||||
SQLC_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/$(shell go run scripts/migrate-ci/main.go)" \
|
||||
sqlc verify -f coderd/database/sqlc.yaml && echo "Passed sqlc verify"
|
||||
.PHONY: sqlc-verify
|
||||
|
||||
sqlc-vet: test-postgres-docker
|
||||
echo "--- sqlc vet"
|
||||
SQLC_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/$(shell go run scripts/migrate-ci/main.go)" \
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
# It was chosen to ensure type-safety when interacting with
|
||||
# the database.
|
||||
version: "2"
|
||||
cloud:
|
||||
# This is the static ID for the coder project.
|
||||
project: "01HEP08N3WKWRFZT3ZZ9Q37J8X"
|
||||
# Ideally renames & overrides would go under the sql section, but there is a
|
||||
# bug in sqlc that only global renames & overrides are currently being applied.
|
||||
overrides:
|
||||
|
|
Loading…
Reference in New Issue