-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (45 loc) · 1.38 KB
/
validate-schemas.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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