Skip to content

Commit 2ff6414

Browse files
committed
Use shared marker for Dockur IIS self-test
1 parent a33a5bf commit 2ff6414

File tree

1 file changed

+64
-13
lines changed

1 file changed

+64
-13
lines changed

.github/workflows/dockur-smoke-test.yml

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,62 @@ jobs:
2424
- name: Prepare Dockur OEM installer
2525
run: |
2626
mkdir -p "$RUNNER_TEMP/dockur-oem"
27+
mkdir -p "$RUNNER_TEMP/dockur-shared"
28+
cat > "$RUNNER_TEMP/dockur-oem/install.ps1" <<'EOF'
29+
$ErrorActionPreference = 'Stop'
30+
$sharePath = '\\host.lan\Data'
31+
32+
function Write-SharedFile {
33+
param(
34+
[string]$Name,
35+
[string]$Value
36+
)
37+
38+
try {
39+
Set-Content -Path (Join-Path $sharePath $Name) -Value $Value -Encoding Ascii
40+
} catch {
41+
Write-Host "Unable to write $Name to shared folder: $($_.Exception.Message)"
42+
}
43+
}
44+
45+
Write-SharedFile -Name 'oem-status.txt' -Value 'started'
46+
47+
Install-WindowsFeature Web-Server -IncludeManagementTools | Out-Null
48+
Set-Content -Path 'C:\inetpub\wwwroot\index.html' -Value 'dockur-iis-ok' -Encoding Ascii
49+
50+
if (-not (Get-NetFirewallRule -DisplayName 'Dockur IIS HTTP 80' -ErrorAction SilentlyContinue)) {
51+
New-NetFirewallRule -DisplayName 'Dockur IIS HTTP 80' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80 | Out-Null
52+
}
53+
54+
Start-Service W3SVC
55+
56+
$iisOk = $false
57+
for ($i = 0; $i -lt 40 -and -not $iisOk; $i++) {
58+
try {
59+
$response = Invoke-WebRequest -UseBasicParsing http://127.0.0.1/
60+
if ($response.Content -match 'dockur-iis-ok') {
61+
$iisOk = $true
62+
break
63+
}
64+
} catch {
65+
}
66+
67+
Start-Sleep -Seconds 5
68+
}
69+
70+
if ($iisOk) {
71+
Write-SharedFile -Name 'iis-selftest.txt' -Value 'dockur-iis-ok'
72+
Write-SharedFile -Name 'oem-status.txt' -Value 'completed'
73+
exit 0
74+
}
75+
76+
Write-SharedFile -Name 'iis-selftest.txt' -Value 'iis-selftest-failed'
77+
Write-SharedFile -Name 'oem-status.txt' -Value 'failed'
78+
exit 1
79+
EOF
2780
cat > "$RUNNER_TEMP/dockur-oem/install.bat" <<'EOF'
2881
@echo off
29-
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command ^
30-
"$ErrorActionPreference = 'Stop';" ^
31-
"Install-WindowsFeature Web-Server -IncludeManagementTools;" ^
32-
"Set-Content -Path 'C:\inetpub\wwwroot\index.html' -Value 'dockur-iis-ok' -Encoding Ascii;" ^
33-
"if (-not (Get-NetFirewallRule -DisplayName 'Dockur IIS HTTP 80' -ErrorAction SilentlyContinue)) { New-NetFirewallRule -DisplayName 'Dockur IIS HTTP 80' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 80 | Out-Null };" ^
34-
"Start-Service W3SVC"
82+
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File C:\OEM\install.ps1
3583
if errorlevel 1 exit /b 1
3684
EOF
3785
@@ -41,14 +89,14 @@ jobs:
4189
docker run -d --name dockur-win \
4290
-e VERSION=2019 \
4391
-p 8006:8006 \
44-
-p 8080:80 \
4592
-p 3389:3389/tcp \
4693
-p 3389:3389/udp \
4794
--device /dev/kvm \
4895
--device /dev/net/tun \
4996
--cap-add NET_ADMIN \
5097
-v "$RUNNER_TEMP/dockur-2019:/storage" \
5198
-v "$RUNNER_TEMP/dockur-oem:/oem" \
99+
-v "$RUNNER_TEMP/dockur-shared:/shared" \
52100
--stop-timeout 120 \
53101
docker.io/dockurr/windows
54102
@@ -77,22 +125,25 @@ jobs:
77125
echo "Windows RDP port never became reachable."
78126
exit 1
79127
80-
- name: Wait for IIS marker page
128+
- name: Wait for IIS self-test marker
81129
run: |
82130
for i in $(seq 1 40); do
83-
if curl -fsS http://127.0.0.1:8080 | tee /tmp/dockur-iis-page.txt | grep -q "dockur-iis-ok"; then
84-
echo "IIS marker page is reachable."
131+
if [ -f "$RUNNER_TEMP/dockur-shared/iis-selftest.txt" ] && grep -q "dockur-iis-ok" "$RUNNER_TEMP/dockur-shared/iis-selftest.txt"; then
132+
echo "IIS self-test marker is present."
85133
exit 0
86134
fi
87135
sleep 15
88136
done
89137
90-
echo "IIS marker page never became reachable."
138+
echo "IIS self-test marker never appeared."
91139
exit 1
92140
93-
- name: Show IIS marker page
141+
- name: Show shared status files
94142
if: always()
95-
run: curl -fsS http://127.0.0.1:8080 || true
143+
run: |
144+
ls -la "$RUNNER_TEMP/dockur-shared" || true
145+
cat "$RUNNER_TEMP/dockur-shared/oem-status.txt" || true
146+
cat "$RUNNER_TEMP/dockur-shared/iis-selftest.txt" || true
96147
97148
- name: Show container status
98149
if: always()

0 commit comments

Comments
 (0)