From 5f21211e2daf9188342fb235cf0a07b9d57182cb Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 11 Dec 2025 21:06:55 +0100 Subject: [PATCH 01/10] 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. --- setup/action.yml | 16 +++++++++++- setup/install-quarto-windows.ps1 | 44 +++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/setup/action.yml b/setup/action.yml index c66e9dd..d645994 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -92,6 +92,20 @@ runs: else powershell -File $GITHUB_ACTION_PATH/install-quarto-windows.ps1 ${{ inputs.version }} fi + + # Check if installation succeeded + if [ $? -ne 0 ]; then + echo "ERROR: Quarto installation failed" + exit 1 + fi + + # Verify Quarto is available + if ! command -v quarto &> /dev/null; then + echo "ERROR: Quarto installation completed but quarto command not found" + exit 1 + fi + + echo "Quarto Installed !" ;; *) echo "$RUNNER_OS not supported" @@ -99,7 +113,7 @@ runs: ;; esac [ ${{ runner.os }} != "Windows" ] && rm $installer - echo "Quarto Installed !" + [ ${{ runner.os }} != "Windows" ] && echo "Quarto Installed !" shell: bash working-directory: ${{ runner.temp }} - name: 'Install TinyTeX' diff --git a/setup/install-quarto-windows.ps1 b/setup/install-quarto-windows.ps1 index 9765616..86d2bde 100644 --- a/setup/install-quarto-windows.ps1 +++ b/setup/install-quarto-windows.ps1 @@ -14,16 +14,54 @@ ttps:/go.microsoft.com/fwlink/?LinkID=135170 #> -Invoke-WebRequest -useb get.scoop.sh -outfile 'install.ps1' -.\install.ps1 -RunAsAdmin -Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH +# Exit immediately on errors +$ErrorActionPreference = "Stop" + +try { + Invoke-WebRequest -useb get.scoop.sh -outfile 'install.ps1' + .\install.ps1 -RunAsAdmin + if ($LASTEXITCODE -ne 0) { + Write-Error "Scoop installation failed with exit code $LASTEXITCODE" + exit 1 + } + Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH +} catch { + Write-Error "Failed to download or install Scoop: $_" + exit 1 +} $version=$args[0] scoop bucket add r-bucket https://github.com/cderv/r-bucket.git +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to add r-bucket with exit code $LASTEXITCODE" + exit 1 +} + if ([string]::IsNullOrEmpty($version)) { scoop install quarto + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to install quarto with exit code $LASTEXITCODE" + exit 1 + } } elseif ($version -eq 'pre-release') { Invoke-Expression -Command "scoop install quarto-prerelease" + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to install quarto-prerelease with exit code $LASTEXITCODE" + exit 1 + } } else { Invoke-Expression -Command "scoop install quarto@$version" + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to install quarto version $version with exit code $LASTEXITCODE" + exit 1 + } } + +# Verify Quarto is available +$quartoPath = Get-Command quarto -ErrorAction SilentlyContinue +if (-not $quartoPath) { + Write-Error "Quarto installation completed but quarto command not found in PATH" + exit 1 +} + +exit 0 From a17583a126a1d7bbde1d05b50120d3e47b0a6859 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:09:13 +0100 Subject: [PATCH 02/10] Remove redundant bash verification on Windows The PowerShell script already verifies Quarto is available with Get-Command. The bash check was redundant and failing because GITHUB_PATH updates only take effect in subsequent steps, not within the same step where the PATH is modified. --- setup/action.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/setup/action.yml b/setup/action.yml index d645994..0f52a4c 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -99,12 +99,6 @@ runs: exit 1 fi - # Verify Quarto is available - if ! command -v quarto &> /dev/null; then - echo "ERROR: Quarto installation completed but quarto command not found" - exit 1 - fi - echo "Quarto Installed !" ;; *) From 262dd71d76e861ac4543b5931e79a3875c8f8479 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:16:38 +0100 Subject: [PATCH 03/10] Update PATH in current PowerShell session The Get-Command verification was failing because $GITHUB_PATH only affects future steps, not the current PowerShell session. Now we also update $env:PATH so the verification can find quarto. --- setup/install-quarto-windows.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup/install-quarto-windows.ps1 b/setup/install-quarto-windows.ps1 index 86d2bde..9baa395 100644 --- a/setup/install-quarto-windows.ps1 +++ b/setup/install-quarto-windows.ps1 @@ -24,7 +24,9 @@ try { Write-Error "Scoop installation failed with exit code $LASTEXITCODE" exit 1 } - Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH + $scoopShims = Join-Path (Resolve-Path ~).Path "scoop\shims" + $scoopShims >> $Env:GITHUB_PATH + $env:PATH = "$scoopShims;$env:PATH" } catch { Write-Error "Failed to download or install Scoop: $_" exit 1 From d4e84b4e9faf6788eb3d12a40a6800eff3c898c6 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:25:41 +0100 Subject: [PATCH 04/10] Refactor to consistent verification across all platforms Previously each OS had different verification approaches: - Windows: PowerShell Get-Command check (failed due to PATH timing) - Linux/macOS: No verification Now all platforms use a single bash verification step that runs after installation. This works because GITHUB_PATH updates take effect in subsequent steps, not within the same step. --- setup/action.yml | 20 ++++++++++---------- setup/install-quarto-windows.ps1 | 7 ------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/setup/action.yml b/setup/action.yml index 0f52a4c..565830a 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -77,7 +77,7 @@ runs: run: | # Install quarto [ ${{ runner.os }} != "Windows" ] && installer=${{ steps.download-quarto.outputs.installer }} - case $RUNNER_OS in + case $RUNNER_OS in "Linux") sudo apt -y install ./$installer ;; @@ -92,14 +92,6 @@ runs: else powershell -File $GITHUB_ACTION_PATH/install-quarto-windows.ps1 ${{ inputs.version }} fi - - # Check if installation succeeded - if [ $? -ne 0 ]; then - echo "ERROR: Quarto installation failed" - exit 1 - fi - - echo "Quarto Installed !" ;; *) echo "$RUNNER_OS not supported" @@ -107,9 +99,17 @@ runs: ;; esac [ ${{ runner.os }} != "Windows" ] && rm $installer - [ ${{ runner.os }} != "Windows" ] && echo "Quarto Installed !" shell: bash working-directory: ${{ runner.temp }} + - name: 'Verify Quarto installation' + run: | + if ! command -v quarto &> /dev/null; then + echo "ERROR: Quarto installation completed but quarto command not found" + exit 1 + fi + echo "Quarto Installed !" + quarto --version + shell: bash - name: 'Install TinyTeX' env: QUARTO_PRINT_STACK: true diff --git a/setup/install-quarto-windows.ps1 b/setup/install-quarto-windows.ps1 index 9baa395..1bf94fe 100644 --- a/setup/install-quarto-windows.ps1 +++ b/setup/install-quarto-windows.ps1 @@ -59,11 +59,4 @@ if ([string]::IsNullOrEmpty($version)) { } } -# Verify Quarto is available -$quartoPath = Get-Command quarto -ErrorAction SilentlyContinue -if (-not $quartoPath) { - Write-Error "Quarto installation completed but quarto command not found in PATH" - exit 1 -} - exit 0 From fd40497786bf436b2bc1ce7cf3406733d4eaa03c Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:30:28 +0100 Subject: [PATCH 05/10] Remove unreliable LASTEXITCODE checks from Scoop commands Scoop commands leave $LASTEXITCODE in unpredictable states even on success. With $ErrorActionPreference = "Stop", real errors will be caught automatically. The separate bash verification step confirms installation succeeded. --- setup/install-quarto-windows.ps1 | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/setup/install-quarto-windows.ps1 b/setup/install-quarto-windows.ps1 index 1bf94fe..a05772f 100644 --- a/setup/install-quarto-windows.ps1 +++ b/setup/install-quarto-windows.ps1 @@ -34,29 +34,11 @@ try { $version=$args[0] scoop bucket add r-bucket https://github.com/cderv/r-bucket.git -if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to add r-bucket with exit code $LASTEXITCODE" - exit 1 -} if ([string]::IsNullOrEmpty($version)) { scoop install quarto - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to install quarto with exit code $LASTEXITCODE" - exit 1 - } } elseif ($version -eq 'pre-release') { - Invoke-Expression -Command "scoop install quarto-prerelease" - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to install quarto-prerelease with exit code $LASTEXITCODE" - exit 1 - } + scoop install quarto-prerelease } else { - Invoke-Expression -Command "scoop install quarto@$version" - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to install quarto version $version with exit code $LASTEXITCODE" - exit 1 - } + scoop install quarto@$version } - -exit 0 From 8634d181db921350432ef9b636227261a955ebae Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:42:10 +0100 Subject: [PATCH 06/10] Correctly don't end with a false --- setup/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup/action.yml b/setup/action.yml index 565830a..2aa7314 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -98,7 +98,9 @@ runs: exit 1 ;; esac - [ ${{ runner.os }} != "Windows" ] && rm $installer + if [ "${{ runner.os }}" != "Windows" ]; then + rm $installer + fi shell: bash working-directory: ${{ runner.temp }} - name: 'Verify Quarto installation' From 2fe6f157947a3f6c92338cbc7afde2f24a9f11fb Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:45:53 +0100 Subject: [PATCH 07/10] Remove path setting --- setup/install-quarto-windows.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup/install-quarto-windows.ps1 b/setup/install-quarto-windows.ps1 index a05772f..6f7c524 100644 --- a/setup/install-quarto-windows.ps1 +++ b/setup/install-quarto-windows.ps1 @@ -25,8 +25,7 @@ try { exit 1 } $scoopShims = Join-Path (Resolve-Path ~).Path "scoop\shims" - $scoopShims >> $Env:GITHUB_PATH - $env:PATH = "$scoopShims;$env:PATH" + Add-Content -Path $Env:GITHUB_PATH -Value $scoopShims } catch { Write-Error "Failed to download or install Scoop: $_" exit 1 From 6dbecf975fb9b5be405e412376808d205b78b50e Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:46:59 +0100 Subject: [PATCH 08/10] Also test a specific version number --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 65932e0..6eb0993 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - version: ${{ inputs.version && fromJSON(format('["{0}"]', inputs.version)) || fromJSON('["release", "pre-release"]') }} + version: ${{ inputs.version && fromJSON(format('["{0}"]', inputs.version)) || fromJSON('["release", "pre-release", "1.8.25"]') }} config: # Default config for standard platforms - os: macos-latest From a144809d44d0b5dedae3fc2bac7545ea01e97a57 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 12:51:10 +0100 Subject: [PATCH 09/10] Trigger a failure to check windows installation --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6eb0993..b029945 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - version: ${{ inputs.version && fromJSON(format('["{0}"]', inputs.version)) || fromJSON('["release", "pre-release", "1.8.25"]') }} + version: ${{ inputs.version && fromJSON(format('["{0}"]', inputs.version)) || fromJSON('["release", "pre-release", "1.8.25", "0.0.1"]') }} config: # Default config for standard platforms - os: macos-latest From f7fa7c7f275464feafb2828134954cec1f810f85 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 12 Dec 2025 13:54:04 +0100 Subject: [PATCH 10/10] Revert "Trigger a failure to check windows installation" This reverts commit a144809d44d0b5dedae3fc2bac7545ea01e97a57. --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b029945..6eb0993 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: false matrix: - version: ${{ inputs.version && fromJSON(format('["{0}"]', inputs.version)) || fromJSON('["release", "pre-release", "1.8.25", "0.0.1"]') }} + version: ${{ inputs.version && fromJSON(format('["{0}"]', inputs.version)) || fromJSON('["release", "pre-release", "1.8.25"]') }} config: # Default config for standard platforms - os: macos-latest