Browse Source

update to the simplified way

content-update
4 years ago committed by xpetit
parent
commit
e1278db547
  1. 12
      go/tests/Dockerfile
  2. 15
      go/tests/entrypoint
  3. 4
      sh/tests/Dockerfile
  4. 17
      sh/tests/entrypoint

12
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"

15
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

4
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

17
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

Loading…
Cancel
Save