Skip to content

Commit

Permalink
Merge pull request #21 from blackskad/test-coverage
Browse files Browse the repository at this point in the history
Export code coverage in github actions
  • Loading branch information
blackskad authored Aug 30, 2024
2 parents 1837840 + d043806 commit 0dd4146
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ concurrency:
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
pull-requests: write
steps:
- name: Detect version
run: |-
Expand All @@ -31,11 +35,20 @@ jobs:
- name: Running tests
uses: docker/build-push-action@v6
with:
target: test
push: false
target: coverage
outputs: type=local,dest=coverage/
build-args: |
VERSION=${{ env.VERSION }}
- name: Archive code coverage results
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: code-coverage-report
path: |
coverage/coverage.out
coverage/coverage.html
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.ref_type == 'tag'
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ COPY pkg/ ./pkg
FROM base AS test

RUN go vet -v ./...
RUN go test -v ./...
RUN go test -race -v -coverprofile=cover.out -covermode=atomic ./...
RUN go tool cover -html cover.out -o cover.html

FROM scratch AS coverage

COPY --from=test /work/cover.html coverage.html
COPY --from=test /work/cover.out coverage.out

# Stage to build the binary
FROM base AS build
Expand Down

0 comments on commit 0dd4146

Please sign in to comment.