Skip to content

chore: add schema-latest pattern #1792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/check-schema-latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

# Change to the working directory where the schema files are located
cd source/unified-test-format || {
echo "Directory source/unified-test-format not found."
exit 1
}

# Find the max X in schema-1.X.json
max=0
for file in schema-1.*.json; do
# Extract the version number from the filename
version=${file##*schema-1.}
version=${version%.json}

if [[ $version =~ ^[0-9]+$ ]]; then
# Compare the version number with the current max
if ((version > max)); then
max=$version
fi
fi
done

if ((max == 0)); then
echo "No schema files found."
exit 1
fi

# Compare that file vs schema-latest.json
expected="schema-1.$max.json"
if ! diff -u "$expected" schema-latest.json >/dev/null; then
echo "schema-latest.json is not up to date with schema-1.$max.json"
echo "please run 'make update-schema-latest' from source/ to update it"
exit 1
fi

exit 0
2 changes: 2 additions & 0 deletions .github/workflows/unified-test-format-schema-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ jobs:
run: make
- name: Check all unified tests schema version is valid
run: bash .github/workflows/check_schema_version.sh
- name: Check schema-latest.json has been updated
run: bash .github/workflows/check-schema-latest.sh
13 changes: 13 additions & 0 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ HAS_JSYAML:
echo 'Error: need "npm install -g js-yaml"' 1>&2; \
exit 1; \
fi

VERSION := $(shell \
find unified-test-format -maxdepth 1 -type f -name 'schema-1.*.json' \
| sed -E 's:.*/schema-1\.([0-9]+)\.json:\1:' \
| sort -n \
| tail -n1 \
)

.PHONY: update-schema-latest
update-schema-latest:
cp unified-test-format/schema-1.$(VERSION).json \
unified-test-format/schema-latest.json

Loading
Loading