ci(jenkins): retry transient go fetch/test failures
This commit is contained in:
parent
6f9dfaa714
commit
265be3eeab
39
Jenkinsfile
vendored
39
Jenkinsfile
vendored
@ -119,11 +119,36 @@ spec:
|
|||||||
apt-get update >/dev/null
|
apt-get update >/dev/null
|
||||||
apt-get install -y --no-install-recommends xz-utils >/dev/null
|
apt-get install -y --no-install-recommends xz-utils >/dev/null
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
|
export GOPROXY='https://proxy.golang.org,direct'
|
||||||
|
export GOSUMDB='sum.golang.org'
|
||||||
|
for attempt in 1 2 3; do
|
||||||
|
if go mod download >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "${attempt}" -eq 3 ]; then
|
||||||
|
echo "go mod download failed after ${attempt} attempts" >&2
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep $((attempt * 3))
|
||||||
|
done
|
||||||
go install github.com/jstemmer/go-junit-report/v2@latest
|
go install github.com/jstemmer/go-junit-report/v2@latest
|
||||||
set +e
|
test_rc=1
|
||||||
go test -v -coverprofile=build/coverage.out ./... > build/test.out 2>&1
|
for attempt in 1 2 3; do
|
||||||
test_rc=$?
|
set +e
|
||||||
set -e
|
go test -v -count=1 -coverprofile=build/coverage.out ./... > build/test.out 2>&1
|
||||||
|
test_rc=$?
|
||||||
|
set -e
|
||||||
|
if [ "${test_rc}" -eq 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if ! grep -q 'TLS handshake timeout' build/test.out 2>/dev/null; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "${attempt}" -eq 3 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep $((attempt * 3))
|
||||||
|
done
|
||||||
printf '%s\n' "${test_rc}" > "${TEST_EXIT_CODE_PATH}"
|
printf '%s\n' "${test_rc}" > "${TEST_EXIT_CODE_PATH}"
|
||||||
cat build/test.out
|
cat build/test.out
|
||||||
"$(go env GOPATH)/bin/go-junit-report" < build/test.out > "${JUNIT_XML}"
|
"$(go env GOPATH)/bin/go-junit-report" < build/test.out > "${JUNIT_XML}"
|
||||||
@ -140,10 +165,12 @@ spec:
|
|||||||
|
|
||||||
stage('Publish test metrics') {
|
stage('Publish test metrics') {
|
||||||
steps {
|
steps {
|
||||||
container('publisher') {
|
container('tester') {
|
||||||
sh '''
|
sh '''
|
||||||
set -eu
|
set -eu
|
||||||
python scripts/publish_test_metrics.py
|
apt-get update >/dev/null
|
||||||
|
apt-get install -y --no-install-recommends python3 >/dev/null
|
||||||
|
python3 scripts/publish_test_metrics.py
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user