Skip to content

Commit

Permalink
Fix codecov upload for Jenkins CI scripts (#6493)
Browse files Browse the repository at this point in the history
It seems that codecov upload has been broken for a while for
ci/jenkins/test-vmc.sh and ci/jenkins/test-mc.sh. The file pattern must
be quoted when calling the codecov binary, or the glob will be expanded
by the shell instead of by codecov (which is bad because we want the
glob to be expanded in the context of the search directory).

We also set "disable_search" to "true" when using the codecov-action in
Github workflows. This action uses the codecov CLI and there is no need
to keep search enabled when providing an explicit and comprehensive list
of files to include in the report.

Signed-off-by: Antonin Bas <[email protected]>
  • Loading branch information
antoninbas authored Jun 28, 2024
1 parent 3a18bab commit d029557
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .coverage/coverage-unit.txt
disable_search: true
flags: unit-tests
name: codecov-unit-test
fail_ci_if_error: ${{ github.event_name == 'push' }}
Expand All @@ -76,6 +77,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: .coverage/coverage-unit.txt
disable_search: true
flags: unit-tests
name: codecov-unit-test
fail_ci_if_error: ${{ github.event_name == 'push' }}
Expand Down Expand Up @@ -107,6 +109,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: .coverage/coverage-integration.txt,multicluster/.coverage/coverage-integration.txt
disable_search: true
flags: integration-tests
name: codecov-integration-test
fail_ci_if_error: ${{ github.event_name == 'push' }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: '*.cov.out*'
disable_search: true
flags: kind-e2e-tests
name: codecov-test-e2e-encap
directory: test-e2e-encap-coverage
Expand Down Expand Up @@ -185,6 +186,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: '*.cov.out*'
disable_search: true
flags: kind-e2e-tests
name: codecov-test-e2e-encap-non-default
directory: test-e2e-encap-non-default-coverage
Expand Down Expand Up @@ -255,6 +257,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: '*.cov.out*'
disable_search: true
flags: kind-e2e-tests
name: codecov-test-e2e-encap-all-features-enabled
directory: test-e2e-encap-all-features-enabled-coverage
Expand Down Expand Up @@ -317,6 +320,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: '*.cov.out*'
disable_search: true
flags: kind-e2e-tests
name: codecov-test-e2e-noencap
directory: test-e2e-noencap-coverage
Expand Down Expand Up @@ -379,6 +383,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: '*.cov.out*'
disable_search: true
flags: kind-e2e-tests
name: codecov-test-e2e-hybrid
directory: test-e2e-hybrid-coverage
Expand Down Expand Up @@ -453,6 +458,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: '*.cov.out*'
disable_search: true
flags: kind-e2e-tests
name: codecov-test-e2e-fa
directory: test-e2e-fa-coverage
Expand Down
2 changes: 1 addition & 1 deletion ci/jenkins/test-mc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function run_codecov { (set -e
shasum -a 256 -c codecov.SHA256SUM

chmod +x codecov
./codecov -c -t ${CODECOV_TOKEN} -F ${flag} -f ${file} -s ${dir} -C ${GIT_COMMIT} -r antrea-io/antrea
./codecov -c -t "${CODECOV_TOKEN}" -F "${flag}" -f "${file}" -s "${dir}" -C "${GIT_COMMIT}" -r "antrea-io/antrea"

rm -f trustedkeys.gpg codecov
)}
Expand Down
23 changes: 11 additions & 12 deletions ci/jenkins/test-vmc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,6 @@ function run_codecov { (set -e
flag=$1
file=$2
dir=$3
remote=$4
ip=$5

rm -f trustedkeys.gpg codecov
# This is supposed to be a one-time step, but there should be no harm in
Expand All @@ -327,12 +325,7 @@ function run_codecov { (set -e

chmod +x codecov

if [[ $remote == true ]]; then
${SCP_WITH_UTILS_KEY} codecov jenkins@${ip}:~
${SSH_WITH_UTILS_KEY} -n jenkins@${ip} "cd antrea; ~/codecov -c -t ${CODECOV_TOKEN} -F ${flag} -f ${file} -C ${GIT_COMMIT} -r antrea-io/antrea"
else
./codecov -c -t ${CODECOV_TOKEN} -F ${flag} -f ${file} -s ${dir} -C ${GIT_COMMIT} -r antrea-io/antrea
fi
./codecov -c -t "${CODECOV_TOKEN}" -F "${flag}" -f "${file}" -s "${dir}" -C "${GIT_COMMIT}" -r "antrea-io/antrea"
rm -f trustedkeys.gpg codecov
)}

Expand Down Expand Up @@ -547,8 +540,14 @@ function run_e2e {

tar -zcf ${GIT_CHECKOUT_DIR}/antrea-test-logs.tar.gz ${GIT_CHECKOUT_DIR}/antrea-test-logs
if [[ "$COVERAGE" == true ]]; then
pushd ${GIT_CHECKOUT_DIR}/e2e-coverage
for dir in */; do
go tool covdata textfmt -i="${dir}" -o "${dir%?}.cov.out"
rm -rf "${dir}";
done
popd
tar -zcf ${GIT_CHECKOUT_DIR}/e2e-coverage.tar.gz ${GIT_CHECKOUT_DIR}/e2e-coverage
run_codecov "e2e-tests" "*.cov.out*" "${GIT_CHECKOUT_DIR}/e2e-coverage" false ""
run_codecov "e2e-tests" "*.cov.out*" "${GIT_CHECKOUT_DIR}/e2e-coverage"
fi
}

Expand Down Expand Up @@ -618,13 +617,13 @@ function run_conformance {
if [[ "$COVERAGE" == true ]]; then
rm -rf ${GIT_CHECKOUT_DIR}/conformance-coverage
mkdir -p ${GIT_CHECKOUT_DIR}/conformance-coverage
collect_coverage
collect_coverage_for_conformance
tar -zcf ${GIT_CHECKOUT_DIR}/$TESTCASE-coverage.tar.gz ${GIT_CHECKOUT_DIR}/conformance-coverage
run_codecov "e2e-tests" "*antrea*" "${GIT_CHECKOUT_DIR}/conformance-coverage" false ""
run_codecov "e2e-tests" "*antrea*" "${GIT_CHECKOUT_DIR}/conformance-coverage"
fi
}

function collect_coverage() {
function collect_coverage_for_conformance() {
antrea_controller_pod_name="$(kubectl get pods --selector=app=antrea,component=antrea-controller -n kube-system --no-headers=true | awk '{ print $1 }')"
controller_pid="$(kubectl exec -i $antrea_controller_pod_name -n kube-system -- pgrep antrea)"
kubectl exec -i $antrea_controller_pod_name -n kube-system -- kill -SIGINT $controller_pid
Expand Down

0 comments on commit d029557

Please sign in to comment.