Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
| ... | ... |
@@ -90,6 +90,13 @@ jobs: |
| 90 | 90 |
sudo chown -R $(id -u):$(id -g) /tmp/reports |
| 91 | 91 |
tree -nh /tmp/reports |
| 92 | 92 |
- |
| 93 |
+ name: Send to Codecov |
|
| 94 |
+ uses: codecov/codecov-action@v3 |
|
| 95 |
+ with: |
|
| 96 |
+ directory: ./bundles |
|
| 97 |
+ env_vars: RUNNER_OS |
|
| 98 |
+ flags: unit |
|
| 99 |
+ - |
|
| 93 | 100 |
name: Upload reports |
| 94 | 101 |
if: always() |
| 95 | 102 |
uses: actions/upload-artifact@v3 |
| ... | ... |
@@ -222,6 +229,7 @@ jobs: |
| 222 | 222 |
make -o build test-integration |
| 223 | 223 |
env: |
| 224 | 224 |
TEST_SKIP_INTEGRATION_CLI: 1 |
| 225 |
+ TESTCOVERAGE: 1 |
|
| 225 | 226 |
- |
| 226 | 227 |
name: Prepare reports |
| 227 | 228 |
if: always() |
| ... | ... |
@@ -236,6 +244,13 @@ jobs: |
| 236 | 236 |
sudo chown -R $(id -u):$(id -g) $reportsPath |
| 237 | 237 |
tree -nh $reportsPath |
| 238 | 238 |
- |
| 239 |
+ name: Send to Codecov |
|
| 240 |
+ uses: codecov/codecov-action@v3 |
|
| 241 |
+ with: |
|
| 242 |
+ directory: ./bundles/test-integration |
|
| 243 |
+ env_vars: RUNNER_OS |
|
| 244 |
+ flags: integration,${{ matrix.mode }}
|
|
| 245 |
+ - |
|
| 239 | 246 |
name: Test daemon logs |
| 240 | 247 |
if: always() |
| 241 | 248 |
run: | |
| ... | ... |
@@ -312,6 +327,7 @@ jobs: |
| 312 | 312 |
make -o build test-integration |
| 313 | 313 |
env: |
| 314 | 314 |
TEST_SKIP_INTEGRATION: 1 |
| 315 |
+ TESTCOVERAGE: 1 |
|
| 315 | 316 |
TESTFLAGS: "-test.run (${{ matrix.test }})/"
|
| 316 | 317 |
- |
| 317 | 318 |
name: Prepare reports |
| ... | ... |
@@ -325,6 +341,13 @@ jobs: |
| 325 | 325 |
sudo chown -R $(id -u):$(id -g) $reportsPath |
| 326 | 326 |
tree -nh $reportsPath |
| 327 | 327 |
- |
| 328 |
+ name: Send to Codecov |
|
| 329 |
+ uses: codecov/codecov-action@v3 |
|
| 330 |
+ with: |
|
| 331 |
+ directory: ./bundles/test-integration |
|
| 332 |
+ env_vars: RUNNER_OS |
|
| 333 |
+ flags: integration-cli |
|
| 334 |
+ - |
|
| 328 | 335 |
name: Test daemon logs |
| 329 | 336 |
if: always() |
| 330 | 337 |
run: | |
| ... | ... |
@@ -234,7 +234,7 @@ pipeline {
|
| 234 | 234 |
sh ''' |
| 235 | 235 |
bundleName=unit |
| 236 | 236 |
echo "Creating ${bundleName}-bundles.tar.gz"
|
| 237 |
- tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report*.xml bundles/go-test-report*.json bundles/profile*.out
|
|
| 237 |
+ tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report*.xml bundles/go-test-report*.json bundles/coverage*.out
|
|
| 238 | 238 |
''' |
| 239 | 239 |
|
| 240 | 240 |
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true |
| ... | ... |
@@ -16,6 +16,7 @@ source "${MAKEDIR}/.go-autogen"
|
| 16 | 16 |
: "${TEST_REPEAT:=1}"
|
| 17 | 17 |
: "${TESTFLAGS:=}"
|
| 18 | 18 |
: "${TESTDEBUG:=}"
|
| 19 |
+: "${TESTCOVERAGE:=}"
|
|
| 19 | 20 |
: "${GOCACHE:=$(go env GOCACHE)}"
|
| 20 | 21 |
|
| 21 | 22 |
setup_integration_test_filter() {
|
| ... | ... |
@@ -80,7 +81,13 @@ run_test_integration_suites() {
|
| 80 | 80 |
# Finally, we use periods as separator (instead of slashes) to be more |
| 81 | 81 |
# in line with Java package names (which is what junit.xml was designed for) |
| 82 | 82 |
pkgname="$(go env GOARCH).${pkgname//\//.}"
|
| 83 |
- echo "Running $PWD (${pkgname}) flags=${flags}"
|
|
| 83 |
+ |
|
| 84 |
+ pkgtestflags=$flags |
|
| 85 |
+ if [ -n "${TESTCOVERAGE}" ]; then
|
|
| 86 |
+ pkgtestflags="$pkgtestflags -test.coverprofile=${ABS_DEST}/${pkgname//./-}-coverage.out"
|
|
| 87 |
+ fi |
|
| 88 |
+ |
|
| 89 |
+ echo "Running $PWD (${pkgname}) flags=${pkgtestflags}"
|
|
| 84 | 90 |
[ -n "$TESTDEBUG" ] && set -x |
| 85 | 91 |
# shellcheck disable=SC2086 |
| 86 | 92 |
test_env gotestsum \ |
| ... | ... |
@@ -88,7 +95,7 @@ run_test_integration_suites() {
|
| 88 | 88 |
--jsonfile="${ABS_DEST}/${pkgname//./-}-go-test-report.json" \
|
| 89 | 89 |
--junitfile="${ABS_DEST}/${pkgname//./-}-junit-report.xml" \
|
| 90 | 90 |
--raw-command \ |
| 91 |
- -- go tool test2json -p "${pkgname}" -t ./test.main ${flags}
|
|
| 91 |
+ -- go tool test2json -p "${pkgname}" -t ./test.main ${pkgtestflags}
|
|
| 92 | 92 |
); then exit 1; fi |
| 93 | 93 |
done |
| 94 | 94 |
} |
| ... | ... |
@@ -112,8 +119,12 @@ build_test_suite_binaries() {
|
| 112 | 112 |
build_test_suite_binary() {
|
| 113 | 113 |
local dir="$1" |
| 114 | 114 |
local out="$2" |
| 115 |
+ local testflags |
|
| 115 | 116 |
echo Building test suite binary "$dir/$out" |
| 116 |
- go test -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "$dir"
|
|
| 117 |
+ if [ -n "${TESTCOVERAGE}" ]; then
|
|
| 118 |
+ testflags="-cover -covermode=atomic" |
|
| 119 |
+ fi |
|
| 120 |
+ go test ${testflags} -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "$dir"
|
|
| 117 | 121 |
} |
| 118 | 122 |
|
| 119 | 123 |
cleanup_test_suite_binaries() {
|
| ... | ... |
@@ -32,7 +32,7 @@ if [ -n "${base_pkg_list}" ]; then
|
| 32 | 32 |
gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report.json --junitfile=bundles/junit-report.xml -- \ |
| 33 | 33 |
"${BUILDFLAGS[@]}" \
|
| 34 | 34 |
-cover \ |
| 35 |
- -coverprofile=bundles/profile.out \ |
|
| 35 |
+ -coverprofile=bundles/coverage.out \ |
|
| 36 | 36 |
-covermode=atomic \ |
| 37 | 37 |
${TESTFLAGS} \
|
| 38 | 38 |
${base_pkg_list}
|
| ... | ... |
@@ -44,7 +44,7 @@ if [ -n "${libnetwork_pkg_list}" ]; then
|
| 44 | 44 |
gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report-libnetwork.json --junitfile=bundles/junit-report-libnetwork.xml -- \ |
| 45 | 45 |
"${BUILDFLAGS[@]}" \
|
| 46 | 46 |
-cover \ |
| 47 |
- -coverprofile=bundles/profile-libnetwork.out \ |
|
| 47 |
+ -coverprofile=bundles/coverage-libnetwork.out \ |
|
| 48 | 48 |
-covermode=atomic \ |
| 49 | 49 |
-p=1 \ |
| 50 | 50 |
${TESTFLAGS} \
|