Skip to content

Commit

Permalink
chore: break out json schema drift check into separate script
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Jan 31, 2023
1 parent e738c4b commit 8cdedff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .github/scripts/json-schema-drift-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -u

if ! git diff-index --quiet HEAD --; then
git diff-index HEAD --
echo "there are uncommitted changes, please commit them before running this check"
exit 1
fi

success=true

if ! make generate-json-schema; then
echo "Generating json schema failed"
success=false
fi

if ! git diff-index --quiet HEAD --; then
git diff-index HEAD --
echo "JSON schema drift detected!"
success=false
fi

if ! $success; then
exit 1
fi
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ check-go-mod-tidy:

check-json-schema-drift:
$(call title,Ensure there is no drift between the JSON schema and the code)
@git diff-index --quiet HEAD -- || (echo "there are uncommitted changes, please commit them before running this check" && false)
@make generate-json-schema || (echo "$(RED)$(BOLD)JSON schema drift detected!$(RESET)" && false)
@git diff-index --quiet HEAD -- || (echo "$(RED)$(BOLD)JSON schema drift detected!$(RESET)" && false)

@.github/scripts/json-schema-drift-check.sh

## Testing targets #################################

Expand Down

0 comments on commit 8cdedff

Please sign in to comment.