diff --git a/go/exam/Dockerfile b/go/exam/Dockerfile new file mode 100644 index 000000000..f68e02b89 --- /dev/null +++ b/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"] diff --git a/go/exam/entrypoint.sh b/go/exam/entrypoint.sh new file mode 100755 index 000000000..562ffb12e --- /dev/null +++ b/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}" "$@"