Skip to content

Commit 58b27a1

Browse files
TUN-7447: Add a cover build to report code coverage
1 parent 867360c commit 58b27a1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,26 @@ container:
140140
generate-docker-version:
141141
echo latest $(VERSION) > versions
142142

143+
143144
.PHONY: test
144145
test: vet
145146
ifndef CI
146147
go test -v -mod=vendor -race $(LDFLAGS) ./...
147148
else
148149
@mkdir -p .cover
149150
go test -v -mod=vendor -race $(LDFLAGS) -coverprofile=".cover/c.out" ./...
150-
go tool cover -html ".cover/c.out" -o .cover/all.html
151151
endif
152152

153+
.PHONY: cover
154+
cover:
155+
@echo ""
156+
@echo "=====> Total test coverage: <====="
157+
@echo ""
158+
# Print the overall coverage here for quick access.
159+
$Q go tool cover -func ".cover/c.out" | grep "total:" | awk '{print $$3}'
160+
# Generate the HTML report that can be viewed from the browser in CI.
161+
$Q go tool cover -html ".cover/c.out" -o .cover/all.html
162+
153163
.PHONY: test-ssh-server
154164
test-ssh-server:
155165
docker-compose -f ssh_server_tests/docker-compose.yml up

cfsetup.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ buster: &buster
2929
- export GOARCH=amd64
3030
- export FIPS=true
3131
- make cloudflared
32+
cover:
33+
build_dir: *build_dir
34+
builddeps: *build_deps
35+
pre-cache: *build_pre_cache
36+
post-cache:
37+
- make cover
3238
# except FIPS (handled in github-fips-release-pkgs) and macos (handled in github-release-macos-amd64)
3339
github-release-pkgs:
3440
build_dir: *build_dir

0 commit comments

Comments
 (0)