Skip to content

Commit 09df87f

Browse files
authored
Merge pull request #435 from yarikoptic/deno-validator
Add "master-deno" flavor of validator to use as well
2 parents 12ee355 + 4e04a68 commit 09df87f

File tree

2 files changed

+66
-10
lines changed

2 files changed

+66
-10
lines changed

.github/workflows/validate_datasets.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
platform: [ubuntu-latest, macos-latest, windows-latest]
24-
bids-validator: [master, stable]
24+
bids-validator: [master, stable, master-deno]
2525

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

@@ -33,6 +33,7 @@ jobs:
3333
- uses: actions/checkout@v4
3434

3535
- name: Set up Node.js
36+
if: "matrix.bids-validator == 'stable' || matrix.bids-validator == 'master'"
3637
uses: actions/setup-node@v4
3738
with:
3839
node-version: 18
@@ -60,13 +61,32 @@ jobs:
6061
bash -c "npm install -g bids-validator-*.tgz"
6162
popd
6263
64+
- uses: denoland/setup-deno@v1
65+
if: "matrix.bids-validator == 'master-deno'"
66+
with:
67+
deno-version: v1.x
68+
69+
- name: Install BIDS validator (master deno build)
70+
if: "matrix.bids-validator == 'master-deno'"
71+
run: |
72+
LOCAL_BIN=$HOME/.local/bin
73+
VALIDATOR=$LOCAL_BIN/bids-validator
74+
mkdir -p $LOCAL_BIN
75+
export PATH="$LOCAL_BIN:$PATH"
76+
echo PATH="$PATH" >> $GITHUB_ENV
77+
echo -e '#!/usr/bin/env'" -S deno run --allow-read --allow-write --allow-env --allow-net --allow-run\nimport 'https://github.com/bids-standard/bids-validator/raw/master/bids-validator/src/bids-validator.ts'" > $VALIDATOR
78+
chmod +x $VALIDATOR
79+
bids-validator --version
80+
shell: bash
81+
6382
- name: Display versions and environment information
6483
run: |
6584
echo $TZ
6685
date
6786
echo "npm"; npm --version
6887
echo "node"; node --version
6988
echo "bids-validator"; bids-validator --version
89+
shell: bash
7090

7191
- name: Check that no large files are present
7292
if: "matrix.bids-validator == 'stable'"
@@ -83,6 +103,12 @@ jobs:
83103
fi
84104
shell: bash
85105

106+
- name: Mark to be skipped some examples for a deno based
107+
if: "matrix.bids-validator == 'master-deno'"
108+
run: |
109+
touch {ds000117,ds000246,ds000247,ds000248,eeg_ds003645s_hed_demo,ieeg_motorMiller2007,ieeg_visual,7t_trt,ds102,fnirs_automaticity,genetics_ukbb,ieeg_epilepsy,ieeg_epilepsyNWB}/.SKIP_VALIDATION
110+
shell: bash
111+
86112
- name: Validate all BIDS datasets using bids-validator
87113
run: |
88114
cat ./run_tests.sh

run_tests.sh

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
#!/usr/bin/env bash
22

3-
rc=0;
3+
failed=
4+
5+
which bids-validator
6+
if bids-validator --help | grep -q -e '--config'; then
7+
VALIDATOR_SUPPORTS_CONFIG=yes
8+
else
9+
VALIDATOR_SUPPORTS_CONFIG=
10+
fi
11+
412
for i in $(ls -d */ | grep -v node_modules); do
5-
echo "Validating dataset" $i
13+
echo -n "Validating dataset $i: "
614

715
if [ -f ${i%%/}/.SKIP_VALIDATION ]; then
8-
echo "Skipping validation for ${i%%/}"
16+
echo "skipping validation"
917
continue
1018
fi
1119

@@ -14,18 +22,40 @@ for i in $(ls -d */ | grep -v node_modules); do
1422
CMD="bids-validator ${i%%/} $VALIDATOR_ARGS"
1523

1624
# Use default configuration unless overridden
17-
if [ ! -f ${i%%/}/.bids-validator-config.json ]; then
18-
CMD="$CMD -c $PWD/bidsconfig.json"
25+
if [ -n "$VALIDATOR_SUPPORTS_CONFIG" ]; then
26+
if [ ! -f ${i%%/}/.bids-validator-config.json ]; then
27+
CMD="$CMD -c $PWD/bidsconfig.json"
28+
fi
29+
else
30+
# with new one we do not have config so let's get --json and exclude some using jq
31+
CMD="$CMD --json"
1932
fi
2033

2134
# Ignore NIfTI headers except for synthetic dataset
2235
if [ $i != "synthetic/" ]; then
2336
CMD="$CMD --ignoreNiftiHeaders"
2437
else
25-
echo "Validating NIfTI headers for dataset" $i
38+
echo "validating NIfTI headers. "
2639
fi
2740

28-
echo $CMD
29-
$CMD || rc=$?
41+
echo "Running " $CMD
42+
43+
if [ -n "$VALIDATOR_SUPPORTS_CONFIG" ]; then
44+
$CMD || failed+=" $i"
45+
else
46+
# exit code is not returned correctly anyways and for the best since we need to ignore
47+
# ref: https://github.com/bids-standard/bids-validator/issues/1909
48+
# NOTE: limit to 1 file per error to not flood screen!
49+
errors=$($CMD 2>/dev/null \
50+
| jq '(.issues | map(select(.severity == "error" and .key != "EMPTY_FILE"))) | map(.files_1 = (.files | if length > 0 then .[0:1] else empty end) | del(.files)) | if length > 0 then . else empty end' \
51+
)
52+
if [ -n "$errors" ]; then
53+
echo -e "$errors" | sed -e 's,^, ,g'
54+
failed+=" $i"
55+
fi
56+
fi
3057
done
31-
exit $rc;
58+
if [ -n "$failed" ]; then
59+
echo "Datasets failed validation: $failed"
60+
exit 1
61+
fi

0 commit comments

Comments
 (0)