Skip to content

Commit 8679a99

Browse files
authored
[DXP-1821] Windows fixes (#211)
1 parent 233e870 commit 8679a99

File tree

23 files changed

+117
-31
lines changed

23 files changed

+117
-31
lines changed

.github/workflows/ci-test-build.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permissions:
1111
contents: read
1212

1313
jobs:
14-
test-build:
14+
linux-test-build:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout
@@ -36,3 +36,28 @@ jobs:
3636
- name: Build project
3737
run: |
3838
./mvnw clean verify -P all-tests
39+
windows-test-build:
40+
runs-on: windows-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
with:
45+
fetch-depth: 0
46+
47+
- id: 'auth'
48+
name: 'Authenticate to Google Cloud'
49+
uses: 'google-github-actions/auth@v2'
50+
with:
51+
workload_identity_provider: ${{ secrets.GCP_STREAMX_RELEASES_WORKLOAD_IDENTITY_PROVIDER }}
52+
service_account: ${{ secrets.GCP_STREAMX_RELEASES_READ_SA }}
53+
54+
- name: Set up JDK 17
55+
uses: actions/setup-java@v3
56+
with:
57+
java-version: '17'
58+
distribution: 'adopt'
59+
cache: 'maven'
60+
61+
- name: Build project
62+
run: |
63+
./mvnw clean verify "-Djacoco.skip=true" -P all-tests

core/src/main/java/dev/streamx/cli/ParameterExceptionHandler.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ public int handleParseException(ParameterException ex, String[] args) {
2828
writer.println(cmd.getHelp().fullSynopsis());
2929

3030
CommandSpec spec = cmd.getCommandSpec();
31-
writer.printf("Try '%s --help' for more information.%n", spec.qualifiedName());
31+
writer.printf("Try '%s --help' for more information.", spec.qualifiedName());
32+
writer.println();
3233

3334
if (cmd.getExitCodeExceptionMapper() != null) {
3435
return cmd.getExitCodeExceptionMapper().getExitCode(ex);
3536
}
3637
return spec.exitCodeOnInvalidInput();
3738
}
38-
}
39+
}

core/src/main/java/dev/streamx/cli/command/ingestion/batch/BatchCommand.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ protected void doRun(StreamxClient client) throws StreamxClientException {
8989
} catch (FileIngestionException e) {
9090
throw new RuntimeException(
9191
ExceptionUtils.appendLogSuggestion(
92-
"Error performing batch publication while processing '" + e.getPath() + "' file.\n"
92+
"Error performing batch publication while processing '"
93+
+ FileUtils.toString(e.getPath()) + "' file.\n"
9394
+ "\n"
9495
+ "Details:\n"
9596
+ e.getCause().getMessage()), e);
@@ -135,12 +136,12 @@ private void updateCommandState(Path file, EventSourceDescriptor eventSource) {
135136

136137
String relativePath = calculateRelativePath(file, eventSource);
137138
Map<String, String> variables = substitutor.createSubstitutionVariables(
138-
file.toString(), eventSource.getChannel(), relativePath);
139+
FileUtils.toString(file), eventSource.getChannel(), relativePath);
139140

140141
String key = substitutor.substitute(variables, eventSource.getKey());
141142
JsonNode message = executeHandlingException(
142143
() -> payloadResolver.createPayload(eventSource, variables),
143-
() -> "Could not resolve payload for file '" + file + "'"
144+
() -> "Could not resolve payload for file '" + FileUtils.toString(file) + "'"
144145
);
145146

146147
Map<String, String> properties = createProperties(eventSource, variables);
@@ -177,11 +178,11 @@ private <T> T executeHandlingException(Supplier<T> function,
177178
private String calculateRelativePath(Path file, EventSourceDescriptor eventSource) {
178179
String relativePath;
179180
if (eventSource.getRelativePathLevel() == null) {
180-
relativePath = Path.of(batchIngestionArguments.getSourceDirectory()).relativize(file)
181-
.toString();
181+
relativePath = FileUtils.toString(
182+
Path.of(batchIngestionArguments.getSourceDirectory()).relativize(file));
182183
} else {
183-
relativePath = FileUtils.getNthParent(eventSource.getSource(),
184-
eventSource.getRelativePathLevel()).relativize(file).toString();
184+
relativePath = FileUtils.toString(FileUtils.getNthParent(eventSource.getSource(),
185+
eventSource.getRelativePathLevel()).relativize(file));
185186
}
186187
return relativePath;
187188
}

core/src/main/java/dev/streamx/cli/command/ingestion/batch/walker/EventSourceFileTreeWalker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void processDirectory(Path dir, EventSourceDescriptor currentDescriptor)
9090
for (Path entry : stream) {
9191
if (Files.isRegularFile(entry)
9292
// Skip .eventsource.yaml files
93-
&& !EventSourceDescriptor.FILENAME.equals(entry.getFileName().toString())
93+
&& !EventSourceDescriptor.FILENAME.equals(FileUtils.toString(entry.getFileName()))
9494
&& noIgnorePatternMatches(entry, currentDescriptor)) {
9595
processor.apply(entry, currentDescriptor);
9696
}
@@ -109,8 +109,8 @@ private boolean noIgnorePatternMatches(Path payloadFile, EventSourceDescriptor d
109109
}
110110

111111
int level = descriptor.getRelativePathLevel() == null ? 0 : descriptor.getRelativePathLevel();
112-
String relativePath = FileUtils.getNthParent(descriptor.getSource(), level)
113-
.relativize(payloadFile).toString();
112+
String relativePath = FileUtils.toString(FileUtils.getNthParent(descriptor.getSource(), level)
113+
.relativize(payloadFile));
114114

115115
// Check against each ignore pattern.
116116
for (String regex : patterns) {

core/src/main/java/dev/streamx/cli/command/ingestion/stream/StreamCommand.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import dev.streamx.cli.command.ingestion.BaseIngestionCommand;
88
import dev.streamx.cli.command.ingestion.stream.parser.StreamIngestionJsonParser;
99
import dev.streamx.cli.util.ExceptionUtils;
10+
import dev.streamx.cli.util.FileUtils;
1011
import dev.streamx.clients.ingestion.exceptions.StreamxClientException;
1112
import dev.streamx.clients.ingestion.publisher.Publisher;
1213
import dev.streamx.clients.ingestion.publisher.SuccessResult;
@@ -57,10 +58,11 @@ protected void perform(Publisher<JsonNode> publisher) throws StreamxClientExcept
5758
} catch (IOException | IllegalArgumentException e) {
5859
throw new RuntimeException(
5960
ExceptionUtils.appendLogSuggestion(
60-
"Error performing stream publication using '" + streamFile + "' file.\n"
61-
+ "\n"
62-
+ "Details:\n"
63-
+ e.getMessage()), e);
61+
"Error performing stream publication using '"
62+
+ FileUtils.toString(streamFile) + "' file.\n"
63+
+ "\n"
64+
+ "Details:\n"
65+
+ e.getMessage()), e);
6466
}
6567
}
6668

