Skip to content

Commit

Permalink
Add CI check for up-to-date type generation (#225)
Browse files Browse the repository at this point in the history
Add a CI check to ensure that the `types.go` file generated from
`schema.json` is up-to-date.

Types are generated from the `schema.json` file but there was no check
in place to ensure that the two were consistent.

This PR runs `make generate` to correct an inconsistency between the
definitions and the generated types and adds the check so that we can't
repeat this mistake.

An example failed run where the types are out of date is
[here](https://github.com/xataio/pgroll/actions/runs/7475710605/job/20344427261).
  • Loading branch information
andrew-farries authored Jan 10, 2024
1 parent 72cc155 commit f1757f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,26 @@ jobs:
fi
done
type-generation:
name: type generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Generate types
run: |
make generate
- name: Ensure generated types are up-to-date
run: |
if ! git diff --quiet; then
echo "generated types are out of date!"
echo "run 'make generate' to regenerate type definitions"
exit 1
fi
license-check:
name: License check
name: license check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -106,7 +124,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs: [test, lint, examples, license-check]
needs: [test, lint, examples, license-check, type-generation]
if: startsWith(github.ref, 'refs/tags/')
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
Expand Down
6 changes: 5 additions & 1 deletion pkg/migrations/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f1757f3

Please sign in to comment.