ci(test): send coverage to codecov
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
4c8af0e2f9
commit
807c849431
5 changed files with 41 additions and 6 deletions
23
.github/workflows/test.yml
vendored
23
.github/workflows/test.yml
vendored
|
@ -89,6 +89,13 @@ jobs:
|
|||
tar -xzf /tmp/reports.tar.gz -C /tmp/reports
|
||||
sudo chown -R $(id -u):$(id -g) /tmp/reports
|
||||
tree -nh /tmp/reports
|
||||
-
|
||||
name: Send to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
directory: ./bundles
|
||||
env_vars: RUNNER_OS
|
||||
flags: unit
|
||||
-
|
||||
name: Upload reports
|
||||
if: always()
|
||||
|
@ -222,6 +229,7 @@ jobs:
|
|||
make -o build test-integration
|
||||
env:
|
||||
TEST_SKIP_INTEGRATION_CLI: 1
|
||||
TESTCOVERAGE: 1
|
||||
-
|
||||
name: Prepare reports
|
||||
if: always()
|
||||
|
@ -235,6 +243,13 @@ jobs:
|
|||
tar -xzf /tmp/reports.tar.gz -C $reportsPath
|
||||
sudo chown -R $(id -u):$(id -g) $reportsPath
|
||||
tree -nh $reportsPath
|
||||
-
|
||||
name: Send to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
directory: ./bundles/test-integration
|
||||
env_vars: RUNNER_OS
|
||||
flags: integration,${{ matrix.mode }}
|
||||
-
|
||||
name: Test daemon logs
|
||||
if: always()
|
||||
|
@ -312,6 +327,7 @@ jobs:
|
|||
make -o build test-integration
|
||||
env:
|
||||
TEST_SKIP_INTEGRATION: 1
|
||||
TESTCOVERAGE: 1
|
||||
TESTFLAGS: "-test.run (${{ matrix.test }})/"
|
||||
-
|
||||
name: Prepare reports
|
||||
|
@ -324,6 +340,13 @@ jobs:
|
|||
tar -xzf /tmp/reports.tar.gz -C $reportsPath
|
||||
sudo chown -R $(id -u):$(id -g) $reportsPath
|
||||
tree -nh $reportsPath
|
||||
-
|
||||
name: Send to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
directory: ./bundles/test-integration
|
||||
env_vars: RUNNER_OS
|
||||
flags: integration-cli
|
||||
-
|
||||
name: Test daemon logs
|
||||
if: always()
|
||||
|
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
|
@ -234,7 +234,7 @@ pipeline {
|
|||
sh '''
|
||||
bundleName=unit
|
||||
echo "Creating ${bundleName}-bundles.tar.gz"
|
||||
tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report*.xml bundles/go-test-report*.json bundles/profile*.out
|
||||
tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report*.xml bundles/go-test-report*.json bundles/coverage*.out
|
||||
'''
|
||||
|
||||
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
|
||||
|
|
1
Makefile
1
Makefile
|
@ -74,6 +74,7 @@ DOCKER_ENVS := \
|
|||
-e TEST_INTEGRATION_DIR \
|
||||
-e TEST_SKIP_INTEGRATION \
|
||||
-e TEST_SKIP_INTEGRATION_CLI \
|
||||
-e TESTCOVERAGE \
|
||||
-e TESTDEBUG \
|
||||
-e TESTDIRS \
|
||||
-e TESTFLAGS \
|
||||
|
|
|
@ -16,6 +16,7 @@ source "${MAKEDIR}/.go-autogen"
|
|||
: "${TEST_REPEAT:=1}"
|
||||
: "${TESTFLAGS:=}"
|
||||
: "${TESTDEBUG:=}"
|
||||
: "${TESTCOVERAGE:=}"
|
||||
: "${GOCACHE:=$(go env GOCACHE)}"
|
||||
|
||||
setup_integration_test_filter() {
|
||||
|
@ -80,7 +81,13 @@ run_test_integration_suites() {
|
|||
# Finally, we use periods as separator (instead of slashes) to be more
|
||||
# in line with Java package names (which is what junit.xml was designed for)
|
||||
pkgname="$(go env GOARCH).${pkgname//\//.}"
|
||||
echo "Running $PWD (${pkgname}) flags=${flags}"
|
||||
|
||||
pkgtestflags=$flags
|
||||
if [ -n "${TESTCOVERAGE}" ]; then
|
||||
pkgtestflags="$pkgtestflags -test.coverprofile=${ABS_DEST}/${pkgname//./-}-coverage.out"
|
||||
fi
|
||||
|
||||
echo "Running $PWD (${pkgname}) flags=${pkgtestflags}"
|
||||
[ -n "$TESTDEBUG" ] && set -x
|
||||
# shellcheck disable=SC2086
|
||||
test_env gotestsum \
|
||||
|
@ -88,7 +95,7 @@ run_test_integration_suites() {
|
|||
--jsonfile="${ABS_DEST}/${pkgname//./-}-go-test-report.json" \
|
||||
--junitfile="${ABS_DEST}/${pkgname//./-}-junit-report.xml" \
|
||||
--raw-command \
|
||||
-- go tool test2json -p "${pkgname}" -t ./test.main ${flags}
|
||||
-- go tool test2json -p "${pkgname}" -t ./test.main ${pkgtestflags}
|
||||
); then exit 1; fi
|
||||
done
|
||||
}
|
||||
|
@ -112,8 +119,12 @@ build_test_suite_binaries() {
|
|||
build_test_suite_binary() {
|
||||
local dir="$1"
|
||||
local out="$2"
|
||||
local testflags
|
||||
echo Building test suite binary "$dir/$out"
|
||||
go test -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "$dir"
|
||||
if [ -n "${TESTCOVERAGE}" ]; then
|
||||
testflags="-cover -covermode=atomic"
|
||||
fi
|
||||
go test ${testflags} -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "$dir"
|
||||
}
|
||||
|
||||
cleanup_test_suite_binaries() {
|
||||
|
|
|
@ -32,7 +32,7 @@ if [ -n "${base_pkg_list}" ]; then
|
|||
gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report.json --junitfile=bundles/junit-report.xml -- \
|
||||
"${BUILDFLAGS[@]}" \
|
||||
-cover \
|
||||
-coverprofile=bundles/profile.out \
|
||||
-coverprofile=bundles/coverage.out \
|
||||
-covermode=atomic \
|
||||
${TESTFLAGS} \
|
||||
${base_pkg_list}
|
||||
|
@ -44,7 +44,7 @@ if [ -n "${libnetwork_pkg_list}" ]; then
|
|||
gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report-libnetwork.json --junitfile=bundles/junit-report-libnetwork.xml -- \
|
||||
"${BUILDFLAGS[@]}" \
|
||||
-cover \
|
||||
-coverprofile=bundles/profile-libnetwork.out \
|
||||
-coverprofile=bundles/coverage-libnetwork.out \
|
||||
-covermode=atomic \
|
||||
-p=1 \
|
||||
${TESTFLAGS} \
|
||||
|
|
Loading…
Reference in a new issue