Skip to content

Commit dc3fa35

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

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

.github/workflows/ci-test.yml

Lines changed: 51 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,34 @@ 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: bash
28+
run: |
29+
echo "Checking Docker status on Windows..."
30+
# Windows runners have Docker pre-installed and running
31+
docker version
32+
docker info
33+
echo "Docker is available"
34+
35+
- name: Set up Docker (macOS)
36+
if: runner.os == 'macOS'
37+
run: |
38+
brew install colima docker docker-compose
39+
# Use QEMU instead of VZ for better compatibility in CI
40+
colima start --cpu 2 --memory 4 --vm-type=qemu
41+
echo "Waiting for Docker to be ready..."
42+
for i in {1..30}; do
43+
if docker info > /dev/null 2>&1; then
44+
echo "Docker is ready"
45+
break
46+
fi
47+
echo "Waiting for Docker... ($i/30)"
48+
sleep 10
49+
done
50+
docker version
51+
docker info
52+
2553
- name: Set up JDK ${{ matrix.java-version }}
2654
uses: actions/setup-java@v5
2755
with:
@@ -43,6 +71,27 @@ jobs:
4371
restore-keys: |
4472
${{ runner.os }}-gradle-
4573
74+
- name: Configure Docker environment (Windows)
75+
if: runner.os == 'Windows'
76+
shell: bash
77+
run: |
78+
echo "DOCKER_HOST=npipe:////./pipe/docker_engine" >> $GITHUB_ENV
79+
echo "TESTCONTAINERS_RYUK_DISABLED=true" >> $GITHUB_ENV
80+
echo "TESTCONTAINERS_CHECKS_DISABLE=true" >> $GITHUB_ENV
81+
82+
- name: Verify Docker is running (Unix)
83+
if: runner.os != 'Windows'
84+
run: |
85+
docker version
86+
docker info
87+
88+
- name: Verify Docker is running (Windows)
89+
if: runner.os == 'Windows'
90+
shell: bash
91+
run: |
92+
docker version
93+
docker info
94+
4695
- name: Run tests (Unix)
4796
if: runner.os != 'Windows'
4897
run: make ci-test
@@ -56,7 +105,7 @@ jobs:
56105
if: always()
57106
uses: actions/upload-artifact@v4
58107
with:
59-
name: test-results-${{ matrix.os }}
108+
name: test-results-${{ matrix.os }}-java${{ matrix.java-version }}
60109
path: |
61110
build/reports/tests/
62111
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)