Skip to content

Commit f0cff92

Browse files
committed
Improve JSON checks
Check formatting for all JSON files including the schema. Improve check.sh with error details. Update JQ to fix big integer parsing with Ubuntu 22.04: diff -u ./schema/landlockconfig.json <(jq < ./schema/landlockconfig.json) --- ./schema/landlockconfig.json +++ /dev/fd/63 @@ -11,7 +11,7 @@ "uint64": { "type": "integer", "minimum": 0, - "maximum": 18446744073709551615 + "maximum": 18446744073709552000 }, "file": { "anyOf": [ See jqlang/jq#1752 Signed-off-by: Mickaël Salaün <[email protected]>
1 parent c4f21b4 commit f0cff92

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
outputs:
4545
commits: ${{ toJSON(steps.*.outputs.*) }}
4646

47-
ubuntu_22_schema:
47+
ubuntu_22_json:
4848
runs-on: ubuntu-22.04
4949
needs: commit_list
5050
strategy:
@@ -60,7 +60,15 @@ jobs:
6060
- name: Install check-jsonschema
6161
run: pipx install check-jsonschema
6262

63-
- name: Check JSON schema
63+
- name: Update jq
64+
run: |
65+
sudo apt update
66+
sudo apt install jq
67+
68+
- name: Check schema format
69+
run: diff -u ./schema/landlockconfig.json <(jq < ./schema/landlockconfig.json)
70+
71+
- name: Check JSON
6472
run: ./schema/check.sh examples/mini-write-tmp.json
6573

6674
ubuntu_22_rust_msrv:

schema/check.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,26 @@ set -u -e -o pipefail
44

55
BASE_DIR=$(dirname "${BASH_SOURCE[0]}")
66

7-
check-jsonschema --schemafile "${BASE_DIR}/landlockconfig.json" "$@"
7+
if [[ $# -eq 0 ]]; then
8+
echo "ERROR: No files to check" >&2
9+
exit 1
10+
fi
11+
12+
for file in "$@"; do
13+
if [[ ! -r "${file}" ]]; then
14+
echo "ERROR: Invalid file: ${file}" >&2
15+
exit 1
16+
fi
17+
18+
diff -u "${file}" <(jq < "${file}") || {
19+
echo
20+
echo "ERROR: Invalid formatting" >&2
21+
exit 1
22+
}
23+
24+
check-jsonschema --schemafile "${BASE_DIR}/landlockconfig.json" "${file}" || {
25+
echo
26+
echo "ERROR: Not validated by schema: ${file}" >&2
27+
exit 1
28+
}
29+
done

0 commit comments

Comments
 (0)