Skip to content

Commit 263a163

Browse files
committed
workaround: run builds with retry (a)
1 parent d7a09c0 commit 263a163

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

util/android-commands.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,22 @@ generate_and_install_public_key() {
482482
echo "installed ssh public key on device"
483483
}
484484

485+
run_with_retry() {
486+
tries=$1
487+
shift 1
488+
489+
for i in $(seq 1 $tries); do
490+
echo "Try #$i of $tries: run $*"
491+
"$@" && echo "Done in try#$i" && return 0
492+
done
493+
494+
exit_code=$?
495+
496+
echo "Still failing after $tries. Code: $exit_code"
497+
498+
return $exit_code
499+
}
500+
485501
snapshot() {
486502
apk="$1"
487503
echo "Running snapshot"
@@ -500,7 +516,8 @@ snapshot() {
500516

501517
echo "Installing cargo-nextest"
502518
# We need to install nextest via cargo currently, since there is no pre-built binary for android x86
503-
run_command_via_ssh "export CARGO_TERM_COLOR=always && cargo install cargo-nextest"
519+
command="export CARGO_TERM_COLOR=always && cargo install cargo-nextest"
520+
run_with_retry 3 run_command_via_ssh "$command"
504521
return_code=$?
505522

506523
echo "Info about cargo and rust - via SSH Script"
@@ -562,7 +579,7 @@ build() {
562579
command="export CARGO_TERM_COLOR=always;
563580
export CARGO_INCREMENTAL=0; \
564581
cd ~/coreutils && cargo build --features feat_os_unix_android"
565-
run_command_via_ssh "$command" || return
582+
run_with_retry 3 run_command_via_ssh "$command" || return
566583

567584
echo "Finished build"
568585
}

util/android-scripts/run-tests.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ export CARGO_INCREMENTAL=0
1111

1212
echo "PATH: $PATH"
1313

14+
run_with_retry() {
15+
tries=$1
16+
shift 1
17+
18+
for i in $(seq 1 $tries); do
19+
echo "Try #$i of $tries: run $*"
20+
"$@" && echo "Done in try#$i" && return 0
21+
done
22+
23+
exit_code=$?
24+
25+
echo "Still failing after $tries. Code: $exit_code"
26+
27+
return $exit_code
28+
}
29+
1430
run_tests_in_subprocess() (
1531

1632
# limit virtual memory to 3GB to avoid that OS kills sshd
@@ -32,10 +48,14 @@ run_tests_in_subprocess() (
3248
watchplus 2 df -h &
3349
watchplus 2 free -hm &
3450

51+
nextest_params=(--profile ci --hide-progress-bar --features feat_os_unix_android)
52+
3553
# run tests
3654
cd ~/coreutils && \
55+
run_with_retry 3 timeout --preserve-status --verbose -k 1m 10m \
56+
cargo nextest run --no-run "${nextest_params[@]}" &&
3757
timeout --preserve-status --verbose -k 1m 60m \
38-
cargo nextest run --profile ci --hide-progress-bar --features feat_os_unix_android
58+
cargo nextest run "${nextest_params[@]}"
3959

4060
result=$?
4161

0 commit comments

Comments
 (0)