Skip to content

Commit 1defecf

Browse files
authored
Refactor JAGS installation workflow for Windows [ci-skip]
Updated JAGS installation process to use caching and simplified steps.
1 parent 2135cc1 commit 1defecf

File tree

1 file changed

+24
-53
lines changed

1 file changed

+24
-53
lines changed

.github/workflows/windows-JAGS-test.yaml

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,28 @@ jobs:
99
runs-on: windows-latest
1010

1111
steps:
12-
- name: Download JAGS installer from release
13-
shell: pwsh
14-
env:
15-
GH_TOKEN: ${{ github.token }}
12+
- uses: actions/checkout@v4
13+
14+
# Cache JAGS installation (Windows)
15+
- name: Cache JAGS (Windows)
16+
if: runner.os == 'Windows'
17+
uses: actions/cache@v3
18+
with:
19+
path: C:\Program Files\JAGS
20+
key: ${{ runner.os }}-jags-4.3.1
21+
restore-keys: |
22+
${{ runner.os }}-jags-
23+
24+
# Install JAGS on Windows
25+
- name: Install JAGS (Windows)
26+
if: runner.os == 'Windows'
27+
shell: cmd
1628
run: |
17-
gh release download tools-jags-4.3.1 `
18-
--repo $env:GITHUB_REPOSITORY `
19-
--pattern "JAGS-4.3.1.exe" `
20-
--dir .
21-
if (!(Test-Path ".\JAGS-4.3.1.exe")) { throw "Installer not found" }
22-
23-
# Use Windows PowerShell (v5) host to run the installer
24-
- name: Install JAGS silently (robust flags)
25-
shell: powershell
26-
run: |
27-
$installer = Join-Path $PWD "JAGS-4.3.1.exe"
28-
$args = "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
29-
Write-Host "Running: $installer $args"
30-
31-
# Short watchdog: fail if still running after 5 minutes
32-
$p = Start-Process -FilePath $installer -ArgumentList $args -PassThru
33-
if (-not $p) { throw "Failed to start installer" }
34-
$deadline = (Get-Date).AddMinutes(5)
35-
while (-not $p.HasExited) {
36-
Start-Sleep -Seconds 5
37-
if (Get-Date -gt $deadline) {
38-
Write-Warning "Installer exceeded 5 minutes; terminating."
39-
try { Stop-Process -Id $p.Id -Force } catch {}
40-
throw "JAGS installer timed out"
41-
}
42-
}
43-
if ($p.ExitCode -ne 0) {
44-
throw "Installer exited with code $($p.ExitCode)"
45-
}
46-
47-
- name: Locate jags-terminal.exe
48-
shell: powershell
49-
run: |
50-
$exe = Get-ChildItem "C:\Program Files\JAGS" -Recurse -Filter "jags-terminal.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
51-
if (!$exe) { throw "Could not find jags-terminal.exe under C:\Program Files\JAGS" }
52-
Write-Host "Found JAGS terminal at: $($exe.FullName)"
53-
echo "JAGS_PATH=$($exe.FullName)" >> $env:GITHUB_ENV
54-
55-
- name: Verify JAGS (version/banner)
56-
shell: powershell
57-
run: |
58-
$exe = "$env:JAGS_PATH"
59-
$out = & $exe --version 2>&1
60-
if ([string]::IsNullOrWhiteSpace($out)) { $out = & $exe 2>&1 }
61-
Write-Host "---- JAGS output ----"
62-
Write-Host $out
63-
Write-Host "---------------------"
64-
if ($out -notmatch "JAGS" -or $out -notmatch "4\.3") {
65-
throw "Unexpected JAGS output"
29+
if not exist "C:\Program Files\JAGS\JAGS-4.3.1\bin\jags-terminal.exe" (
30+
echo "JAGS not found in cache, downloading and installing..."
31+
curl -o jags-installer.exe -L https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.1.exe/download
32+
jags-installer.exe /S
33+
del jags-installer.exe
34+
) else (
35+
echo "JAGS found in cache, skipping installation"
36+
)

0 commit comments

Comments
 (0)