Skip to content

Commit 6ffaf06

Browse files
committed
ENH: allow to test against bids-spec PR schema.
1 parent 5060654 commit 6ffaf06

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

.github/workflows/validate_datasets.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,47 @@ defaults:
2020
shell: bash
2121

2222
jobs:
23+
# Prepare the matrix dynamically based on whether a bids-specification PR is referenced
24+
prepare-matrix:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
matrix: ${{ steps.set-matrix.outputs.matrix }}
28+
bids_pr: ${{ steps.find-pr.outputs.pr_number }}
29+
steps:
30+
- uses: actions/checkout@v5
31+
with:
32+
fetch-depth: 0 # Get full history for commit message scanning
33+
34+
- name: Check for bids-specification PR reference
35+
id: find-pr
36+
run: |
37+
# Also check PR description if this is a PR
38+
if [ "${{ github.event_name }}" == "pull_request" ]; then
39+
PR_NUM=$(echo "${{ github.event.pull_request.body }}" | grep -oP 'bids-specification-pr:s*(https://github\.com/bids-standard/bids-specification/pulls/)*K[0-9]+/*' || true)
40+
[ -n "$PR_BODY_NUM" ] && echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT
41+
fi
42+
43+
- name: Set matrix
44+
id: set-matrix
45+
run: |
46+
EXTRA_ITEM=''
47+
if [ -n "${{ steps.find-pr.outputs.pr_number }}" ]; then
48+
EXTRA_ITEM=', "bids-pr"'
49+
fi
50+
echo 'matrix=["stable", "main", "dev", "legacy"${EXTRA_ITEM}' >> $GITHUB_OUTPUT
51+
2352
build:
53+
needs: prepare-matrix
2454
strategy:
2555
fail-fast: false
2656
matrix:
2757
platform: [ubuntu-latest, macos-latest, windows-latest]
28-
bids-validator: [stable, main, dev, legacy]
58+
bids-validator: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
2959

3060
runs-on: ${{ matrix.platform }}
3161

3262
env:
63+
BIDS_PR: ${{ needs.prepare-matrix.outputs.bids_pr }}
3364
TZ: Europe/Berlin
3465
FORCE_COLOR: 1
3566

@@ -65,7 +96,7 @@ jobs:
6596
deno install -Agf -n bids-validator jsr:@bids/validator
6697
6798
- name: Install BIDS validator (main)
68-
if: matrix.bids-validator == 'main'
99+
if: matrix.bids-validator == 'main' or matrix.bids-validator == 'bids-pr'
69100
run: |
70101
# If unmerged validator PRs are needed for testing, you can use
71102
# https://github.com/<FORK>/bids-validator/raw/<BRANCH>/bids-validator/src/bids-validator.ts
@@ -130,6 +161,13 @@ jobs:
130161
# release of https://jsr.io/@bids/schema
131162
run: echo BIDS_SCHEMA=https://bids-specification.readthedocs.io/en/latest/schema.json >> $GITHUB_ENV
132163

164+
- name: Set BIDS_SCHEMA variable for bids-pr version
165+
if: matrix.bids-validator == 'bids-pr'
166+
# Use the readthedocs PR preview build for the schema
167+
run: |
168+
echo "Using schema from bids-specification PR #${{ env.BIDS_PR }}"
169+
echo BIDS_SCHEMA=https://bids-specification--${{ env.BIDS_PR }}.org.readthedocs.build/en/${{ env.BIDS_PR }}/schema.json >> $GITHUB_ENV
170+
133171
- name: Validate all BIDS datasets using bids-validator
134172
run: |
135173
cat ./run_tests.sh

0 commit comments

Comments
 (0)