@@ -2,14 +2,14 @@ name: validate_datasets
22
33on :
44 push :
5- branches : ['**']
5+ branches : [master, main]
6+ tags : ['*']
67 pull_request :
7- branches : ['**']
8- create :
9- branches : [master]
10- tags : ['**']
8+ types : [opened, synchronize, reopened, edited]
9+ branches : [master, main, 'bep*']
1110 schedule :
1211 - cron : " 0 4 * * 1"
12+ workflow_dispatch :
1313
1414concurrency :
1515 group : ${{ github.ref }}
@@ -20,25 +20,63 @@ defaults:
2020 shell : bash
2121
2222jobs :
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+ spec_pr : ${{ steps.find-pr.outputs.spec_pr }}
29+ val_pr : ${{ steps.find-pr.outputs.val_pr }}
30+ steps :
31+ - uses : actions/checkout@v5
32+ with :
33+ fetch-depth : 0 # Get full history for commit message scanning
34+
35+ - name : Check for bids-specification PR reference
36+ id : find-pr
37+ run : |
38+ # Check PR description if this is a PR
39+ if [ "${{ github.event_name }}" == "pull_request" ]; then
40+ cat << 'EOF' > /tmp/pr_body.txt
41+ ${{ github.event.pull_request.body }}
42+ EOF
43+ SPEC_PR=$(grep -oP 'BIDS Specification PR:\s*(https://github\.com/bids-standard/bids-specification/pulls?/|bids-standard/bids-specification#)*\K[0-9]+' /tmp/pr_body.txt | head -1 || true)
44+ [ -n "$SPEC_PR" ] && echo "spec_pr=$SPEC_PR" >> $GITHUB_OUTPUT || :
45+ VAL_PR=$(grep -oP 'BIDS Validator PR:\s*(https://github\.com/bids-standard/bids-validator/pulls?/|bids-standard/bids-validator#)*\K[0-9]+' /tmp/pr_body.txt | head -1 || true)
46+ [ -n "$VAL_PR" ] && echo "val_pr=$VAL_PR" >> $GITHUB_OUTPUT || :
47+ fi
48+
49+ - name : Set matrix
50+ id : set-matrix
51+ run : |
52+ EXTRA_ITEM=''
53+ if [ -n "${{ steps.find-pr.outputs.spec_pr }}${{ steps.find-pr.outputs.val_pr }}" ]; then
54+ EXTRA_ITEM=', "dev-prs"'
55+ fi
56+ echo "matrix=[\"stable\", \"main\", \"dev\", \"legacy\"${EXTRA_ITEM}]" >> $GITHUB_OUTPUT
57+
2358 build :
59+ needs : prepare-matrix
2460 strategy :
2561 fail-fast : false
2662 matrix :
2763 platform : [ubuntu-latest, macos-latest, windows-latest]
28- bids-validator : [stable, main, dev, legacy]
64+ bids-validator : ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
2965
3066 runs-on : ${{ matrix.platform }}
3167
3268 env :
69+ SPEC_PR : ${{ needs.prepare-matrix.outputs.spec_pr }}
70+ VAL_PR : ${{ needs.prepare-matrix.outputs.val_pr }}
3371 TZ : Europe/Berlin
3472 FORCE_COLOR : 1
3573
3674 steps :
37- - uses : actions/checkout@v5
75+ - uses : actions/checkout@v6
3876
3977 - name : Set up Node.js
4078 if : matrix.bids-validator == 'legacy'
41- uses : actions/setup-node@v4
79+ uses : actions/setup-node@v6
4280 with :
4381 node-version : 22
4482
4987
5088 - name : Load npm cache
5189 if : matrix.bids-validator == 'legacy'
52- uses : actions/cache@v4
90+ uses : actions/cache@v5
5391 with :
5492 path : ~/.npm
5593 key : npm-${{ runner.os }}-${{ env.MONTH }}
72110 deno install -Agf https://github.com/bids-standard/bids-validator/raw/deno-build/bids-validator.js
73111
74112 - name : Install BIDS validator (dev)
75- if : matrix.bids-validator == 'dev'
113+ if : ( matrix.bids-validator == 'dev' ) || ( matrix.bids-validator == 'dev-prs' && env.VAL_PR == '' )
76114 run : |
77115 git clone -b dev https://github.com/bids-standard/bids-validator/ ../bids-validator
78116 cd ../bids-validator
@@ -83,6 +121,25 @@ jobs:
83121 run : |
84122 npm install -g bids-validator
85123
124+ - name : Install BIDS validator (dev-prs with VAL_PR)
125+ if : matrix.bids-validator == 'dev-prs' && env.VAL_PR != ''
126+ shell : bash
127+ env :
128+ GH_TOKEN : ${{ github.token }}
129+ run : |
130+ # Fetch PR info using gh cli (handles auth automatically)
131+ fork_url=$(gh api repos/bids-standard/bids-validator/pulls/${{ env.VAL_PR }} --jq '.head.repo.html_url')
132+ branch=$(gh api repos/bids-standard/bids-validator/pulls/${{ env.VAL_PR }} --jq '.head.ref')
133+ echo "I: Received fork_url=$fork_url branch=$branch"
134+ if [ "$fork_url" = "null" ] || [ -z "$fork_url" ]; then
135+ echo "E: Failed to get PR info for VAL_PR=${{ env.VAL_PR }}"
136+ exit 1
137+ fi
138+ # Perform the same installation as in "dev"
139+ git clone -b "$branch" "$fork_url" ../bids-validator
140+ cd ../bids-validator
141+ deno compile -A -o $HOME/.deno/bin/bids-validator src/bids-validator.ts
142+
86143 - name : Display versions and environment information
87144 run : |
88145 echo $TZ
96153 if : " matrix.bids-validator == 'stable'"
97154 run : |
98155 echo "Checking for big files ..."
99- found=`find . -not -path "./.git*" -type f -size +500k `
156+ found=`find . -not -path "./.git*" -type f -size +1M `
100157 if [ "$found" == "" ]
101158 then
102159 echo "No big files present, great!"
@@ -107,7 +164,7 @@ jobs:
107164 fi
108165
109166 - name : Skip legacy validation for post-legacy datasets
110- run : for DS in mrs_* dwi_deriv pet006 pheno004 volume_timing; do touch $DS/.SKIP_VALIDATION; done
167+ run : for DS in mrs_* dwi_deriv pet006 pheno004 volume_timing atlas-* ; do touch $DS/.SKIP_VALIDATION; done
111168 if : matrix.bids-validator == 'legacy'
112169
113170 - name : Skip stable validation for datasets with unreleased validator features
@@ -119,7 +176,7 @@ jobs:
119176 - name : Skip main validation for datasets with unreleased spec features
120177 # Replace ${EMPTY} with dataset patterns, when this is needed
121178 # Reset to "for DS in ${EMPTY}; ..." after a spec release
122- run : for DS in dwi_deriv pheno004 ; do touch $DS/.SKIP_VALIDATION; done
179+ run : for DS in atlas-* emg_* ; do touch $DS/.SKIP_VALIDATION; done
123180 if : matrix.bids-validator != 'dev'
124181
125182 - name : Set BIDS_SCHEMA variable for dev version
@@ -130,6 +187,13 @@ jobs:
130187 # release of https://jsr.io/@bids/schema
131188 run : echo BIDS_SCHEMA=https://bids-specification.readthedocs.io/en/latest/schema.json >> $GITHUB_ENV
132189
190+ - name : Set BIDS_SCHEMA variable for dev-prs version
191+ if : matrix.bids-validator == 'dev-prs' && env.SPEC_PR != ''
192+ # Use the readthedocs PR preview build for the schema
193+ run : |
194+ echo "Using schema from bids-specification PR #${{ env.SPEC_PR }}"
195+ echo BIDS_SCHEMA=https://bids-specification--${{ env.SPEC_PR }}.org.readthedocs.build/en/${{ env.SPEC_PR }}/schema.json >> $GITHUB_ENV
196+
133197 - name : Validate all BIDS datasets using bids-validator
134198 run : |
135199 cat ./run_tests.sh
0 commit comments