Skip to content

Commit beb0949

Browse files
committed
Retry on bash startup failure on Windows
1 parent 3e95df3 commit beb0949

4 files changed

Lines changed: 67 additions & 44 deletions

File tree

.github/.cspell/project-dictionary.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ grcov
1717
gungraun
1818
insta
1919
knope
20+
LASTEXITCODE
2021
libicu
2122
linkcheck
2223
mdbook
@@ -38,6 +39,7 @@ sigstore
3839
syft
3940
tombi
4041
udeps
42+
USERPROFILE
4143
wasmtime
4244
watchexec
4345
worktree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
1010

1111
## [Unreleased]
1212

13+
- Implement workaround for [windows-11-arm runner bug](https://github.com/actions/partner-runner-images/issues/169) which sometimes causes installation failure. ([#1657](https://github.com/taiki-e/install-action/pull/1657))
14+
15+
This addresses an issue that was attempted to be worked around in 2.71.0 but was insufficient.
16+
1317
- Update `mise@latest` to 2026.4.1.
1418

1519
- Update `uv@latest` to 0.11.3.

action.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,26 @@ runs:
5252
DEFAULT_GITHUB_TOKEN: ${{ github.token }}
5353
ACTION_USER_AGENT: ${{ github.action_repository }} (${{ github.action_ref }})
5454
if: runner.os != 'Windows'
55-
# Workaround for https://github.com/actions/partner-runner-images/issues/169
56-
# TODO: Is it necessary to retry for main.sh call? Or is this sufficient? https://github.com/taiki-e/install-action/pull/1647
55+
# Use pwsh and retry on bash startup failure to work around windows-11-arm runner bug: https://github.com/actions/partner-runner-images/issues/169
5756
- run: |
5857
Set-StrictMode -Version Latest
59-
$action_path = $env:GITHUB_ACTION_PATH
60-
& bash --noprofile --norc "${action_path}/main.sh"
58+
for ($i=1; $i -le 10; $i++) {
59+
$prev_err_action = $ErrorActionPreference
60+
$ErrorActionPreference = "Continue"
61+
& bash --noprofile --norc "$env:GITHUB_ACTION_PATH/main.sh"
62+
$code = $LASTEXITCODE
63+
$ErrorActionPreference = "$prev_err_action"
64+
if (Test-Path "$env:USERPROFILE\.install-action\init") {
65+
# If bash started successfully, main.sh creates init file.
66+
Remove-Item "$env:USERPROFILE\.install-action\init" -Force
67+
exit $code
68+
}
69+
if ($i -lt 10) {
70+
Write-Output "::warning::installation failed due to bash startup failure (<https://github.com/actions/partner-runner-images/issues/169>); retrying..."
71+
}
72+
}
73+
Write-Output "::error::installation failed due to bash startup failure (<https://github.com/actions/partner-runner-images/issues/169>); this maybe resolved by re-running job"
74+
exit 1
6175
shell: pwsh
6276
env:
6377
# NB: Sync with non-Windows case.

main.sh

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -436,46 +436,6 @@ canonicalize_windows_path() {
436436
esac
437437
}
438438

439-
# cargo-binstall may call `cargo install` on their fallback: https://github.com/taiki-e/install-action/pull/54#issuecomment-1383140833
440-
# cross calls rustup on `cross --version` if the current directly is cargo workspace.
441-
export CARGO_NET_RETRY=10
442-
export RUSTUP_MAX_RETRIES=10
443-
444-
if [[ $# -gt 0 ]]; then
445-
bail "invalid argument '$1'"
446-
fi
447-
448-
export DEBIAN_FRONTEND=noninteractive
449-
manifest_dir="$(dirname -- "$0")/manifests"
450-
451-
# Inputs
452-
tool="${INPUT_TOOL:-}"
453-
tools=()
454-
if [[ -n "${tool}" ]]; then
455-
while read -rd,; do
456-
tools+=("${REPLY}")
457-
done < <(normalize_comma_or_space_separated "${tool}")
458-
fi
459-
if [[ ${#tools[@]} -eq 0 ]]; then
460-
warn "no tool specified; this could be caused by a dependabot bug where @<tool_name> tags on this action are replaced by @<version> tags"
461-
# Exit with 0 for backward compatibility.
462-
# TODO: We want to reject it in the next major release.
463-
exit 0
464-
fi
465-
466-
enable_checksum="${INPUT_CHECKSUM:-}"
467-
case "${enable_checksum}" in
468-
true) ;;
469-
false) enable_checksum='' ;;
470-
*) bail "'checksum' input option must be 'true' or 'false': '${enable_checksum}'" ;;
471-
esac
472-
473-
fallback="${INPUT_FALLBACK:-}"
474-
case "${fallback}" in
475-
none | cargo-binstall | cargo-install) ;;
476-
*) bail "'fallback' input option must be 'none', 'cargo-binstall', or 'cargo-install': '${fallback}'" ;;
477-
esac
478-
479439
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
480440
base_distro=''
481441
exe=''
@@ -590,6 +550,9 @@ cargo_bin="${CARGO_HOME:-"${home}/.cargo"}/bin"
590550
# is used ($CARGO_HOME/bin is most likely not included in the PATH), fallback to
591551
# $install_action_dir/bin.
592552
if [[ "${host_os}" == "windows" ]]; then
553+
mkdir -p -- "${install_action_dir}"
554+
# See action.yml.
555+
touch -- "${install_action_dir}"/init
593556
if type -P cargo >/dev/null; then
594557
info "cargo is located at $(type -P cargo)"
595558
cargo_bin=$(dirname -- "$(type -P cargo)")
@@ -604,6 +567,46 @@ elif [[ ! -e "${cargo_bin}" ]] || [[ "$(type -P cargo || true)" != "${cargo_bin}
604567
cargo_bin="${install_action_dir}/bin"
605568
fi
606569

570+
# cargo-binstall may call `cargo install` on their fallback: https://github.com/taiki-e/install-action/pull/54#issuecomment-1383140833
571+
# cross calls rustup on `cross --version` if the current directly is cargo workspace.
572+
export CARGO_NET_RETRY=10
573+
export RUSTUP_MAX_RETRIES=10
574+
575+
if [[ $# -gt 0 ]]; then
576+
bail "invalid argument '$1'"
577+
fi
578+
579+
export DEBIAN_FRONTEND=noninteractive
580+
manifest_dir="$(dirname -- "$0")/manifests"
581+
582+
# Inputs
583+
tool="${INPUT_TOOL:-}"
584+
tools=()
585+
if [[ -n "${tool}" ]]; then
586+
while read -rd,; do
587+
tools+=("${REPLY}")
588+
done < <(normalize_comma_or_space_separated "${tool}")
589+
fi
590+
if [[ ${#tools[@]} -eq 0 ]]; then
591+
warn "no tool specified; this could be caused by a dependabot bug where @<tool_name> tags on this action are replaced by @<version> tags"
592+
# Exit with 0 for backward compatibility.
593+
# TODO: We want to reject it in the next major release.
594+
exit 0
595+
fi
596+
597+
enable_checksum="${INPUT_CHECKSUM:-}"
598+
case "${enable_checksum}" in
599+
true) ;;
600+
false) enable_checksum='' ;;
601+
*) bail "'checksum' input option must be 'true' or 'false': '${enable_checksum}'" ;;
602+
esac
603+
604+
fallback="${INPUT_FALLBACK:-}"
605+
case "${fallback}" in
606+
none | cargo-binstall | cargo-install) ;;
607+
*) bail "'fallback' input option must be 'none', 'cargo-binstall', or 'cargo-install': '${fallback}'" ;;
608+
esac
609+
607610
case "${host_os}" in
608611
linux)
609612
if ! type -P jq >/dev/null || ! type -P curl >/dev/null || ! type -P tar >/dev/null; then

0 commit comments

Comments
 (0)