-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add github validation workflows
- Loading branch information
1 parent
88e25b6
commit 4e6940c
Showing
5 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: [ 'main' ] | ||
paths-ignore: | ||
- '**.md' # Don't run CI on markdown changes. | ||
pull_request: | ||
branches: [ 'main', 'feat/**' ] | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
lints: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Validate JSON Formatting | ||
run: | | ||
./scripts/ci/format-json.sh | ||
git diff-index --quiet HEAD -- | ||
- name: Validate JSON schemas | ||
run: | | ||
./scripts/ci/validate-json-schemas.sh | ||
- name: Validate all SDKs are represented in data files | ||
run: | | ||
./scripts/ci/sdk-consistency.sh |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
mapfile -t schemas < <(git grep -Fl 'https://json-schema.org' '**/*.json') | ||
|
||
function runTest() { | ||
primary=$(realpath --relative-to="$(pwd)" "$1") | ||
|
||
# Build up a list of reference schemas to use, being careful to ignore the | ||
# schema under test. If we don't skip that one, ajv will generate an error | ||
# about duplicate $ids. | ||
ajvFlags=() | ||
for schema in "${schemas[@]}"; do | ||
if [[ "$schema" != "$primary" ]]; then | ||
ajvFlags+=(-r "${schema}") | ||
fi | ||
done | ||
|
||
npx --package=ajv-cli --package=ajv-formats ajv validate --spec=draft2020 -s "$primary" "${ajvFlags[@]}" -d "$2" | ||
} | ||
|
||
runTest ./schemas/features.json ./data/features.json | ||
runTest ./schemas/types.json ./data/types.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Checks that for each SDK ID defined in sdks.json, all other files have an entry for that ID. | ||
# If not, outputs a diff containing the missing IDs and exits with a non-zero status. | ||
|
||
cleanup() { | ||
rm ./data/*.json.keys | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
jq -r 'values[]' ./data/sdks.json | sort > ./data/sdks.json.keys | ||
|
||
for file in ./data/*.json; do | ||
# Skip sdks.json itself | ||
if [ "$file" == "./data/sdks.json" ]; then | ||
continue | ||
fi | ||
jq -r 'keys[]' "$file" | sort > "$file.keys" | ||
if diff -q sdks.json.keys "$file.keys" > /dev/null; then | ||
echo "$file is consistent" | ||
else | ||
echo "$file is missing some SDK IDs:" | ||
diff ./data/sdks.json.keys "$file.keys" | ||
exit 1 | ||
fi | ||
done |