Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- New examples often relate to in-progress changes to the specification or validator. Link to the relevant PRs, if any. -->

- BIDS Specification PR: NONE
- BIDS Validator PR: NONE
- TODOs:
- [ ] ...

<!-- PLEASE READ AND DELETE THE TEXT BELOW BEFORE OPENING THE PULL REQUEST -->

See the [CONTRIBUTING](https://github.com/bids-standard/bids-examples/blob/master/CONTRIBUTING.md) guide. Specifically:

- Please keep the title of your Pull Request (PR) short but informative - it will appear in the changelog.

69 changes: 67 additions & 2 deletions .github/workflows/validate_datasets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches: ['**']
pull_request:
types: [opened, synchronize, reopened, edited]
branches: ['**']
create:
branches: [master]
Expand All @@ -21,16 +22,54 @@ defaults:
shell: bash

jobs:
# Prepare the matrix dynamically based on whether a bids-specification PR is referenced
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
spec_pr: ${{ steps.find-pr.outputs.spec_pr }}
val_pr: ${{ steps.find-pr.outputs.val_pr }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Get full history for commit message scanning

- name: Check for bids-specification PR reference
id: find-pr
run: |
# Check PR description if this is a PR
if [ "${{ github.event_name }}" == "pull_request" ]; then
cat << 'EOF' > /tmp/pr_body.txt
${{ github.event.pull_request.body }}
EOF
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)
[ -n "$SPEC_PR" ] && echo "spec_pr=$SPEC_PR" >> $GITHUB_OUTPUT || :
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)
[ -n "$VAL_PR" ] && echo "val_pr=$VAL_PR" >> $GITHUB_OUTPUT || :
fi

- name: Set matrix
id: set-matrix
run: |
EXTRA_ITEM=''
if [ -n "${{ steps.find-pr.outputs.spec_pr }}${{ steps.find-pr.outputs.val_pr }}" ]; then
EXTRA_ITEM=', "dev-prs"'
fi
echo "matrix=[\"stable\", \"main\", \"dev\", \"legacy\"${EXTRA_ITEM}]" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would either deactivate dev or just update dev steps to use your environment variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to collide the two making it to change meaning of a CI run? "explicit better than implicit", so I would have just added one dedicated run so if dev passes somehow -- should alert people if they expect non-released bids-specification to fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I called it dev-prs now to reflect the fact that we still use dev version of validator even if no PR is given for it.


build:
needs: prepare-matrix
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
bids-validator: [stable, main, dev, legacy]
bids-validator: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}

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

env:
SPEC_PR: ${{ needs.prepare-matrix.outputs.spec_pr }}
VAL_PR: ${{ needs.prepare-matrix.outputs.val_pr }}
TZ: Europe/Berlin
FORCE_COLOR: 1

Expand Down Expand Up @@ -73,7 +112,7 @@ jobs:
deno install -Agf https://github.com/bids-standard/bids-validator/raw/deno-build/bids-validator.js

- name: Install BIDS validator (dev)
if: matrix.bids-validator == 'dev'
if: ( matrix.bids-validator == 'dev' ) || ( matrix.bids-validator == 'dev-prs' && env.VAL_PR == '' )
run: |
git clone -b dev https://github.com/bids-standard/bids-validator/ ../bids-validator
cd ../bids-validator
Expand All @@ -84,6 +123,25 @@ jobs:
run: |
npm install -g bids-validator

- name: Install BIDS validator (dev-prs with VAL_PR)
if: matrix.bids-validator == 'dev-prs' && env.VAL_PR != ''
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
# Fetch PR info using gh cli (handles auth automatically)
fork_url=$(gh api repos/bids-standard/bids-validator/pulls/${{ env.VAL_PR }} --jq '.head.repo.html_url')
branch=$(gh api repos/bids-standard/bids-validator/pulls/${{ env.VAL_PR }} --jq '.head.ref')
echo "I: Received fork_url=$fork_url branch=$branch"
if [ "$fork_url" = "null" ] || [ -z "$fork_url" ]; then
echo "E: Failed to get PR info for VAL_PR=${{ env.VAL_PR }}"
exit 1
fi
# Perform the same installation as in "dev"
git clone -b "$branch" "$fork_url" ../bids-validator
cd ../bids-validator
deno compile -A -o $HOME/.deno/bin/bids-validator src/bids-validator.ts

- name: Display versions and environment information
run: |
echo $TZ
Expand Down Expand Up @@ -131,6 +189,13 @@ jobs:
# release of https://jsr.io/@bids/schema
run: echo BIDS_SCHEMA=https://bids-specification.readthedocs.io/en/latest/schema.json >> $GITHUB_ENV

- name: Set BIDS_SCHEMA variable for dev-prs version
if: matrix.bids-validator == 'dev-prs' && env.SPEC_PR != ''
# Use the readthedocs PR preview build for the schema
run: |
echo "Using schema from bids-specification PR #${{ env.SPEC_PR }}"
echo BIDS_SCHEMA=https://bids-specification--${{ env.SPEC_PR }}.org.readthedocs.build/en/${{ env.SPEC_PR }}/schema.json >> $GITHUB_ENV

- name: Validate all BIDS datasets using bids-validator
run: |
cat ./run_tests.sh
Expand Down