Skip to content

Commit

Permalink
Add CI step to validate examples against the JSON schema (#301)
Browse files Browse the repository at this point in the history
Add a CI step to validate that the example migrations are valid
according to the JSON schema.

This would have caught the problem where the JSON schema was not fully
updated in #293 and had to be
updated in a follow-up PR #300
despite #293 including an example migration.

Use [ajv-cli](https://ajv.js.org/packages/ajv-cli.html) to perform
schema validation.

Here is an [example
run](https://github.com/xataio/pgroll/actions/runs/8113707179/job/22177613982)
where the check fails.
  • Loading branch information
andrew-farries committed Mar 4, 2024
1 parent eda936f commit 63d5a7f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ jobs:
with:
go-version-file: 'go.mod'

- name: Validate examples against JSON schema
run: |
npx -y ajv-cli --spec=draft2020 validate -s schema.json -d "./examples/*.json"
- name: Run example migrations
run: |
if [ "$PGROLL_SCHEMA" != "public" ]; then
Expand Down

0 comments on commit 63d5a7f

Please sign in to comment.