Skip to content

Commit ae0834e

Browse files
committed
Install if needed custom bids-validator and also adjust installation to use SPEC_PR instead of BIDS_PR var
Also renamed into `dev-prs` to ensure reflecting the fact that we are installing a development version of the validator even if PR for it not given.
1 parent a76de45 commit ae0834e

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

.github/workflows/validate_datasets.yml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ jobs:
2727
runs-on: ubuntu-latest
2828
outputs:
2929
matrix: ${{ steps.set-matrix.outputs.matrix }}
30-
bids_pr: ${{ steps.find-pr.outputs.pr_number }}
30+
spec_pr: ${{ steps.find-pr.outputs.spec_pr }}
31+
val_pr: ${{ steps.find-pr.outputs.val_pr }}
3132
steps:
3233
- uses: actions/checkout@v5
3334
with:
@@ -41,16 +42,18 @@ jobs:
4142
cat << 'EOF' > /tmp/pr_body.txt
4243
${{ github.event.pull_request.body }}
4344
EOF
44-
SPEC_PR_NUM=$(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)
45-
[ -n "$SPEC_PR_NUM" ] && echo "spec_pr_number=$SPEC_PR_NUM" >> $GITHUB_OUTPUT || :
45+
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)
46+
[ -n "$SPEC_PR" ] && echo "spec_pr=$SPEC_PR" >> $GITHUB_OUTPUT || :
47+
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)
48+
[ -n "$VAL_PR" ] && echo "val_pr=$VAL_PR" >> $GITHUB_OUTPUT || :
4649
fi
4750
4851
- name: Set matrix
4952
id: set-matrix
5053
run: |
5154
EXTRA_ITEM=''
52-
if [ -n "${{ steps.find-pr.outputs.spec_pr_number }}" ]; then
53-
EXTRA_ITEM=', "bids-prs"'
55+
if [ -n "${{ steps.find-pr.outputs.spec_pr }}${{ steps.find-pr.outputs.val_pr }}" ]; then
56+
EXTRA_ITEM=', "dev-prs"'
5457
fi
5558
echo "matrix=[\"stable\", \"main\", \"dev\", \"legacy\"${EXTRA_ITEM}]" >> $GITHUB_OUTPUT
5659
@@ -65,7 +68,8 @@ jobs:
6568
runs-on: ${{ matrix.platform }}
6669

6770
env:
68-
BIDS_PR: ${{ needs.prepare-matrix.outputs.bids_pr }}
71+
SPEC_PR: ${{ needs.prepare-matrix.outputs.spec_pr }}
72+
VAL_PR: ${{ needs.prepare-matrix.outputs.val_pr }}
6973
TZ: Europe/Berlin
7074
FORCE_COLOR: 1
7175

@@ -101,14 +105,14 @@ jobs:
101105
deno install -Agf -n bids-validator jsr:@bids/validator
102106
103107
- name: Install BIDS validator (main)
104-
if: matrix.bids-validator == 'main' || matrix.bids-validator == 'bids-prs'
108+
if: matrix.bids-validator == 'main'
105109
run: |
106110
# If unmerged validator PRs are needed for testing, you can use
107111
# https://github.com/<FORK>/bids-validator/raw/<BRANCH>/bids-validator/src/bids-validator.ts
108112
deno install -Agf https://github.com/bids-standard/bids-validator/raw/deno-build/bids-validator.js
109113
110114
- name: Install BIDS validator (dev)
111-
if: matrix.bids-validator == 'dev'
115+
if: ( matrix.bids-validator == 'dev' ) || ( matrix.bids-validator == 'dev-prs' && env.VAL_PR == '' )
112116
run: |
113117
git clone -b dev https://github.com/bids-standard/bids-validator/ ../bids-validator
114118
cd ../bids-validator
@@ -119,6 +123,17 @@ jobs:
119123
run: |
120124
npm install -g bids-validator
121125
126+
- name: Install BIDS validator (dev-prs with VAL_PR)
127+
if: matrix.bids-validator == 'dev-prs' && env.VAL_PR != ''
128+
shell: bash
129+
run: |
130+
# First fetch PR info (fork URL and branch)
131+
mapfile -t pr_info < <(curl -s https://api.github.com/repos/bids-standard/bids-validator/pulls/${{ env.VAL_PR }} | jq -r '.head.repo.html_url, .head.ref')
132+
# Perform the same installation as in "dev"
133+
git clone -b ${pr_info[1]} ${pr_info[0]} ../bids-validator
134+
cd ../bids-validator
135+
deno compile -A -o $HOME/.deno/bin/bids-validator src/bids-validator.ts
136+
122137
- name: Display versions and environment information
123138
run: |
124139
echo $TZ
@@ -166,12 +181,12 @@ jobs:
166181
# release of https://jsr.io/@bids/schema
167182
run: echo BIDS_SCHEMA=https://bids-specification.readthedocs.io/en/latest/schema.json >> $GITHUB_ENV
168183

169-
- name: Set BIDS_SCHEMA variable for bids-prs version
170-
if: matrix.bids-validator == 'bids-prs'
184+
- name: Set BIDS_SCHEMA variable for dev-prs version
185+
if: matrix.bids-validator == 'dev-prs' && env.SPEC_PR != ''
171186
# Use the readthedocs PR preview build for the schema
172187
run: |
173-
echo "Using schema from bids-specification PR #${{ env.BIDS_PR }}"
174-
echo BIDS_SCHEMA=https://bids-specification--${{ env.BIDS_PR }}.org.readthedocs.build/en/${{ env.BIDS_PR }}/schema.json >> $GITHUB_ENV
188+
echo "Using schema from bids-specification PR #${{ env.SPEC_PR }}"
189+
echo BIDS_SCHEMA=https://bids-specification--${{ env.SPEC_PR }}.org.readthedocs.build/en/${{ env.SPEC_PR }}/schema.json >> $GITHUB_ENV
175190
176191
- name: Validate all BIDS datasets using bids-validator
177192
run: |

0 commit comments

Comments
 (0)