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. + diff --git a/.github/workflows/validate_datasets.yml b/.github/workflows/validate_datasets.yml index 63b57c509..2337fc8ef 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] @@ -20,16 +21,50 @@ 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: | + # 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 + 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 + + - 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 +100,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' || 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 +165,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