Skip to content

Changed code to make it easier to do unit tests. Added unit tests and… #18

Changed code to make it easier to do unit tests. Added unit tests and…

Changed code to make it easier to do unit tests. Added unit tests and… #18

name: Validate JSON Schemas
on:
push:
branches:
- '**'
jobs:
validate-schemas:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Install jv
run: |
go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Validate JSON schemas
run: |
for file in $(find ./.schema/test/ -name "*.hery"); do
echo "Validating $file"
tmpfile="${file%.hery}.yaml"
mv "$file" "$tmpfile"
if [[ $file == *invalid.hery ]]; then
if jv ./.schema/entity.schema.json "$tmpfile"; then
echo "Error: $file is invalid but passed validation"
mv "$tmpfile" "$file"
exit 1
else
echo "$file correctly failed validation"
mv "$tmpfile" "$file"
fi
elif [[ $file == *valid.hery ]]; then
if jv ./.schema/entity.schema.json "$tmpfile"; then
echo "$file correctly passed validation"
mv "$tmpfile" "$file"
else
echo "Error: $file is valid but failed validation"
mv "$tmpfile" "$file"
exit 1
fi
fi
done