This repository has been archived by the owner on Mar 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hack: containerize unit test (#1723)
- Loading branch information
1 parent
0fd48c2
commit 0095267
Showing
5 changed files
with
45 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ cleanup() { | |
|
||
trap cleanup EXIT | ||
|
||
|
||
./hack/update_vendor.sh 1>/dev/null | ||
|
||
GIT_VERSION=$(git rev-parse HEAD) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function listPkgs() { | ||
go list ./cmd/... ./pkg/... ./test/... | grep -v generated | ||
} | ||
|
||
function listFiles() { | ||
# pipeline is much faster than for loop | ||
listPkgs | xargs -I {} find "${GOPATH}/src/{}" -name '*.go' | grep -v generated | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
source "hack/lib/test_lib.sh" | ||
|
||
# coverage.txt is the combined coverage report consumed by codecov | ||
echo "mode: atomic" > coverage.txt | ||
|
||
TEST_PKGS=$(listPkgs | grep -v e2e) | ||
for pkg in $TEST_PKGS | ||
do | ||
build_flags=("-i") # cache package compilation data for faster repeated builds | ||
for i in {1..2}; do | ||
go test ${build_flags[@]} -race -covermode=atomic -coverprofile=profile.out $pkg | ||
# Expand empty array would cause "unbound variable". | ||
# Expand one empty string array is equal to nothing. | ||
build_flags=("") | ||
done | ||
if [ -f profile.out ]; then | ||
tail -n +2 profile.out >> coverage.txt | ||
rm profile.out | ||
fi | ||
done | ||
|
||
# Send reports to codecov, CODECOV_TOKEN env must be present in Jenkins | ||
(curl -s https://codecov.io/bash | bash) || true |