From c3a7ee0d4f1651ca3d9eea849ea528b9c5731450 Mon Sep 17 00:00:00 2001 From: John Donaldson Date: Fri, 28 Oct 2022 19:27:20 +0000 Subject: [PATCH] Pull XML reporting into its own job, so it still shows up --- .gitlab-ci.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a802f5e..f697f2d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,32 +2,42 @@ stages: - test - push -test: +Run unit tests: stage: test - - image: golang:1.18 + image: &goimage golang:1.18 only: refs: - main - merge_requests script: - go test -coverprofile=coverage.txt -covermode=atomic -race ./... - - go get github.com/boumenot/gocover-cobertura - - go run github.com/boumenot/gocover-cobertura < coverage.txt > coverage.xml - go tool cover -html=coverage.txt -o coverage.html - go tool cover -func coverage.txt coverage: /\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/ + artifacts: + paths: + - coverage.html + - coverage.txt +Generage coverage XML: + stage: test + image: *goimage + needs: ["Run unit tests"] + script: + - go get github.com/boumenot/gocover-cobertura + - go run github.com/boumenot/gocover-cobertura < coverage.txt > coverage.xml + only: + refs: + - main + - merge_requests artifacts: reports: coverage_report: coverage_format: cobertura path: coverage.xml - paths: - - coverage.html - - coverage.txt - - coverage.xml + push: stage: push + needs: ["Run unit tests"] rules: - if: $CI_COMMIT_TAG - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'