Skip to content

Commit 34c5cc4

Browse files
authored
Update format_questions.yml
1 parent 818d664 commit 34c5cc4

File tree

1 file changed

+59
-9
lines changed

1 file changed

+59
-9
lines changed
Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Question Bundles
1+
name: Build & Validate Question Bundles
22

33
on:
44
push:
@@ -7,16 +7,20 @@ on:
77
- 'questions/**'
88
- 'utils/**'
99
- 'schemas/**'
10-
- '.github/workflows/**'
10+
- '.github/workflows/**' # ensure workflow edits retrigger
1111
pull_request:
1212
paths:
1313
- 'questions/**'
1414
- 'utils/**'
1515
- 'schemas/**'
1616
- '.github/workflows/**'
1717

18+
concurrency:
19+
group: build-validate-${{ github.ref }}
20+
cancel-in-progress: true
21+
1822
jobs:
19-
build-only:
23+
format-validate:
2024
runs-on: ubuntu-latest
2125
steps:
2226
- uses: actions/checkout@v4
@@ -31,25 +35,71 @@ jobs:
3135

3236
- name: Install deps
3337
run: |
38+
set -euo pipefail
3439
python -m pip install --upgrade pip
40+
python -m pip install "jsonschema>=4.0,<5"
41+
42+
# ---------- quick sanity: are we running the right validator? ----------
43+
- name: Debug validator presence and contents
44+
run: |
45+
set -euo pipefail
46+
echo "Commit:"; git log -1 --oneline
47+
echo "::group::Search for any other validate_questions.py"
48+
git ls-files | grep -n 'validate_questions.py' || true
49+
echo "::endgroup::"
50+
echo "::group::Show utils/validate_questions.py (first 140 lines)"
51+
nl -ba utils/validate_questions.py | sed -n '1,140p'
52+
echo "::endgroup::"
53+
echo "::group::Check for old SCHEMA line"
54+
if grep -n 'SCHEMA = json.load(open("schemas/question.schema.json"))' -R utils; then
55+
echo "Found stale validator code; please ensure only the new path-robust version exists." >&2
56+
exit 1
57+
else
58+
echo "No stale SCHEMA loader found. Good."
59+
fi
60+
echo "::endgroup::"
61+
62+
# ---------- validate schema file itself, fail early & print context ----------
63+
- name: Validate schema JSON strictly (and print with line numbers)
64+
run: |
65+
set -euo pipefail
66+
echo "::group::schemas/question.schema.json (first 120 lines)"
67+
nl -ba schemas/question.schema.json | sed -n '1,120p' || true
68+
echo "::endgroup::"
69+
echo "Checking schema JSON with python -m json.tool..."
70+
python -m json.tool schemas/question.schema.json >/dev/null
71+
echo "Schema is valid JSON."
3572
3673
# ---------- build ----------
3774
- name: Build bundles into /build
38-
run: python utils/build_bundle.py
75+
run: |
76+
set -euo pipefail
77+
python utils/build_bundle.py
3978
4079
# ---------- verify something was built ----------
4180
- name: Check build outputs exist
4281
run: |
82+
set -euo pipefail
4383
test -d build || { echo "build/ does not exist"; exit 1; }
44-
ls -l build
84+
ls -l build || true
4585
shopt -s nullglob
4686
files=(build/*.json)
4787
((${#files[@]})) || { echo "No build/*.json files found"; exit 1; }
4888
49-
# ---------- artifact for debugging ----------
50-
- name: Upload build artifacts
89+
# ---------- validate ----------
90+
# Let the script default to build/*.json internally (safer than a fragile shell glob).
91+
- name: Validate bundles
92+
run: |
93+
set -euo pipefail
94+
python utils/validate_questions.py
95+
96+
# ---------- artifacts for debugging ----------
97+
- name: Upload artifacts (build + schema + validator)
5198
if: always()
5299
uses: actions/upload-artifact@v4
53100
with:
54-
name: question-bundles
55-
path: build/*.json
101+
name: question-bundles-and-schema
102+
path: |
103+
build/*.json
104+
schemas/question.schema.json
105+
utils/validate_questions.py

0 commit comments

Comments
 (0)