Skip to content

Commit 65869d3

Browse files
committed
ci: use local bin and native coverage merge in Makefile
- use binary coverage output for unit tests to enable native merge with integration coverage - install test binary to project-local bin/ instead of using sudo to install to /usr/bin/ - replace external gocovmerge with native 'go tool covdata merge' Signed-off-by: Klara Necasova <knecasov@redhat.com>
1 parent 559f03f commit 65869d3

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPEC_FILE_NAME := $(PROJECT).spec
77
SPEC_FILE := $(SOURCEDIR)/$(SPEC_FILE_NAME)
88
COMMIT_SHORT := $(shell git rev-parse --short HEAD)
99
VERSION := $(shell grep 'Version:' $(SPEC_FILE) | awk '{printf "%s", $$2}').git$(COMMIT_SHORT)
10+
SHELL := /usr/bin/env bash
1011
GOFLAGS ?=
1112
COVERDIR ?= $(CURDIR)/test/coverage
1213
GOCOVERDIR ?= $(COVERDIR)/integration
@@ -42,22 +43,22 @@ test:
4243
go test -v ./...
4344

4445
.PHONY: test-coverage
45-
test-coverage: SHELL := /usr/bin/env bash
4646
test-coverage:
4747
rm -rf "$(COVERDIR)"
48-
mkdir -p "$(GOCOVERDIR)"
49-
go test -coverpkg=./... -coverprofile="$(COVERDIR)/unit.out" -covermode=atomic ./...
48+
mkdir -p "$(COVERDIR)/unit" "$(GOCOVERDIR)" "$(COVERDIR)/merged"
49+
GOCOVERDIR="$(COVERDIR)/unit" go test -coverpkg=./... -covermode=atomic ./...
5050
export GOCOVERDIR="$(GOCOVERDIR)"; \
5151
set -e; \
52-
$(MAKE) build GOFLAGS="-cover -covermode=atomic" && sudo install -D -m 755 $(PROJECT) /usr/bin/; \
52+
$(MAKE) build GOFLAGS="-cover -covermode=atomic" && \
53+
install -D -m 755 $(PROJECT) $(CURDIR)/bin/$(PROJECT); \
54+
export PATH="$(CURDIR)/bin:$$PATH"; \
5355
source .github/scripts/fdo-utils.sh; \
5456
generate_certs; \
5557
docker compose -f .github.qkg1.toppose/servers.yaml up -d --build; \
5658
trap 'docker compose -f .github.qkg1.toppose/servers.yaml logs; docker compose -f .github.qkg1.toppose/servers.yaml down' EXIT; \
57-
test_onboarding; \
58-
go tool covdata textfmt -i="$(GOCOVERDIR)" -o="$(COVERDIR)/integration.out"
59-
go install github.com/wadey/gocovmerge@latest
60-
gocovmerge "$(COVERDIR)/unit.out" "$(COVERDIR)/integration.out" > "$(COVERDIR)/coverage.out"
59+
test_onboarding
60+
go tool covdata merge -i="$(COVERDIR)/unit,$(GOCOVERDIR)" -o="$(COVERDIR)/merged"
61+
go tool covdata textfmt -i="$(COVERDIR)/merged" -o="$(COVERDIR)/coverage.out"
6162
go tool cover -html="$(COVERDIR)/coverage.out" -o "$(COVERDIR)/coverage.html"
6263

6364
.PHONY: vendor-tarball

0 commit comments

Comments
 (0)