Skip to content

Commit

Permalink
Run bids-validator
Browse files Browse the repository at this point in the history
To test:

- set up a gitea install at ../gitea/ and run `./start` (if elsewhere, run `GITEA_APP_PATH=path/to/gitea ./start`)
- make a repo in it; upload some git-annex (or not git-annex) files
- commit and push to the test repo
  • Loading branch information
kousu committed Feb 25, 2023
1 parent 0598331 commit b1f1094
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions worker
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
set -o nounset -o pipefail
trap 'exit 3' ERR

(exec 1>&2
date
Expand All @@ -12,13 +11,62 @@ BH_UUID=${BH_UUID}
EOF
)

GITEA_REPO="$GITEA_REPOSITORY_ROOT"/"${BH_USER}"/"${BH_REPO}".git
#echo $GITEA_REPO #DEBUG

sleep 5

cat <<"EOF"
<!DOCTYPE html>
<html lang=en>
<title>a title</title>
<p>a paragraph
<p>a paragraph</p>
<pre>
EOF

(
WORKDIR="$(mktemp -d --tmpdir bids-hook."$BH_UUID".XXXXXXXXXXX)"
cd "$WORKDIR"

#git clone "$GITEA_REPO" dataset && cd dataset # this is standard but clones a full copy of the repo which might be expensive
#git clone -b "${BH_COMMIT}" --depth 1 "$GITEA_REPO" dataset && cd dataset # this doesn't work unless BH_COMMIT is a branch name
# this is more complicated but it allows to us to --depth 1 with branches OR commit IDs:
(mkdir dataset && cd dataset && git init && git remote add origin "$GITEA_REPO" && git fetch --depth 1 origin "${BH_COMMIT}")
#trap 'echo -n "cleaning "; pwd; chmod -R +w "$WORKDIR" && rm -rf "$WORKDIR"' EXIT
(
cd dataset
git checkout "$BH_COMMIT"
set -e

if git ls-remote --exit-code "$GITEA_REPO" "refs/heads/git-annex" >/dev/null; then
ANNEXED=1
else
ANNEXED=""
fi

if [ -n "$ANNEXED" ]; then
set -x
# this reduces copies; always overrides annex.hardlink even if that is set system-wide
git config annex.thin true
# make sure we don't corrupt origin accidentally
git config remote.origin.annex-readonly true
git config annex.private true # XXX this doesn't do anything until git-annex 10
git annex init
git annex dead here # this is like annex.private, but has to be run
git annex sync --only-annex --no-content # grab the git-annex branch (since we did a shallow clone above)
git annex copy --from origin # NB: using copy --from origin and not git annex get to ensure we're validating the contents of origin and not any special remotes
else
set -x
fi

bids-validator --verbose .
)
) 2>&1
R=$?

cat <<"EOF"
</pre>
</html>
EOF

exit 0
exit $R

0 comments on commit b1f1094

Please sign in to comment.