|
36 | 36 | ts:${{ steps.filter.outputs.ts }}
|
37 | 37 | k8s:${{ steps.filter.outputs.k8s }}
|
38 | 38 | ci:${{ steps.filter.outputs.ci }}
|
| 39 | +db:${{ steps.filter.outputs.db }} |
39 | 40 | offlinedocs-only:${{ steps.filter.outputs.offlinedocs_count == steps.filter.outputs.all_count }}
|
40 | 41 | offlinedocs:${{ steps.filter.outputs.offlinedocs }}
|
41 | 42 | steps:
|
|
57 | 58 | - "examples/web-server/**"
|
58 | 59 | - "examples/monitoring/**"
|
59 | 60 | - "examples/lima/**"
|
| 61 | + db: |
| 62 | + - "**.sql" |
| 63 | + - "coderd/database/queries/**" |
| 64 | + - "coderd/database/migrations" |
| 65 | + - "coderd/database/sqlc.yaml" |
| 66 | + - "coderd/database/dump.sql" |
60 | 67 | go:
|
61 | 68 | - "**.sql"
|
62 | 69 | - "**.go"
|
@@ -618,6 +625,7 @@ jobs:
|
618 | 625 | -test-js
|
619 | 626 | -test-e2e
|
620 | 627 | -offlinedocs
|
| 628 | + -sqlc-vet |
621 | 629 | # Allow this job to run even if the needed jobs fail, are skipped or
|
622 | 630 | # cancelled.
|
623 | 631 | if:always()
|
@@ -908,3 +916,26 @@ jobs:
|
908 | 916 |
|
909 | 917 | echo "::endgroup::"
|
910 | 918 | done
|
| 919 | +
|
| 920 | +# sqlc-vet runs a postgres docker container, runs Coder migrations, and then |
| 921 | +# runs sqlc-vet to ensure all queries are valid. This catches any mistakes |
| 922 | +# in migrations or sqlc queries that makes a query unable to be prepared. |
| 923 | +sqlc-vet: |
| 924 | +runs-on:${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} |
| 925 | +needs:changes |
| 926 | +if:needs.changes.outputs.db == 'true' || github.ref == 'refs/heads/main' |
| 927 | +steps: |
| 928 | + -name:Checkout |
| 929 | +uses:actions/checkout@v4 |
| 930 | +with: |
| 931 | +fetch-depth:1 |
| 932 | +# We need golang to run the migration main.go |
| 933 | + -name:Setup Go |
| 934 | +uses:./.github/actions/setup-go |
| 935 | + |
| 936 | + -name:Setup sqlc |
| 937 | +uses:./.github/actions/setup-sqlc |
| 938 | + |
| 939 | + -name:Setup and run sqlc vet |
| 940 | +run:| |
| 941 | + make sqlc-vet |