Skip to content

Commit 753eca2

Browse files
committed
Fixing test failures
1 parent a34b78d commit 753eca2

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

.github/workflows/reusable-build.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,27 @@ jobs:
5555
}
5656
}
5757
58-
- name: Docker version
59-
run: docker version
58+
- name: Configure Docker to use WSL on Windows
59+
if: ${{ matrix.os == 'windows-latest' }}
60+
shell: powershell
61+
run: |
62+
$dockerPath = & where docker
63+
if ($dockerPath)
64+
{
65+
$dockercliPath = $dockerPath -replace "docker.exe", "dockercli.exe"
66+
if (Test-Path $dockercliPath)
67+
{
68+
& "$dockercliPath" -SwitchLinuxEngine
69+
}
70+
else
71+
{
72+
Write-Host "dockercli.exe not found at $dockercliPath"
73+
}
74+
}
75+
else
76+
{
77+
Write-Host "docker.exe not found"
78+
}
6079
6180
# Pull the images used by integration tests
6281
- name: Pull docker:dind

core/src/main/java/io/github/cowwoc/anchor4j/core/resource/DefaultBuildListener.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.BufferedReader;
1313
import java.io.FileNotFoundException;
1414
import java.io.IOException;
15+
import java.util.List;
1516
import java.util.StringJoiner;
1617
import java.util.concurrent.BlockingQueue;
1718
import java.util.concurrent.LinkedBlockingQueue;
@@ -28,8 +29,10 @@ public class DefaultBuildListener implements BuildListener
2829
"error reading preface from client .+?: file has already been closed\n");
2930
// Known variants:
3031
// ERROR: failed to build: resolve : (?:CreateFile|lstat) (.+?): The system cannot find the file specified.
31-
private static final Pattern FILE_NOT_FOUND = Pattern.compile("ERROR: failed to build: resolve : " +
32-
"(?:CreateFile|lstat) (.+?): The system cannot find the file specified\\.");
32+
// ERROR: resolve : lstat /home/runner/work/anchor4j/anchor4j/buildx/src/test/resources/missing: no such file or directory
33+
private static final List<Pattern> FILE_NOT_FOUND = List.of(
34+
Pattern.compile("ERROR: resolve : CreateFile (.+?): The system cannot find the file specified\\."),
35+
Pattern.compile("ERROR: resolve : lstat (.+?): no such file or directory"));
3336
private static final String DOCKER_DRIVER_DOES_NOT_SUPPORT_MANIFEST_LIST =
3437
"ERROR: failed to build: docker exporter does not currently support exporting manifest lists";
3538
private static final String DOCKER_DRIVER_DOES_NOT_SUPPORT_OCI =
@@ -42,7 +45,7 @@ public class DefaultBuildListener implements BuildListener
4245
private static final Pattern RESOURCE_IN_USE = Pattern.compile("""
4346
ERROR: failed to build: no valid drivers found: open (.+?): The process cannot access the file because \
4447
it is being used by another process\\.""");
45-
48+
4649
/**
4750
* The lines returned by the build's standard output stream.
4851
*/
@@ -163,9 +166,12 @@ public void buildFailed(CommandResult result) throws IOException
163166
// "2025/06/11 15:53:20 http2: server: error reading preface from client //./pipe/dockerDesktopLinuxEngine: file has already been closed"
164167
stderr = stderr.substring(matcher.end());
165168
}
166-
matcher = FILE_NOT_FOUND.matcher(stderr);
167-
if (matcher.matches())
168-
throw new FileNotFoundException(matcher.group(1));
169+
for (Pattern pattern : FILE_NOT_FOUND)
170+
{
171+
matcher = pattern.matcher(stderr);
172+
if (matcher.matches())
173+
throw new FileNotFoundException(matcher.group(1));
174+
}
169175
matcher = BuildXParser.NOT_FOUND.matcher(stderr);
170176
if (matcher.matches())
171177
throw new BuilderNotFoundException(matcher.group(1));

0 commit comments

Comments
 (0)