Skip to content

Commit

Permalink
test: Add coverage output
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-crone committed Aug 12, 2020
1 parent e2bb97a commit c6a65bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
run: make lint
- name: Run unit tests
run: make unit-test
- name: Get unit test coverage
run: make unit-test-coverage
- name: Build Linux binary
run: make PLATFORM=linux/amd64
- name: Build Windows binary
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax = docker/dockerfile:1-experimental

FROM --platform=${BUILDPLATFORM} golang:1.14.3-alpine AS base
FROM --platform=${BUILDPLATFORM} golang:1.15.0-alpine AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* .
Expand All @@ -16,7 +16,7 @@ RUN --mount=target=. \
FROM base AS unit-test
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
go test -v .
mkdir /out && go test -v -coverprofile=/out/cover.out ./...

FROM golangci/golangci-lint:v1.27-alpine AS lint-base

Expand All @@ -27,6 +27,9 @@ RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/golangci-lint \
golangci-lint run --timeout 10m0s ./...

FROM scratch AS unit-test-coverage
COPY --from=unit-test /out/cover.out /cover.out

FROM scratch AS bin-unix
COPY --from=build /out/example /

Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ bin/example:
unit-test:
@docker build . --target unit-test

.PHONY: unit-test-coverage
unit-test-coverage:
@docker build . --target unit-test-coverage \
--output coverage/
cat coverage/cover.out

.PHONY: lint
lint:
@docker build . --target lint

0 comments on commit c6a65bc

Please sign in to comment.