ci: run junit report from branches

JUnit reports are useful for merge requests
so it is generate only from commits to branches
other than master.

This solves the issue where the code coverage was missing
from the badge and no testing logs are shown in the console
output.

Also fixed (hopefully) is the deployment of the coverage
report to my GitLab pages site.
This commit is contained in:
Dan Anglin 2020-01-18 01:48:27 +00:00
parent 5fd24b80df
commit e4df5bfb8e
No known key found for this signature in database
GPG key ID: 7AC2B18EC1D09F27
2 changed files with 23 additions and 7 deletions

View file

@ -6,19 +6,33 @@ stages:
variables: variables:
CGO_ENABLED: 0 CGO_ENABLED: 0
test:unit: test:junit:
artifacts: artifacts:
expire_in: 30 minutes expire_in: 1 hour
paths:
- code-coverage.html
reports: reports:
junit: junit:
report.xml report.xml
before_script: before_script:
- apk add --no-cache make - apk add --no-cache make
- go get -u github.com/jstemmer/go-junit-report - go get -u github.com/jstemmer/go-junit-report
except:
- master
image: golang:1.13.6-alpine image: golang:1.13.6-alpine
script: script:
- make test_junit_report
stage: test
test:unit:
artifacts:
expire_in: 30 minutes
paths:
- code-coverage.html
before_script:
- apk add --no-cache make
image: golang:1.13.6-alpine
only:
- master@dananglin/pominal
script:
- make test_cover_report - make test_cover_report
stage: test stage: test
@ -30,8 +44,7 @@ pages:
dependencies: dependencies:
- test:unit - test:unit
only: only:
refs: - master@dananglin/pominal
- master@dananglin/pominal
script: script:
- mkdir public - mkdir public
- mv code-coverage.html public - mv code-coverage.html public

View file

@ -6,8 +6,11 @@ BIN_FILE := $(BIN_DIR)/$(NAME)
all: test_unit build all: test_unit build
test_junit_report:
@go test -v . 2>&1 | go-junit-report > report.xml
test_unit: test_unit:
@go test -v -coverprofile=cover.out . 2>&1 | go-junit-report > report.xml @go test -v -coverprofile=cover.out .
test_cover_report: test_unit test_cover_report: test_unit
@go tool cover -html=cover.out -o code-coverage.html @go tool cover -html=cover.out -o code-coverage.html