Skip to content

Commit

Permalink
Move coverage reports over to bazel
Browse files Browse the repository at this point in the history
coverage reports were the last part where we had to compile kubevirt
with pure go-code. With this change it is possible to remove
"libvirt-devel" from the builder image. Now no build/test dependencies
are installedin the build-image which can get out of sync with bazel.

Signed-off-by: Roman Mohr <[email protected]>
  • Loading branch information
rmohr committed Oct 2, 2020
1 parent b0a2f90 commit ac1b7b1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
15 changes: 15 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,18 @@ genrule(
cmd = "echo '#!/bin/sh\n\ncp $(SRCS) $$1' > \"$@\"",
executable = 1,
)

filegroup(
name = "coverage_files",
srcs = glob(["bazel-out/k8-fastbuild/testlogs/**/coverage.dat"]),
)

genrule(
name = "goveralls",
srcs = [
":coverage_files",
],
outs = ["bazel-goveralls"],
cmd = "echo '#!/bin/sh\n\necho $(SRCS) | hack/goveralls.sh' > \"$@\"",
executable = 1,
)
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ go-build:
coverage:
hack/dockerized "./hack/coverage.sh ${WHAT}"

goveralls: go-build
SYNC_OUT=false hack/dockerized "COVERALLS_TOKEN_FILE=${COVERALLS_TOKEN_FILE} COVERALLS_TOKEN=${COVERALLS_TOKEN} CI_NAME=prow CI_BRANCH=${PULL_REFS} CI_PR_NUMBER=${PULL_NUMBER} ./hack/goveralls.sh"
goveralls:
SYNC_OUT=false hack/dockerized "COVERALLS_TOKEN_FILE=${COVERALLS_TOKEN_FILE} COVERALLS_TOKEN=${COVERALLS_TOKEN} CI_NAME=prow CI_BRANCH=${PULL_REFS} CI_PR_NUMBER=${PULL_NUMBER} ./hack/bazel-goveralls.sh"

go-test: go-build
SYNC_OUT=false hack/dockerized "./hack/build-go.sh test ${WHAT}"
Expand Down Expand Up @@ -175,4 +175,6 @@ bump-kubevirtci:
cluster-sync \
olm-verify \
olm-push \
coverage \
goveralls \
build-functests
5 changes: 5 additions & 0 deletions hack/bazel-goveralls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e

./hack/coverage.sh
bazel run :goveralls
13 changes: 4 additions & 9 deletions hack/coverage.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#!/usr/bin/env bash

set -e

source hack/common.sh

path="./pkg/... ./vendor/kubevirt.io/client-go/..."
coverpkg="../kubevirt/pkg/...,../kubevirt/vendor/kubevirt.io/client-go/..."
profile=.coverprofile

go test -cover -covermode=atomic -coverpkg="${coverpkg}" -v -coverprofile=${profile}.tmp ${path}
cat ${profile}.tmp | grep -v generated >${profile}
go tool cover -html=$profile -o ${OUT_DIR}/coverage.html
rm -f ${profile}.tmp
bazel coverage \
--config=${ARCHITECTURE} \
--stamp \
--test_output=errors -- //staging/src/kubevirt.io/client-go/... //pkg/... //cmd/...
6 changes: 3 additions & 3 deletions hack/goveralls.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail

set -e
coverprofiles=$(cat | sed "s/ /,/g")

./hack/coverage.sh
goveralls -v -debug -service=${CI_NAME} -coverprofile=.coverprofile -ignore=$(find -regextype posix-egrep -regex ".*generated_mock.*\.go|.*swagger_generated\.go|.*openapi_generated\.go" -printf "%P\n" | paste -d, -s)
goveralls -v -debug -service=${CI_NAME} -coverprofile=${coverprofiles} -ignore=$(find -regextype posix-egrep -regex ".*generated_mock.*\.go|.*swagger_generated\.go|.*openapi_generated\.go" -printf "%P\n" | paste -d, -s)

0 comments on commit ac1b7b1

Please sign in to comment.