Skip to content

Commit 5f21211

Browse files
committed
Fix Windows installation error handling
When Scoop fails to download or install Quarto (e.g., 503 server errors), the action would still report "Quarto Installed !" and succeed. The PowerShell script had no error handling and the bash wrapper didn't check exit codes, causing installation failures to be silently ignored.
1 parent 877ac20 commit 5f21211

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

setup/action.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,28 @@ runs:
9292
else
9393
powershell -File $GITHUB_ACTION_PATH/install-quarto-windows.ps1 ${{ inputs.version }}
9494
fi
95+
96+
# Check if installation succeeded
97+
if [ $? -ne 0 ]; then
98+
echo "ERROR: Quarto installation failed"
99+
exit 1
100+
fi
101+
102+
# Verify Quarto is available
103+
if ! command -v quarto &> /dev/null; then
104+
echo "ERROR: Quarto installation completed but quarto command not found"
105+
exit 1
106+
fi
107+
108+
echo "Quarto Installed !"
95109
;;
96110
*)
97111
echo "$RUNNER_OS not supported"
98112
exit 1
99113
;;
100114
esac
101115
[ ${{ runner.os }} != "Windows" ] && rm $installer
102-
echo "Quarto Installed !"
116+
[ ${{ runner.os }} != "Windows" ] && echo "Quarto Installed !"
103117
shell: bash
104118
working-directory: ${{ runner.temp }}
105119
- name: 'Install TinyTeX'

setup/install-quarto-windows.ps1

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,54 @@
1414
ttps:/go.microsoft.com/fwlink/?LinkID=135170
1515
#>
1616

17-
Invoke-WebRequest -useb get.scoop.sh -outfile 'install.ps1'
18-
.\install.ps1 -RunAsAdmin
19-
Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH
17+
# Exit immediately on errors
18+
$ErrorActionPreference = "Stop"
19+
20+
try {
21+
Invoke-WebRequest -useb get.scoop.sh -outfile 'install.ps1'
22+
.\install.ps1 -RunAsAdmin
23+
if ($LASTEXITCODE -ne 0) {
24+
Write-Error "Scoop installation failed with exit code $LASTEXITCODE"
25+
exit 1
26+
}
27+
Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH
28+
} catch {
29+
Write-Error "Failed to download or install Scoop: $_"
30+
exit 1
31+
}
2032

2133
$version=$args[0]
2234
scoop bucket add r-bucket https://github.com/cderv/r-bucket.git
35+
if ($LASTEXITCODE -ne 0) {
36+
Write-Error "Failed to add r-bucket with exit code $LASTEXITCODE"
37+
exit 1
38+
}
39+
2340
if ([string]::IsNullOrEmpty($version)) {
2441
scoop install quarto
42+
if ($LASTEXITCODE -ne 0) {
43+
Write-Error "Failed to install quarto with exit code $LASTEXITCODE"
44+
exit 1
45+
}
2546
} elseif ($version -eq 'pre-release') {
2647
Invoke-Expression -Command "scoop install quarto-prerelease"
48+
if ($LASTEXITCODE -ne 0) {
49+
Write-Error "Failed to install quarto-prerelease with exit code $LASTEXITCODE"
50+
exit 1
51+
}
2752
} else {
2853
Invoke-Expression -Command "scoop install quarto@$version"
54+
if ($LASTEXITCODE -ne 0) {
55+
Write-Error "Failed to install quarto version $version with exit code $LASTEXITCODE"
56+
exit 1
57+
}
2958
}
59+
60+
# Verify Quarto is available
61+
$quartoPath = Get-Command quarto -ErrorAction SilentlyContinue
62+
if (-not $quartoPath) {
63+
Write-Error "Quarto installation completed but quarto command not found in PATH"
64+
exit 1
65+
}
66+
67+
exit 0

0 commit comments

Comments
 (0)