This is an automated email from the ASF dual-hosted git repository. wanghailin pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push: new ca94e3beb0 [Improve][CI]add code specification check (#8209) ca94e3beb0 is described below commit ca94e3beb0f4b5325e781839c2d3abb7659578da Author: zhangdonghao <39961809+hawk9...@users.noreply.github.com> AuthorDate: Thu Dec 5 09:40:57 2024 +0800 [Improve][CI]add code specification check (#8209) --- .github/workflows/backend.yml | 4 ++ pom.xml | 1 + seatunnel-ci-tools/pom.xml | 54 ++++++++++++++++++++++ .../seatunnel/api/ImportShadeClassCheckTest.java | 9 ++-- .../apache/seatunnel/api/UTClassNameCheckTest.java | 21 ++++++++- .../api/file/AllFileSpecificationCheckTest.java | 5 +- .../apache/seatunnel/api/file}/MarkdownTest.java | 2 +- seatunnel-dist/pom.xml | 10 ---- 8 files changed, 86 insertions(+), 20 deletions(-) diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index f75a867b4c..8f737a914f 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -54,6 +54,10 @@ jobs: submodules: true - name: Check code style run: ./mvnw --batch-mode --quiet --no-snapshot-updates clean spotless:check + - name: Check code specification + run: ./mvnw -B -T 1 clean test -D"license.skipAddThirdParty"=true -pl seatunnel-ci-tools -am --no-snapshot-updates + env: + MAVEN_OPTS: -Xmx512m dead-link: name: Dead links diff --git a/pom.xml b/pom.xml index e050018b2b..256ccfe7fb 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,7 @@ <module>seatunnel-examples</module> <module>seatunnel-e2e</module> <module>seatunnel-shade</module> + <module>seatunnel-ci-tools</module> </modules> <properties> diff --git a/seatunnel-ci-tools/pom.xml b/seatunnel-ci-tools/pom.xml new file mode 100644 index 0000000000..18084e0ed1 --- /dev/null +++ b/seatunnel-ci-tools/pom.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.seatunnel</groupId> + <artifactId>seatunnel</artifactId> + <version>${revision}</version> + </parent> + + <artifactId>seatunnel-ci-tools</artifactId> + <name>SeaTunnel : Tools : CI : Java</name> + + <properties> + <javaparser.version>3.26.1</javaparser.version> + </properties> + + <dependencies> + <dependency> + <groupId>com.github.javaparser</groupId> + <artifactId>javaparser-core</artifactId> + <version>${javaparser.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>8</source> + <target>8</target> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/ImportShadeClassCheckTest.java b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/ImportShadeClassCheckTest.java similarity index 96% rename from seatunnel-dist/src/test/java/org/apache/seatunnel/api/ImportShadeClassCheckTest.java rename to seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/ImportShadeClassCheckTest.java index e7e0a4152a..84cbddff27 100644 --- a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/ImportShadeClassCheckTest.java +++ b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/ImportShadeClassCheckTest.java @@ -31,6 +31,7 @@ import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.io.InputStream; +import java.nio.file.FileVisitOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -41,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import java.util.stream.Stream; import static java.nio.file.StandardOpenOption.READ; @@ -56,11 +58,8 @@ public class ImportShadeClassCheckTest { @BeforeAll public static void beforeAll() { - Path directoryPath = Paths.get(System.getProperty("user.dir")).getParent(); - log.info("work directory parent ===> " + directoryPath); - try { - Files.walk(directoryPath) - .filter(path -> path.toString().endsWith(JAVA_FILE_EXTENSION)) + try (Stream<Path> paths = Files.walk(Paths.get(".."), FileVisitOption.FOLLOW_LINKS)) { + paths.filter(path -> path.toString().endsWith(JAVA_FILE_EXTENSION)) .forEach( path -> { try (InputStream inputStream = Files.newInputStream(path, READ)) { diff --git a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/UTClassNameCheckTest.java b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/UTClassNameCheckTest.java similarity index 85% rename from seatunnel-dist/src/test/java/org/apache/seatunnel/api/UTClassNameCheckTest.java rename to seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/UTClassNameCheckTest.java index 17832b7218..55a20057b4 100644 --- a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/UTClassNameCheckTest.java +++ b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/UTClassNameCheckTest.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.seatunnel.api; import org.junit.jupiter.api.Assertions; @@ -11,6 +28,7 @@ import com.github.javaparser.ast.NodeList; import lombok.extern.slf4j.Slf4j; import java.io.IOException; +import java.nio.file.FileVisitOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -28,10 +46,9 @@ public class UTClassNameCheckTest { @Test public void checkUTClassName() { - Path directoryPath = Paths.get(System.getProperty("user.dir")).getParent(); String testPathFragment = isWindows ? "src\\test\\java" : "src/test/java"; - try (Stream<Path> paths = Files.walk(directoryPath)) { + try (Stream<Path> paths = Files.walk(Paths.get(".."), FileVisitOption.FOLLOW_LINKS)) { List<String> collect = paths.filter( path -> { diff --git a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/file/AllFileSpecificationCheckTest.java b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/file/AllFileSpecificationCheckTest.java similarity index 97% rename from seatunnel-dist/src/test/java/org/apache/seatunnel/api/file/AllFileSpecificationCheckTest.java rename to seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/file/AllFileSpecificationCheckTest.java index d51eb1dad4..73b07ae31e 100644 --- a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/file/AllFileSpecificationCheckTest.java +++ b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/file/AllFileSpecificationCheckTest.java @@ -114,11 +114,12 @@ public class AllFileSpecificationCheckTest { "docs/en/concept/config.md", "seatunnel-api/src/main/java/org/apache/seatunnel/api/common/CommonOptions.java", "seatunnel-e2e/seatunnel-connector-v2-e2e/connector-fake-e2e/src/test/resources/fake_to_assert_with_compatible_source_and_result_table_name.conf", - "seatunnel-e2e/seatunnel-connector-v2-e2e/connector-fake-e2e/src/test/java/org/apache/seatunnel/e2e/connector/fake/FakeIT.java"); + "seatunnel-e2e/seatunnel-connector-v2-e2e/connector-fake-e2e/src/test/java/org/apache/seatunnel/e2e/connector/fake/FakeIT.java", + "seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/file/AllFileSpecificationCheckTest.java"); fileContents.forEach( (path, lines) -> { - if (whiteList.contains(path)) { + if (whiteList.contains(path.trim())) { return; } for (int i = 0; i < lines.size(); i++) { diff --git a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/connector/MarkdownTest.java b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/file/MarkdownTest.java similarity index 99% rename from seatunnel-dist/src/test/java/org/apache/seatunnel/api/connector/MarkdownTest.java rename to seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/file/MarkdownTest.java index 65e30ca00f..a1df76f44e 100644 --- a/seatunnel-dist/src/test/java/org/apache/seatunnel/api/connector/MarkdownTest.java +++ b/seatunnel-ci-tools/src/test/java/org/apache/seatunnel/api/file/MarkdownTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.seatunnel.api.connector; +package org.apache.seatunnel.api.file; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; diff --git a/seatunnel-dist/pom.xml b/seatunnel-dist/pom.xml index 79a4f93e0d..e1e77616f0 100644 --- a/seatunnel-dist/pom.xml +++ b/seatunnel-dist/pom.xml @@ -32,18 +32,8 @@ <properties> <!-- disable mvn deploy to central maven repo by default --> <maven.deploy.skip>true</maven.deploy.skip> - <javaparser.version>3.26.1</javaparser.version> </properties> - <dependencies> - <dependency> - <groupId>com.github.javaparser</groupId> - <artifactId>javaparser-core</artifactId> - <version>${javaparser.version}</version> - <scope>test</scope> - </dependency> - </dependencies> - <build> <finalName>apache-seatunnel-${project.version}</finalName> <plugins>