-
Notifications
You must be signed in to change notification settings - Fork 147
172 lines (150 loc) · 6.56 KB
/
validate_datasets.yml
File metadata and controls
172 lines (150 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: validate_datasets
on:
push:
branches: [master, main]
tags: ['*']
pull_request:
types: [opened, synchronize, reopened, edited]
branches: [master, main, 'bep*']
schedule:
- cron: "0 4 * * 1"
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
defaults:
run:
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@v6
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\"${EXTRA_ITEM}]" >> $GITHUB_OUTPUT
build:
needs: prepare-matrix
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
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
steps:
- uses: actions/checkout@v6
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Install BIDS validator (stable)
if: matrix.bids-validator == 'stable'
run: |
deno install -Agf -n bids-validator jsr:@bids/validator
- name: Install BIDS validator (main)
if: matrix.bids-validator == 'main'
run: |
# If unmerged validator PRs are needed for testing, you can use
# https://github.com/<FORK>/bids-validator/raw/<BRANCH>/bids-validator/src/bids-validator.ts
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' ) || ( 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
deno compile -A -o $HOME/.deno/bin/bids-validator src/bids-validator.ts
- 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
date
which deno && echo "deno\n----" && deno --version || true
echo "node\n----"; node --version
echo "npm\n----"; npm --version
echo "bids-validator"; bids-validator --version
- name: Check that no large files are present
if: "matrix.bids-validator == 'stable'"
run: |
echo "Checking for big files ..."
found=`find . -not -path "./.git*" -type f -size +1M`
if [ "$found" == "" ]
then
echo "No big files present, great!"
else
echo "Found big files:"
echo "$found"
exit 1;
fi
- name: Skip stable validation for datasets with unreleased validator features
# Replace ${EMPTY} with dataset patterns, when this is needed
# Reset to "for DS in ${EMPTY}; ..." after a validator release
run: for DS in ${EMPTY}; do touch $DS/.SKIP_VALIDATION; done
if: matrix.bids-validator == 'stable'
- name: Skip main validation for datasets with unreleased spec features
# Replace ${EMPTY} with dataset patterns, when this is needed
# Reset to "for DS in ${EMPTY}; ..." after a spec release
run: for DS in ${EMPTY}; do touch $DS/.SKIP_VALIDATION; done
if: matrix.bids-validator != 'dev'
- name: Set BIDS_SCHEMA variable for dev version
if: matrix.bids-validator == 'dev'
# When proposing new features, schema changes may be necessary.
# Update this URL to the schema.json from PRs to the spec, when needed.
# If this variable is unset, dev will generally track the latest development
# 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
./run_tests.sh