-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (65 loc) · 2.45 KB
/
schema-tests.yml
File metadata and controls
77 lines (65 loc) · 2.45 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Schema Validation Tests
on:
push:
branches: [main]
paths:
- "integration-manifest-schema.json"
- "schema-tests/**"
pull_request:
branches: [main]
paths:
- "integration-manifest-schema.json"
- "schema-tests/**"
permissions:
contents: read # Read-only access to repository contents for checkout and validation
jobs:
validate-schema-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install AJV CLI
run: npm install -g ajv-cli
- name: Check schema against test cases
run: |
PASS=1
echo "::group::Test known good manifests"
for file in schema-tests/pass/*.json; do
if [ -f "$file" ]; then
#echo "Testing $file (should pass)..."
if ajv test --spec=draft2020 --valid -s integration-manifest-schema.json -d "$file" --errors=text; then
echo "✅ $file passed validation (expected)" >> $GITHUB_STEP_SUMMARY
else
echo "❌ $file failed validation (unexpected)" >> $GITHUB_STEP_SUMMARY
echo "::error file=$file::Validation failed for $file, but it was expected to pass."
PASS=0
fi
fi
done
echo "::endgroup::"
echo "::group::Test known bad manifests"
echo "Testing that invalid manifests fail validation..."
for file in schema-tests/fail/*.json; do
if [ -f "$file" ]; then
#echo "Testing $file (should fail)..."
if ajv test --spec=draft2020 --invalid -s integration-manifest-schema.json -d "$file" --errors=text; then
echo "✅ $file failed validation (expected)" >> $GITHUB_STEP_SUMMARY
else
echo "❌ $file passed validation (unexpected)" >> $GITHUB_STEP_SUMMARY
echo "::error file=$file::Validation passed for $file, but it was expected to fail."
PASS=0
fi
fi
done
echo "::endgroup::"
if [ $PASS -eq 1 ]; then
echo "::notice::All schema validation tests passed successfully!"
else
echo "::error::Some schema validation tests failed. Please review the results above."
exit 1
fi
shell: bash