This is an automated email from the ASF dual-hosted git repository.
wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new d2a5d61f [Feature][CI] Support build on windows (#1697)
d2a5d61f is described below
commit d2a5d61ff5bbbae5e9ac2767ed8838607a985d06
Author: ChunFu Wu <[email protected]>
AuthorDate: Sat Apr 23 19:26:34 2022 +0800
[Feature][CI] Support build on windows (#1697)
* fix mvnw not found
* change --no-snapshot-updates to -nsu
* remove windows integration tests CI
---
.github/workflows/backend.yml | 40 ++++++++++++++++++++--
.../org/apache/seatunnel/common/config/Common.java | 2 ++
.../apache/seatunnel/common/config/CommonTest.java | 6 ++--
.../org/apache/seatunnel/config/CompleteTest.java | 5 +--
.../apache/seatunnel/config/ConfigFactoryTest.java | 13 +++----
.../apache/seatunnel/config/JsonFormatTest.java | 8 +++--
.../apache/seatunnel/config/utils/FileUtils.java | 13 +++----
7 files changed, 64 insertions(+), 23 deletions(-)
diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml
index b21ce3d1..b36acffd 100644
--- a/.github/workflows/backend.yml
+++ b/.github/workflows/backend.yml
@@ -31,8 +31,8 @@ concurrency:
cancel-in-progress: true
jobs:
- build:
- name: Build
+ build-on-ubuntu:
+ name: Build-on-ubuntu
runs-on: ubuntu-latest
strategy:
matrix:
@@ -76,3 +76,39 @@ jobs:
- name: Run Integration tests
run: |
./mvnw -T 2C -B clean verify -DskipUT=true -DskipIT=false
--no-snapshot-updates
+ build-on-windows:
+ name: Build-on-windows
+ runs-on: windows-latest
+ strategy:
+ matrix:
+ java: ['8']
+ timeout-minutes: 50
+ env:
+ MAVEN_OPTS: -Xmx2G -Xms2G
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK ${{ matrix.java }}
+ uses: actions/setup-java@v3
+ with:
+ java-version: ${{ matrix.java }}
+ distribution: 'temurin'
+ cache: 'maven'
+ - name: Cache local Maven repository
+ uses: actions/cache@v2
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+ - name: Check Style
+ shell: cmd
+ run: |
+ .\mvnw.cmd -T 2C -B checkstyle:check -nsu
+ - name: Build and Package
+ shell: cmd
+ run: |
+ .\mvnw.cmd -B install scalastyle:check -Dmaven.test.skip=true
-Dcheckstyle.skip=true -Dlicense.skipAddThirdParty=true -Dhttp.keepAlive=false
-Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.count=3
-Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -nsu
+ - name: Run Unit tests
+ shell: cmd
+ run: |
+ .\mvnw.cmd -T 2C -B clean verify -Dmaven.test.skip=false
-Dcheckstyle.skip=true -Dscalastyle.skip=true -Dlicense.skipAddThirdParty=true
-nsu
diff --git
a/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java
b/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java
index 88d35e5f..af1b60b0 100644
---
a/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java
+++
b/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java
@@ -17,6 +17,7 @@
package org.apache.seatunnel.common.config;
+import java.io.File;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -67,6 +68,7 @@ public class Common {
if (MODE.equals(Optional.of(DeployMode.CLIENT.getName()))) {
try {
String path =
Common.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
+ path = new File(path).getPath();
return Paths.get(path).getParent().getParent();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
diff --git
a/seatunnel-common/src/test/java/org/apache/seatunnel/common/config/CommonTest.java
b/seatunnel-common/src/test/java/org/apache/seatunnel/common/config/CommonTest.java
index 8c99c15c..ee715c10 100644
---
a/seatunnel-common/src/test/java/org/apache/seatunnel/common/config/CommonTest.java
+++
b/seatunnel-common/src/test/java/org/apache/seatunnel/common/config/CommonTest.java
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import java.io.File;
+
public class CommonTest {
static {
@@ -29,11 +31,11 @@ public class CommonTest {
@Test
public void appLibDir() {
- assertEquals(Common.appRootDir().toString() + "/lib",
Common.appLibDir().toString());
+ assertEquals(Common.appRootDir().toString() + File.separator + "lib",
Common.appLibDir().toString());
}
@Test
public void pluginTarFile() {
- assertEquals(Common.appRootDir().toString() + "/plugins.tar.gz",
Common.pluginTarball().toString());
+ assertEquals(Common.appRootDir().toString() + File.separator +
"plugins.tar.gz", Common.pluginTarball().toString());
}
}
diff --git
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java
index 0528aa3c..0ec86684 100644
---
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java
+++
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java
@@ -26,13 +26,14 @@ import
org.apache.seatunnel.shade.com.typesafe.config.ConfigResolveOptions;
import org.junit.Assert;
import org.junit.Test;
+import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
public class CompleteTest {
@Test
- public void testVariables() {
+ public void testVariables() throws URISyntaxException {
// We use a map to mock the system property, since the system property
will be only loaded once
// after the test is run. see Issue #1670
Map<String, String> systemProperties = new HashMap<>();
@@ -40,7 +41,7 @@ public class CompleteTest {
systemProperties.put("city2", "shanghai");
Config config = ConfigFactory
-
.parseFile(FileUtils.getFileFromResources("seatunnel/variables.conf"))
+
.parseFile(FileUtils.getFileFromResources("/seatunnel/variables.conf"))
.resolveWith(ConfigFactory.parseMap(systemProperties),
ConfigResolveOptions.defaults().setAllowUnresolved(true));
String sql1 =
config.getConfigList("transform").get(1).getString("sql");
String sql2 =
config.getConfigList("transform").get(2).getString("sql");
diff --git
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/ConfigFactoryTest.java
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/ConfigFactoryTest.java
index c0250e62..7c24368c 100644
---
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/ConfigFactoryTest.java
+++
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/ConfigFactoryTest.java
@@ -25,15 +25,16 @@ import
org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;
import org.junit.Assert;
import org.junit.Test;
+import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
public class ConfigFactoryTest {
@Test
- public void testBasicParseAppConf() {
+ public void testBasicParseAppConf() throws URISyntaxException {
- Config config =
ConfigFactory.parseFile(FileUtils.getFileFromResources("factory/config.conf"));
+ Config config =
ConfigFactory.parseFile(FileUtils.getFileFromResources("/factory/config.conf"));
Assert.assertTrue(config.hasPath("env"));
Assert.assertTrue(config.hasPath("source"));
@@ -53,9 +54,9 @@ public class ConfigFactoryTest {
}
@Test
- public void testTransformOrder() {
+ public void testTransformOrder() throws URISyntaxException {
- Config config =
ConfigFactory.parseFile(FileUtils.getFileFromResources("factory/config.conf"));
+ Config config =
ConfigFactory.parseFile(FileUtils.getFileFromResources("/factory/config.conf"));
String[] pluginNames = {"split", "sql1", "sql2", "sql3", "json"};
@@ -70,11 +71,11 @@ public class ConfigFactoryTest {
}
@Test
- public void testQuotedString() {
+ public void testQuotedString() throws URISyntaxException {
List<String> keys = Arrays.asList("spark.app.name",
"spark.executor.instances", "spark.executor.cores",
"spark.executor.memory", "spark.streaming.batchDuration");
- Config config =
ConfigFactory.parseFile(FileUtils.getFileFromResources("factory/config.conf"));
+ Config config =
ConfigFactory.parseFile(FileUtils.getFileFromResources("/factory/config.conf"));
Config evnConfig = config.getConfig("env");
evnConfig.entrySet().forEach(entry ->
Assert.assertTrue(keys.contains(entry.getKey())));
diff --git
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/JsonFormatTest.java
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/JsonFormatTest.java
index d16c798a..faca079e 100644
---
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/JsonFormatTest.java
+++
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/JsonFormatTest.java
@@ -26,18 +26,20 @@ import
org.apache.seatunnel.shade.com.typesafe.config.ConfigResolveOptions;
import org.junit.Assert;
import org.junit.Test;
+import java.net.URISyntaxException;
+
public class JsonFormatTest {
@Test
- public void testJsonFormat() {
+ public void testJsonFormat() throws URISyntaxException {
Config json = ConfigFactory
-
.parseFile(FileUtils.getFileFromResources("json/spark.batch.json"))
+
.parseFile(FileUtils.getFileFromResources("/json/spark.batch.json"))
.resolveWith(ConfigFactory.systemProperties(),
ConfigResolveOptions.defaults().setAllowUnresolved(true));
Config config = ConfigFactory
-
.parseFile(FileUtils.getFileFromResources("json/spark.batch.conf"))
+
.parseFile(FileUtils.getFileFromResources("/json/spark.batch.conf"))
.resolveWith(ConfigFactory.systemProperties(),
ConfigResolveOptions.defaults().setAllowUnresolved(true));
diff --git
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/utils/FileUtils.java
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/utils/FileUtils.java
index c106494f..3b0e01b7 100644
---
a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/utils/FileUtils.java
+++
b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/utils/FileUtils.java
@@ -18,7 +18,9 @@
package org.apache.seatunnel.config.utils;
import java.io.File;
+import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.file.Paths;
public final class FileUtils {
@@ -26,17 +28,12 @@ public final class FileUtils {
}
// get file from classpath, resources folder
- public static File getFileFromResources(String fileName) {
-
- ClassLoader classLoader = FileUtils.class.getClassLoader();
-
- URL resource = classLoader.getResource(fileName);
+ public static File getFileFromResources(String fileName) throws
URISyntaxException {
+ URL resource = FileUtils.class.getResource(fileName);
if (resource == null) {
throw new IllegalArgumentException("file is not found!");
- } else {
- return new File(resource.getFile());
}
-
+ return Paths.get(resource.toURI()).toFile();
}
}