Skip to content

Commit

Permalink
Merge pull request #111 from mpsonntag/validationFixes
Browse files Browse the repository at this point in the history
Validation fixes
  • Loading branch information
mpsonntag committed Jul 29, 2022
2 parents 1f2d701 + 01a7e6b commit 127e4a0
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 91 deletions.
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
}

0 comments on commit 127e4a0

Please sign in to comment.