Browse Source

Add Go exam image (run with arguments)

pull/663/head
xpetit 4 years ago
parent
commit
b1d683699f
No known key found for this signature in database
GPG Key ID: 97C60669182C17A5
  1. 11
      go/exam/Dockerfile
  2. 32
      go/exam/entrypoint.sh

11
go/exam/Dockerfile

@ -0,0 +1,11 @@
FROM golang:1-alpine
ENV GIT_TERMINAL_PROMPT=0
RUN apk add --no-cache git
RUN go get golang.org/x/tools/cmd/goimports
RUN go get github.com/01-edu/z01
RUN go get github.com/01-edu/public/go/tests/rc
COPY --from=mkcert-ca . /usr/local/share/ca-certificates
RUN update-ca-certificates
COPY entrypoint.sh /usr/local/bin
ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"]

32
go/exam/entrypoint.sh

@ -0,0 +1,32 @@
#!/bin/sh
set -o noglob
set -o errexit
set -o nounset
IFS='
'
mkdir -p src/student
cd src/student
first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1)
mkdir -p "$(dirname "$first_file")"
cat > "$first_file"
# Format code
goimports -w .
# Check restrictions
if test "$ALLOWED_FUNCTIONS" && test "$EXPECTED_FILES"; then
IFS=' '
# shellcheck disable=SC2086
rc "$first_file" $ALLOWED_FUNCTIONS
IFS='
'
fi
cd
# Run program
go build "./src/student/$EXERCISE"
./"${EXERCISE}" "$@"
Loading…
Cancel
Save