Skip to content

Commit 609df30

Browse files
authored
Update format_questions.yml
1 parent a13ddaa commit 609df30

File tree

1 file changed

+57
-10
lines changed

1 file changed

+57
-10
lines changed

.github/workflows/format_questions.yml

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@ on:
77
- 'questions/**'
88
- 'utils/**'
99
- 'schemas/**'
10+
- '.github/workflows/**' # ensure workflow edits retrigger
1011
pull_request:
1112
paths:
1213
- 'questions/**'
1314
- 'utils/**'
1415
- 'schemas/**'
16+
- '.github/workflows/**'
17+
18+
concurrency:
19+
group: build-validate-${{ github.ref }}
20+
cancel-in-progress: true
1521

1622
jobs:
1723
format-validate:
1824
runs-on: ubuntu-latest
1925
steps:
2026
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
2129

2230
- name: Set up Python
2331
uses: actions/setup-python@v5
@@ -27,32 +35,71 @@ jobs:
2735

2836
- name: Install deps
2937
run: |
38+
set -euo pipefail
3039
python -m pip install --upgrade pip
3140
python -m pip install "jsonschema>=4.0,<5"
3241
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."
72+
3373
# ---------- build ----------
3474
- name: Build bundles into /build
35-
run: python utils/build_bundle.py
75+
run: |
76+
set -euo pipefail
77+
python utils/build_bundle.py
3678
37-
# (Optional) verify something was built
79+
# ---------- verify something was built ----------
3880
- name: Check build outputs exist
3981
run: |
82+
set -euo pipefail
4083
test -d build || { echo "build/ does not exist"; exit 1; }
41-
ls -l build
42-
# Fail if no JSONs produced
84+
ls -l build || true
4385
shopt -s nullglob
4486
files=(build/*.json)
4587
((${#files[@]})) || { echo "No build/*.json files found"; exit 1; }
4688
4789
# ---------- validate ----------
48-
# Prefer NO args so your script defaults to build/*.json safely.
90+
# Let the script default to build/*.json internally (safer than a fragile shell glob).
4991
- name: Validate bundles
50-
run: python utils/validate_questions.py
92+
run: |
93+
set -euo pipefail
94+
python utils/validate_questions.py
5195
52-
# ---------- artifact for debugging ----------
53-
- name: Upload build artifacts
96+
# ---------- artifacts for debugging ----------
97+
- name: Upload artifacts (build + schema + validator)
5498
if: always()
5599
uses: actions/upload-artifact@v4
56100
with:
57-
name: question-bundles
58-
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)