Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Move unit-tests from Dockerfile to separate workflow job #31

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 1 addition & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,14 @@ 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
FROM scratch AS final-stage

WORKDIR /

COPY --from=test-stage /simple-fileserver /
COPY --from=build-stage /simple-fileserver /

EXPOSE 8080

Expand Down