Skip to content

Commit 15cb2e2

Browse files
committed
ci(validate): scope data checkout to data changes
1 parent 13ca948 commit 15cb2e2

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

.github/workflows/validate-data.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,38 @@ jobs:
2020
- uses: actions/checkout@v4
2121
with:
2222
# The committed Pages dump contains over a million generated files.
23-
# Validation only needs records and the bundled validator.
23+
# Start with the validator and its tests. Data is added only when
24+
# the pull request actually changes a record.
2425
sparse-checkout: |
26+
.github
2527
app
26-
data
28+
tests
2729
sparse-checkout-cone-mode: true
2830
- uses: actions/setup-python@v5
2931
with:
3032
python-version: "3.12"
33+
- name: Select validation scope
34+
id: scope
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
shell: bash
38+
run: |
39+
if [[ "${{ github.event_name }}" == "push" ]]; then
40+
echo "scope=full" >> "$GITHUB_OUTPUT"
41+
elif gh api --paginate "repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }}/files" --jq '.[].filename' | grep -q '^data/'; then
42+
echo "scope=full" >> "$GITHUB_OUTPUT"
43+
else
44+
echo "scope=tests" >> "$GITHUB_OUTPUT"
45+
fi
3146
- name: Self-check (bundled validator)
32-
run: python -m app.validate
47+
shell: bash
48+
run: |
49+
if [[ "${{ steps.scope.outputs.scope }}" == "full" ]]; then
50+
git sparse-checkout add data
51+
python -m app.validate
52+
else
53+
python -m unittest discover -s tests -v
54+
fi
3355
3456
engine-validate:
3557
needs: self-validate

0 commit comments

Comments
 (0)