Skip to content

Commit

Permalink
Merge pull request #5993 from cre4ture/fix/workaround_for_textfile_bu…
Browse files Browse the repository at this point in the history
…sy_error

Android CI: workaround: run builds with retry
  • Loading branch information
sylvestre authored Feb 28, 2024
2 parents 769c5ca + 263a163 commit 372cd52
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
21 changes: 19 additions & 2 deletions util/android-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,22 @@ generate_and_install_public_key() {
echo "installed ssh public key on device"
}

run_with_retry() {
tries=$1
shift 1

for i in $(seq 1 $tries); do
echo "Try #$i of $tries: run $*"
"$@" && echo "Done in try#$i" && return 0
done

exit_code=$?

echo "Still failing after $tries. Code: $exit_code"

return $exit_code
}

snapshot() {
apk="$1"
echo "Running snapshot"
Expand All @@ -500,7 +516,8 @@ snapshot() {

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

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

echo "Finished build"
}
Expand Down
22 changes: 21 additions & 1 deletion util/android-scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ export CARGO_INCREMENTAL=0

echo "PATH: $PATH"

run_with_retry() {
tries=$1
shift 1

for i in $(seq 1 $tries); do
echo "Try #$i of $tries: run $*"
"$@" && echo "Done in try#$i" && return 0
done

exit_code=$?

echo "Still failing after $tries. Code: $exit_code"

return $exit_code
}

run_tests_in_subprocess() (

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

nextest_params=(--profile ci --hide-progress-bar --features feat_os_unix_android)

# run tests
cd ~/coreutils && \
run_with_retry 3 timeout --preserve-status --verbose -k 1m 10m \
cargo nextest run --no-run "${nextest_params[@]}" &&
timeout --preserve-status --verbose -k 1m 60m \
cargo nextest run --profile ci --hide-progress-bar --features feat_os_unix_android
cargo nextest run "${nextest_params[@]}"

result=$?

Expand Down

0 comments on commit 372cd52

Please sign in to comment.