Skip to content

Commit 6fe6aff

Browse files
committed
ci: fix: handle missing docker config on MacOS & Windows in ci-test.yml
1 parent 7e024a3 commit 6fe6aff

File tree

2 files changed

+87
-3
lines changed

2 files changed

+87
-3
lines changed

.github/workflows/ci-test.yml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
12-
timeout-minutes: 30
12+
timeout-minutes: 45
1313
permissions:
1414
contents: read
1515
strategy:
@@ -22,6 +22,52 @@ jobs:
2222
- name: Checkout code
2323
uses: actions/checkout@v6.0.1
2424

25+
- name: Set up Docker (Windows)
26+
if: runner.os == 'Windows'
27+
shell: powershell
28+
run: |
29+
Write-Host "Starting Docker Desktop..."
30+
Start-Process "C:\Program Files\Docker\Docker\Docker Desktop.exe" -ErrorAction SilentlyContinue
31+
Write-Host "Waiting for Docker to be ready..."
32+
$timeout = 300
33+
$elapsed = 0
34+
while ($elapsed -lt $timeout) {
35+
try {
36+
docker version 2>&1 | Out-Null
37+
if ($LASTEXITCODE -eq 0) {
38+
Write-Host "Docker is ready"
39+
docker version
40+
docker info
41+
break
42+
}
43+
} catch {
44+
Write-Host "Docker not ready yet... ($elapsed/$timeout seconds)"
45+
}
46+
Start-Sleep -Seconds 10
47+
$elapsed += 10
48+
}
49+
if ($elapsed -ge $timeout) {
50+
Write-Host "Docker failed to start within timeout"
51+
exit 1
52+
}
53+
54+
- name: Set up Docker (macOS)
55+
if: runner.os == 'macOS'
56+
run: |
57+
brew install colima docker docker-compose
58+
colima start --cpu 2 --memory 4
59+
echo "Waiting for Docker to be ready..."
60+
for i in {1..30}; do
61+
if docker info > /dev/null 2>&1; then
62+
echo "Docker is ready"
63+
break
64+
fi
65+
echo "Waiting for Docker... ($i/30)"
66+
sleep 10
67+
done
68+
docker version
69+
docker info
70+
2571
- name: Set up JDK ${{ matrix.java-version }}
2672
uses: actions/setup-java@v5
2773
with:
@@ -43,6 +89,27 @@ jobs:
4389
restore-keys: |
4490
${{ runner.os }}-gradle-
4591
92+
- name: Configure Docker environment (Windows)
93+
if: runner.os == 'Windows'
94+
shell: bash
95+
run: |
96+
echo "DOCKER_HOST=npipe:////./pipe/docker_engine" >> $GITHUB_ENV
97+
echo "TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock" >> $GITHUB_ENV
98+
echo "TESTCONTAINERS_HOST_OVERRIDE=localhost" >> $GITHUB_ENV
99+
100+
- name: Verify Docker is running (Unix)
101+
if: runner.os != 'Windows'
102+
run: |
103+
docker version
104+
docker info
105+
106+
- name: Verify Docker is running (Windows)
107+
if: runner.os == 'Windows'
108+
shell: bash
109+
run: |
110+
docker version
111+
docker info
112+
46113
- name: Run tests (Unix)
47114
if: runner.os != 'Windows'
48115
run: make ci-test
@@ -56,7 +123,7 @@ jobs:
56123
if: always()
57124
uses: actions/upload-artifact@v4
58125
with:
59-
name: test-results-${{ matrix.os }}
126+
name: test-results-${{ matrix.os }}-java${{ matrix.java-version }}
60127
path: |
61128
build/reports/tests/
62129
build/test-results/

src/test/java/com/example/arinfra/file/SecureTempFileManagerTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,29 @@ void should_create_writable_file() throws IOException {
308308
}
309309

310310
@Test
311-
void should_not_create_executable_file() throws IOException {
311+
void should_not_create_executable_file_on_unix() throws IOException {
312312
createdFile = subject.createSecureTempFile(TEST_PREFIX, TEST_SUFFIX);
313313

314314
assertFalse(createdFile.canExecute());
315315
}
316316

317+
@Test
318+
@EnabledOnOs(OS.WINDOWS)
319+
void should_handle_windows_executable_behavior() throws IOException {
320+
createdFile = subject.createSecureTempFile(TEST_PREFIX, TEST_SUFFIX);
321+
322+
// Windows doesn't use Unix-style executable bits
323+
// Files are executable based on extension (.exe, .bat, .cmd, etc.)
324+
// A .txt file should not be executable on Windows
325+
assertTrue(createdFile.isFile());
326+
assertFalse(createdFile.isDirectory());
327+
328+
String userTempDir = System.getProperty("java.io.tmpdir");
329+
assertTrue(createdFile.getAbsolutePath().startsWith(userTempDir));
330+
331+
// On Windows, canExecute() may return true for all files the user owns
332+
}
333+
317334
@Test
318335
void should_create_temp_directory_with_prefix() throws IOException {
319336
File createdDir = subject.createSecureTempDirectory(TEST_PREFIX);

0 commit comments

Comments
 (0)