From 6ffaf068d6e1044050982a4feddf9f70a413d8d9 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 18 Sep 2025 13:31:05 -0400 Subject: [PATCH 1/6] ENH: allow to test against bids-spec PR schema. --- .github/workflows/validate_datasets.yml | 42 +++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate_datasets.yml b/.github/workflows/validate_datasets.yml index 63b57c509..05de4b692 100644 --- a/.github/workflows/validate_datasets.yml +++ b/.github/workflows/validate_datasets.yml @@ -20,16 +20,47 @@ 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 }} + bids_pr: ${{ steps.find-pr.outputs.pr_number }} + 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: | + # Also check PR description if this is a PR + if [ "${{ github.event_name }}" == "pull_request" ]; then + 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) + [ -n "$PR_BODY_NUM" ] && echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT + fi + + - name: Set matrix + id: set-matrix + run: | + EXTRA_ITEM='' + if [ -n "${{ steps.find-pr.outputs.pr_number }}" ]; then + EXTRA_ITEM=', "bids-pr"' + fi + echo 'matrix=["stable", "main", "dev", "legacy"${EXTRA_ITEM}' >> $GITHUB_OUTPUT + 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: + BIDS_PR: ${{ needs.prepare-matrix.outputs.bids_pr }} TZ: Europe/Berlin FORCE_COLOR: 1 @@ -65,7 +96,7 @@ jobs: deno install -Agf -n bids-validator jsr:@bids/validator - name: Install BIDS validator (main) - if: matrix.bids-validator == 'main' + if: matrix.bids-validator == 'main' or matrix.bids-validator == 'bids-pr' run: | # If unmerged validator PRs are needed for testing, you can use # https://github.com//bids-validator/raw//bids-validator/src/bids-validator.ts @@ -130,6 +161,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 bids-pr version + if: matrix.bids-validator == 'bids-pr' + # Use the readthedocs PR preview build for the schema + run: | + echo "Using schema from bids-specification PR #${{ env.BIDS_PR }}" + echo BIDS_SCHEMA=https://bids-specification--${{ env.BIDS_PR }}.org.readthedocs.build/en/${{ env.BIDS_PR }}/schema.json >> $GITHUB_ENV + - name: Validate all BIDS datasets using bids-validator run: | cat ./run_tests.sh From 9f499028a01197defcaf8bda48ee499d41539fca Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 18 Sep 2025 13:39:00 -0400 Subject: [PATCH 2/6] Add rudimentary pull_requests_template.md with syntax to list bids-specification-pr --- .github/pull_request_template.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..31758c080 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,12 @@ + + +- Needs testing against a bids-specification-pr: NUMBER-or-URL +- TODOs: + - [ ] ... + + + +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. + From 3f3e71e6376d5b76105bd422cb7d5878e827c159 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 18 Sep 2025 13:43:27 -0400 Subject: [PATCH 3/6] CI: trigger workflow on PR description edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow validate_datasets workflow to re-run when PR description is edited, enabling dynamic detection of bids-specification-pr references added after PR creation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/validate_datasets.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate_datasets.yml b/.github/workflows/validate_datasets.yml index 05de4b692..3e2a77303 100644 --- a/.github/workflows/validate_datasets.yml +++ b/.github/workflows/validate_datasets.yml @@ -4,6 +4,7 @@ on: push: branches: ['**'] pull_request: + types: [opened, synchronize, reopened, edited] branches: ['**'] create: branches: [master] From b83dbe57a5072532feee70fc7326e0ef58bc756f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 18 Sep 2025 14:02:12 -0400 Subject: [PATCH 4/6] CI: fix workflow syntax errors for bids-pr matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix missing closing bracket in matrix JSON output - Fix variable name mismatch (PR_BODY_NUM vs PR_NUM) - Fix regex pattern for PR detection (escape sequences) - Fix bash conditional syntax (use || instead of 'or') 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/validate_datasets.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate_datasets.yml b/.github/workflows/validate_datasets.yml index 3e2a77303..10ffd3d5e 100644 --- a/.github/workflows/validate_datasets.yml +++ b/.github/workflows/validate_datasets.yml @@ -37,8 +37,8 @@ jobs: run: | # Also check PR description if this is a PR if [ "${{ github.event_name }}" == "pull_request" ]; then - 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) - [ -n "$PR_BODY_NUM" ] && echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT + 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]+' | head -1 || true) + [ -n "$PR_NUM" ] && echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT fi - name: Set matrix @@ -48,7 +48,7 @@ jobs: if [ -n "${{ steps.find-pr.outputs.pr_number }}" ]; then EXTRA_ITEM=', "bids-pr"' fi - echo 'matrix=["stable", "main", "dev", "legacy"${EXTRA_ITEM}' >> $GITHUB_OUTPUT + echo "matrix=[\"stable\", \"main\", \"dev\", \"legacy\"${EXTRA_ITEM}]" >> $GITHUB_OUTPUT build: needs: prepare-matrix @@ -97,7 +97,7 @@ jobs: deno install -Agf -n bids-validator jsr:@bids/validator - name: Install BIDS validator (main) - if: matrix.bids-validator == 'main' or matrix.bids-validator == 'bids-pr' + if: matrix.bids-validator == 'main' || matrix.bids-validator == 'bids-pr' run: | # If unmerged validator PRs are needed for testing, you can use # https://github.com//bids-validator/raw//bids-validator/src/bids-validator.ts From b065cf0ce476286784d69a1e62713975ef545142 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 18 Sep 2025 14:06:38 -0400 Subject: [PATCH 5/6] CI: fix PR body parsing to handle special characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use heredoc to safely handle PR body content that may contain: - Quotes (single and double) - Newlines and multiline text - Special bash characters 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/validate_datasets.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate_datasets.yml b/.github/workflows/validate_datasets.yml index 10ffd3d5e..a4e2cc22f 100644 --- a/.github/workflows/validate_datasets.yml +++ b/.github/workflows/validate_datasets.yml @@ -35,9 +35,12 @@ jobs: - name: Check for bids-specification PR reference id: find-pr run: | - # Also check PR description if this is a PR + # Check PR description if this is a PR if [ "${{ github.event_name }}" == "pull_request" ]; then - 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]+' | head -1 || true) + cat << 'EOF' > /tmp/pr_body.txt + ${{ github.event.pull_request.body }} + EOF + PR_NUM=$(grep -oP 'bids-specification-pr:\s*(https://github\.com/bids-standard/bids-specification/pulls?/)*\K[0-9]+' /tmp/pr_body.txt | head -1 || true) [ -n "$PR_NUM" ] && echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT fi From 6f613fc3b16d809ce4a8d004532aa909fe5d7a8e Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 18 Sep 2025 14:07:44 -0400 Subject: [PATCH 6/6] noop if no match --- .github/workflows/validate_datasets.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate_datasets.yml b/.github/workflows/validate_datasets.yml index a4e2cc22f..2337fc8ef 100644 --- a/.github/workflows/validate_datasets.yml +++ b/.github/workflows/validate_datasets.yml @@ -41,7 +41,7 @@ jobs: ${{ github.event.pull_request.body }} EOF PR_NUM=$(grep -oP 'bids-specification-pr:\s*(https://github\.com/bids-standard/bids-specification/pulls?/)*\K[0-9]+' /tmp/pr_body.txt | head -1 || true) - [ -n "$PR_NUM" ] && echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT + [ -n "$PR_NUM" ] && echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT || : fi - name: Set matrix