@@ -70,4 +72,4 @@ private static String getRequiredProperty(JsonNode message, String property) {
7072
}
7173
return message.get(property).asText();
7274
}
73-
}
75+
}

core/src/main/java/dev/streamx/cli/command/init/project/template/ProdProjectTemplateSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class ProdProjectTemplateSource implements ProjectTemplateSource {
44

55
public static final String PROD_PROJECT_TEMPLATE_SOURCE_URL =
6-
"git@github.com:streamx-dev/streamx-sample-project.git";
6+
"https://github.com/streamx-dev/streamx-sample-project.git";
77

88
@Override
99
public String getRepoUrl() {

core/src/main/java/dev/streamx/cli/settings/SettingsStore.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.ObjectMapper;
44
import dev.streamx.cli.exception.SettingsFileException;
5+
import dev.streamx.cli.util.FileUtils;
56
import jakarta.enterprise.context.ApplicationScoped;
67
import jakarta.inject.Inject;
78
import java.io.IOException;
@@ -31,7 +32,7 @@ public <T> Optional<T> retrieveSettings(String settingFile, Class<T> clazz) {
3132
return Optional.empty();
3233
}
3334
} catch (IOException e) {
34-
throw new SettingsFileException(path.toString(), e);
35+
throw new SettingsFileException(FileUtils.toString(path), e);
3536
}
3637
}
3738

@@ -43,13 +44,13 @@ public <T> void updateSettings(String settingFile, T settings) {
4344
Files.createDirectories(rootPath);
4445
}
4546
} catch (IOException e) {
46-
throw new SettingsFileException(path.toString(), e);
47+
throw new SettingsFileException(FileUtils.toString(path), e);
4748
}
4849

4950
try {
5051
objectMapper.writeValue(path.toFile(), settings);
5152
} catch (IOException e) {
52-
throw new SettingsFileException(path.toString(), e);
53+
throw new SettingsFileException(FileUtils.toString(path), e);
5354
}
5455
}
5556

core/src/main/java/dev/streamx/cli/util/FileUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ public static Path getNthParent(Path path, int n) {
4242
}
4343
return current;
4444
}
45+
46+
public static String toString(Path path) {
47+
return path.toString().replace("\\", "/");
48+
}
4549
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.streamx.cli;
2+
3+
import dev.streamx.runner.validation.DockerEnvironmentValidator;
4+
import org.apache.commons.lang3.StringEscapeUtils;
5+
6+
public class OsUtils {
7+
public static final String ESCAPED_LINE_SEPARATOR =
8+
StringEscapeUtils.escapeJson(System.lineSeparator());
9+
10+
public static boolean isDockerAvailable() {
11+
try {
12+
new DockerEnvironmentValidator().validateDockerClient();
13+
return true;
14+
} catch (Exception e) {
15+
return false;
16+
}
17+
}
18+
}

core/src/test/java/dev/streamx/cli/command/cloud/ProjectUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public static Path getProjectPath() {
2626
public static String getResource(String resourceName) throws IOException {
2727
try (InputStream is = ServiceMeshResolverTest.class.getResourceAsStream(
2828
PROJECT_PATH + resourceName)) {
29-
return new String(is.readAllBytes(), StandardCharsets.UTF_8);
29+
return new String(is.readAllBytes(), StandardCharsets.UTF_8)
30+
.replace("\r\n", "\n");
3031
}
3132
}
3233
}

0 commit comments

Comments
 (0)