From bc99a33fa6359b8e5f8e4298debf3a4ba0c95b36 Mon Sep 17 00:00:00 2001 From: Heathcliff Date: Sun, 14 Jul 2024 10:27:06 +0200 Subject: [PATCH] CI: Move unit-tests from Dockerfile to separate workflow job Signed-off-by: Heathcliff --- .github/workflows/ci.yaml | 4 ++++ Dockerfile | 19 +------------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2c5c4b6..7df5c54 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,10 +20,14 @@ jobs: lint: uses: heathcliff26/ci/.github/workflows/golang-lint.yaml@main + unit-tests: + uses: heathcliff26/ci/.github/workflows/golang-unit-tests.yaml@main + build: uses: heathcliff26/ci/.github/workflows/build-container.yaml@main needs: - lint + - unit-tests permissions: contents: read packages: write diff --git a/Dockerfile b/Dockerfile index 49040b1..d75eea0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,23 +19,6 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" go build -ldflags="-w -s" -o # END build-stage ############################################################################### -############################################################################### -# BEGIN test-stage -# Run the tests in the container -FROM docker.io/library/golang:1.22.5@sha256:829eff99a4b2abffe68f6a3847337bf6455d69d17e49ec1a97dac78834754bd6 AS test-stage - -WORKDIR /app - -COPY --from=build-stage /app /app -# Not needed for testing, but needed for later stage -COPY --from=build-stage /simple-fileserver / - -RUN go test -v ./... - -# -# END test-stage -############################################################################### - ############################################################################### # BEGIN final-stage # Create final docker image @@ -43,7 +26,7 @@ FROM scratch AS final-stage WORKDIR / -COPY --from=test-stage /simple-fileserver / +COPY --from=build-stage /simple-fileserver / EXPOSE 8080