From e1278db547019af44104e2c4057a637afb0f5ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=81=A3?= <⁣> Date: Sat, 23 May 2020 22:16:08 +0200 Subject: [PATCH] update to the simplified way --- go/tests/Dockerfile | 12 ++++-------- go/tests/entrypoint | 15 ++------------- sh/tests/Dockerfile | 4 ++-- sh/tests/entrypoint | 17 +---------------- 4 files changed, 9 insertions(+), 39 deletions(-) mode change 100644 => 100755 go/tests/entrypoint diff --git a/go/tests/Dockerfile b/go/tests/Dockerfile index 5fffa20f..d9e816a6 100644 --- a/go/tests/Dockerfile +++ b/go/tests/Dockerfile @@ -1,19 +1,15 @@ FROM golang:1-alpine -ENV GIT_TERMINAL_PROMPT=0 RUN apk add --no-cache git nano RUN go get golang.org/x/tools/cmd/goimports RUN go get github.com/01-edu/z01 WORKDIR src -COPY entrypoint.sh /usr/local/bin COPY . . -RUN go install rc -RUN find -mindepth 2 -maxdepth 2 -name '*_correct' -type d|xargs go install -RUN find -mindepth 2 -maxdepth 2 -name '*_correct' -type d|cut -d/ -f1-2|xargs go install +COPY entrypoint /usr/local/bin +RUN go install -trimpath -ldflags="-s -w" rc +RUN find -mindepth 2 -maxdepth 2 -name '*_correct' -type d|xargs go install -trimpath -ldflags="-s -w" +RUN find -mindepth 2 -maxdepth 2 -name '*_correct' -type d|cut -d/ -f1-2|xargs go install -trimpath -ldflags="-s -w" RUN find -mindepth 2 -maxdepth 2 -name '*_correct' -type d|cut -d/ -f1-2|xargs rm -rf -WORKDIR /tmp -USER 1000 -ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"] # compare performance with and without : # ENV CGO_ENABLED 0 # -trimpath -ldflags="-s -w" diff --git a/go/tests/entrypoint b/go/tests/entrypoint old mode 100644 new mode 100755 index 4ce5bad2..0f0eac99 --- a/go/tests/entrypoint +++ b/go/tests/entrypoint @@ -6,21 +6,10 @@ set -o nounset IFS=' ' -mkdir -p src/student +mkdir src +mv student src cd src/student -if test "$REPOSITORY"; then - password=$(cat) - if ! git clone --depth=1 --shallow-submodules http://root:"${password}"@"$REPOSITORY" . 2>/dev/null; then - echo Could not clone your repository - exit 1 - fi -else - first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1) - mkdir "$(dirname $first_file)" - cat > "$first_file" -fi - # Check formatting s=$(goimports -d .) if test "$s"; then diff --git a/sh/tests/Dockerfile b/sh/tests/Dockerfile index 63f5fd32..2e5e7280 100644 --- a/sh/tests/Dockerfile +++ b/sh/tests/Dockerfile @@ -1,6 +1,6 @@ FROM debian:stable-slim RUN apt-get update -RUN apt-get -y install jq curl git +RUN apt-get -y install --no-install-recommends jq curl git COPY . /app -ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"] +COPY entrypoint /usr/local/bin diff --git a/sh/tests/entrypoint b/sh/tests/entrypoint index f7313310..c629894f 100755 --- a/sh/tests/entrypoint +++ b/sh/tests/entrypoint @@ -5,26 +5,11 @@ set -euo pipefail IFS=' ' -mkdir student -cd student - -if test "$REPOSITORY"; then - password=$(cat) - if ! git clone --depth=1 --shallow-submodules http://root:"${password}"@"$REPOSITORY" . 2>/dev/null; then - echo Could not clone your repository - exit 1 - fi -else - first_file=$(echo "$EXPECTED_FILES" | cut -d' ' -f1) - mkdir "$(dirname $first_file)" - cat > "$first_file" -fi - -cd cp -rT /app . if ! test -f ${EXERCISE}_test.sh; then echo No test file found for the exercise : "$EXERCISE" exit 1 fi + bash ${EXERCISE}_test.sh