Skip to content

Commit 0c41c8b

Browse files
chore: add schema-latest pattern (#1792)
1 parent c196d3a commit 0c41c8b

File tree

4 files changed

+1211
-0
lines changed

4 files changed

+1211
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# Change to the working directory where the schema files are located
4+
cd source/unified-test-format || {
5+
echo "Directory source/unified-test-format not found."
6+
exit 1
7+
}
8+
9+
# Find the max X in schema-1.X.json
10+
max=0
11+
for file in schema-1.*.json; do
12+
# Extract the version number from the filename
13+
version=${file##*schema-1.}
14+
version=${version%.json}
15+
16+
if [[ $version =~ ^[0-9]+$ ]]; then
17+
# Compare the version number with the current max
18+
if ((version > max)); then
19+
max=$version
20+
fi
21+
fi
22+
done
23+
24+
if ((max == 0)); then
25+
echo "No schema files found."
26+
exit 1
27+
fi
28+
29+
# Compare that file vs schema-latest.json
30+
expected="schema-1.$max.json"
31+
if ! diff -u "$expected" schema-latest.json >/dev/null; then
32+
echo "schema-latest.json is not up to date with schema-1.$max.json"
33+
echo "please run 'make update-schema-latest' from source/ to update it"
34+
exit 1
35+
fi
36+
37+
exit 0

.github/workflows/unified-test-format-schema-check.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
run: make
2929
- name: Check all unified tests schema version is valid
3030
run: bash .github/workflows/check_schema_version.sh
31+
- name: Check schema-latest.json has been updated
32+
run: bash .github/workflows/check-schema-latest.sh

source/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,16 @@ HAS_JSYAML:
1717
echo 'Error: need "npm install -g js-yaml"' 1>&2; \
1818
exit 1; \
1919
fi
20+
21+
VERSION := $(shell \
22+
find unified-test-format -maxdepth 1 -type f -name 'schema-1.*.json' \
23+
| sed -E 's:.*/schema-1\.([0-9]+)\.json:\1:' \
24+
| sort -n \
25+
| tail -n1 \
26+
)
27+
28+
.PHONY: update-schema-latest
29+
update-schema-latest:
30+
cp unified-test-format/schema-1.$(VERSION).json \
31+
unified-test-format/schema-latest.json
32+

0 commit comments

Comments
 (0)