TUN-7447: Add a cover build to report code coverage
This commit is contained in:
parent
867360c8dd
commit
58b27a1ccf
12
Makefile
12
Makefile
|
@ -140,6 +140,7 @@ container:
|
||||||
generate-docker-version:
|
generate-docker-version:
|
||||||
echo latest $(VERSION) > versions
|
echo latest $(VERSION) > versions
|
||||||
|
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: vet
|
test: vet
|
||||||
ifndef CI
|
ifndef CI
|
||||||
|
@ -147,9 +148,18 @@ ifndef CI
|
||||||
else
|
else
|
||||||
@mkdir -p .cover
|
@mkdir -p .cover
|
||||||
go test -v -mod=vendor -race $(LDFLAGS) -coverprofile=".cover/c.out" ./...
|
go test -v -mod=vendor -race $(LDFLAGS) -coverprofile=".cover/c.out" ./...
|
||||||
go tool cover -html ".cover/c.out" -o .cover/all.html
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
.PHONY: cover
|
||||||
|
cover:
|
||||||
|
@echo ""
|
||||||
|
@echo "=====> Total test coverage: <====="
|
||||||
|
@echo ""
|
||||||
|
# Print the overall coverage here for quick access.
|
||||||
|
$Q go tool cover -func ".cover/c.out" | grep "total:" | awk '{print $$3}'
|
||||||
|
# Generate the HTML report that can be viewed from the browser in CI.
|
||||||
|
$Q go tool cover -html ".cover/c.out" -o .cover/all.html
|
||||||
|
|
||||||
.PHONY: test-ssh-server
|
.PHONY: test-ssh-server
|
||||||
test-ssh-server:
|
test-ssh-server:
|
||||||
docker-compose -f ssh_server_tests/docker-compose.yml up
|
docker-compose -f ssh_server_tests/docker-compose.yml up
|
||||||
|
|
|
@ -29,6 +29,12 @@ buster: &buster
|
||||||
- export GOARCH=amd64
|
- export GOARCH=amd64
|
||||||
- export FIPS=true
|
- export FIPS=true
|
||||||
- make cloudflared
|
- make cloudflared
|
||||||
|
cover:
|
||||||
|
build_dir: *build_dir
|
||||||
|
builddeps: *build_deps
|
||||||
|
pre-cache: *build_pre_cache
|
||||||
|
post-cache:
|
||||||
|
- make cover
|
||||||
# except FIPS (handled in github-fips-release-pkgs) and macos (handled in github-release-macos-amd64)
|
# except FIPS (handled in github-fips-release-pkgs) and macos (handled in github-release-macos-amd64)
|
||||||
github-release-pkgs:
|
github-release-pkgs:
|
||||||
build_dir: *build_dir
|
build_dir: *build_dir
|
||||||
|
|
Loading…
Reference in New Issue