Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation fixes #111

Merged
merged 12 commits into from
Jul 29, 2022
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN go build ./cmd/ginvalid
### ============================ ###

# RUNNER IMAGE
FROM alpine:3.14
FROM alpine:3.16

# Runtime deps
RUN echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories
Expand All @@ -43,9 +43,8 @@ RUN apk --no-cache --no-progress add \
py3-tomli \
py3-pip \
python3-dev \
py3-lxml \
py3-h5py \
py3-numpy
py3-numpy \
py3-h5py

# Install the BIDS validator
RUN npm install -g bids-validator
Expand All @@ -63,8 +62,7 @@ COPY ./scripts/odml-validate /bin
COPY ./resources /resources

# Install NIXPy for NIX validation
# Use master branch until new beta is released
RUN pip3 install --no-cache-dir -U git+https://github.com/G-Node/nixpy@master
RUN pip3 install --no-cache-dir nixio

# Copy git-annex from builder image
COPY --from=binbuilder /git-annex /git-annex
Expand All @@ -86,7 +84,6 @@ COPY ./assets /assets

# Test validation
RUN odml-validate /resources/odmldata.odml
RUN nixio -h
RUN nixio validate /resources/nixdata.nix
RUN bids-validator --version

Expand Down
17 changes: 17 additions & 0 deletions internal/web/ginutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/user"
"path/filepath"
Expand Down Expand Up @@ -494,3 +495,19 @@ func remoteCommitCheckout(gitdir, hash string) error {
}
return nil
}

// getRepoCommit uses a gin client connection to query the latest commit
// of a provided gin repository and returns either an error or
// the commit hash as a string.
func getRepoCommit(client *ginclient.Client, repo string) (string, error) {
reqpath := fmt.Sprintf("api/v1/repos/%s/commits/refs/heads/master", repo)
resp, err := client.Get(reqpath)
if err != nil {
return "", fmt.Errorf("failed to get latest commit hash for %q: %s", repo, err.Error())
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("failed to read latest commit hash from response for %q: %s", repo, err.Error())
}
return string(data), nil
}
Loading