You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2023/02/21 00:11:10 UTC
[maven-build-cache-extension] branch master updated: use our shared GHA buiid, add dependabot and release (#41)
This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-build-cache-extension.git
The following commit(s) were added to refs/heads/master by this push:
new 28baa8e use our shared GHA buiid, add dependabot and release (#41)
28baa8e is described below
commit 28baa8e666ed70f8050eec4c68937593bdccef7e
Author: Olivier Lamy <ol...@apache.org>
AuthorDate: Tue Feb 21 10:11:04 2023 +1000
use our shared GHA buiid, add dependabot and release (#41)
could run on osx windows except if no docker
Signed-off-by: Olivier Lamy <ol...@apache.org>
---
.github/dependabot.yml | 30 +++++
.github/release-drafter.yml | 19 +++
.github/workflows/maven-verify.yml | 34 +++++
.github/workflows/maven.yml | 54 --------
.github/workflows/release-drafter.yml | 25 ++++
pom.xml | 146 +++++++++------------
.../BuildCacheMojosExecutionStrategy.java | 15 ++-
.../apache/maven/buildcache/xml/XmlService.java | 10 ++
.../BuildCacheMojosExecutionStrategyTest.java | 18 ++-
.../maven/buildcache/its/RemoteCacheDavTest.java | 42 ++++--
src/test/resources/logback.xml | 4 +-
11 files changed, 240 insertions(+), 157 deletions(-)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..ccf1b48
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,30 @@
+# 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.
+
+version: 2
+updates:
+ - package-ecosystem: "maven"
+ directory: "/"
+ schedule:
+ interval: "daily"
+ ignore:
+ # ignore Maven Core updates
+ - dependency-name: "org.apache.maven:*"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml
new file mode 100644
index 0000000..73dffa3
--- /dev/null
+++ b/.github/release-drafter.yml
@@ -0,0 +1,19 @@
+# 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.
+
+_extends: maven-gh-actions-shared
+tag-template: maven-build-cache-extension-$NEXT_MINOR_VERSION
diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml
new file mode 100644
index 0000000..29d448d
--- /dev/null
+++ b/.github/workflows/maven-verify.yml
@@ -0,0 +1,34 @@
+# 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.
+
+name: Verify
+
+on:
+ push:
+ pull_request:
+
+jobs:
+ build:
+ name: Verify
+ uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3
+ with:
+ maven-args: '-D"maven.test.redirectTestOutputToFile=false"'
+ maven-matrix: '[ "3.9.0", "4.0.0-alpha-4" ]'
+ matrix-exclude: >
+ [
+ {"jdk": "8"}
+ ]
\ No newline at end of file
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index 2a77fdc..0000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-# 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.
-
-name: Java CI
-
-on: [push, pull_request]
-
-jobs:
- build:
- strategy:
- matrix:
- os: [ubuntu-latest, macOS-latest]
- java: [11, 17]
- maven: [maven3, maven4]
- fail-fast: false
-
- runs-on: ${{ matrix.os }}
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Setup Java
- uses: actions/setup-java@v2
- with:
- java-version: ${{ matrix.java }}
- distribution: 'temurin'
- cache: 'maven'
-
- - name: Cache maven local repository
- uses: actions/cache@v1
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-
-
- - name: Build with Maven
- run: mvn verify -e -B -V -P${{ matrix.maven }} -P run-its
-
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
new file mode 100644
index 0000000..b44872c
--- /dev/null
+++ b/.github/workflows/release-drafter.yml
@@ -0,0 +1,25 @@
+# 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.
+
+name: Release Drafter
+on:
+ push:
+ branches:
+ - master
+jobs:
+ update_release_draft:
+ uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v3
diff --git a/pom.xml b/pom.xml
index 95c350b..6339a79 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@ under the License.
<classWorldsVersion>2.6.0</classWorldsVersion>
<!-- default maven version, can be override by maven3 profile -->
- <mavenVersion>4.0.0-alpha-2</mavenVersion>
+ <mavenVersion>4.0.0-alpha-4</mavenVersion>
<maven.dir>maven4</maven.dir>
<maven.basedir>${project.build.directory}/${maven.dir}</maven.basedir>
@@ -228,47 +228,62 @@ under the License.
</dependencies>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <release>${javaVersion}</release>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Xmx256m --add-exports java.base/sun.nio.ch=ALL-UNNAMED</argLine>
+ <environmentVariables>
+ <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED>
+ <TESTCONTAINERS_RYUK_DISABLED>true</TESTCONTAINERS_RYUK_DISABLED>
+ </environmentVariables>
+ </configuration>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <phase>test</phase>
+ <configuration>
+ <excludes>**/its/**</excludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>3.5.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>.mvn/maven.config</exclude>
+ <exclude>.asf.yaml</exclude>
+ <exclude>src/test/resources*/**</exclude>
+ <exclude>src/test/projects/**</exclude>
+ <exclude>src/test/remote-repo/**</exclude>
+ <exclude>src/build/maven-header.txt</exclude>
+ <exclude>.gitmodules</exclude>
+ <exclude>.gitattributes</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>.mvn/maven.config</exclude>
- <exclude>.asf.yaml</exclude>
- <exclude>src/test/resources*/**</exclude>
- <exclude>src/test/projects/**</exclude>
- <exclude>src/test/remote-repo/**</exclude>
- <exclude>src/build/maven-header.txt</exclude>
- <exclude>.gitmodules</exclude>
- <exclude>.gitattributes</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <!--
- <version>3.1.2</version>
- <configuration>
- <violationSeverity>info</violationSeverity>
- <suppressionsLocation>${maven.multiModuleProjectDirectory}/src/build/checkstyle-suppressions.xml</suppressionsLocation>
- <headerLocation>${maven.multiModuleProjectDirectory}/src/build/maven-header.txt</headerLocation>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>com.puppycrawl.tools</groupId>
- <artifactId>checkstyle</artifactId>
- <version>8.41.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-shared-resources</artifactId>
- <version>3</version>
- </dependency>
- </dependencies>
- -->
- </plugin>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
@@ -332,14 +347,6 @@ under the License.
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.10.1</version>
- <configuration>
- <release>${javaVersion}</release>
- </configuration>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
@@ -367,35 +374,6 @@ under the License.
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>3.0.0-M7</version>
- <configuration>
- <argLine>-Xmx256m --add-exports java.base/sun.nio.ch=ALL-UNNAMED</argLine>
- <environmentVariables>
- <JENKINS_MAVEN_AGENT_DISABLED>true</JENKINS_MAVEN_AGENT_DISABLED>
- <TESTCONTAINERS_RYUK_DISABLED>true</TESTCONTAINERS_RYUK_DISABLED>
- </environmentVariables>
- </configuration>
- <executions>
- <execution>
- <id>default-test</id>
- <goals>
- <goal>test</goal>
- </goals>
- <phase>test</phase>
- <configuration>
- <excludes>**/its/**</excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>3.4.0</version>
- </plugin>
</plugins>
</build>
@@ -406,8 +384,7 @@ under the License.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>3.0.0-M7</version>
+ <artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<!-- local repo provided by m-invoker-p:install -->
@@ -416,17 +393,16 @@ under the License.
<maven.multiModuleProjectDirectory>${maven.multiModuleProjectDirectory}</maven.multiModuleProjectDirectory>
<maven.basedir>${maven.basedir}</maven.basedir>
</systemPropertyVariables>
+ <includes>**/its/**</includes>
</configuration>
<executions>
<execution>
- <id>integration-test</id>
+ <id>it-tests</id>
<goals>
- <goal>test</goal>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
</goals>
<phase>integration-test</phase>
- <configuration>
- <includes>**/its/**</includes>
- </configuration>
</execution>
</executions>
</plugin>
diff --git a/src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java b/src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java
index 72306d6..6f704a7 100644
--- a/src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java
+++ b/src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java
@@ -312,7 +312,20 @@ public class BuildCacheMojosExecutionStrategy implements MojosExecutionStrategy
*/
private static String normalizedPath(Path path, Path baseDirPath) {
boolean isProjectSubdir = path.isAbsolute() && path.startsWith(baseDirPath);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(
+ "normalizedPath isProjectSubdir {} path '{}' - baseDirPath '{}', path.isAbsolute() {}, path.startsWith(baseDirPath) {}",
+ isProjectSubdir,
+ path,
+ baseDirPath,
+ path.isAbsolute(),
+ path.startsWith(baseDirPath));
+ }
Path preparedPath = isProjectSubdir ? baseDirPath.relativize(path) : path;
- return preparedPath.normalize().toString();
+ String normalizedPath = preparedPath.normalize().toString();
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("normalizedPath '{}' - {} return {}", path, baseDirPath, normalizedPath);
+ }
+ return normalizedPath;
}
}
diff --git a/src/main/java/org/apache/maven/buildcache/xml/XmlService.java b/src/main/java/org/apache/maven/buildcache/xml/XmlService.java
index 7583cd5..eaba25e 100644
--- a/src/main/java/org/apache/maven/buildcache/xml/XmlService.java
+++ b/src/main/java/org/apache/maven/buildcache/xml/XmlService.java
@@ -148,6 +148,16 @@ public class XmlService {
}
} catch (IOException | XmlPullParserException e) {
throw new RuntimeException("Unable to parse cache xml element", e);
+ } finally {
+ closeQuietly(inputStream);
+ }
+ }
+
+ private void closeQuietly(InputStream inputStream) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // ignore
}
}
}
diff --git a/src/test/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategyTest.java b/src/test/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategyTest.java
index 3fc2b29..380c0b2 100644
--- a/src/test/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategyTest.java
+++ b/src/test/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategyTest.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.Lists;
+import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.buildcache.xml.CacheConfig;
import org.apache.maven.buildcache.xml.build.CompletedExecution;
import org.apache.maven.buildcache.xml.build.PropertyValue;
@@ -71,11 +72,13 @@ class BuildCacheMojosExecutionStrategyTest {
@Test
void testBasicParamsMatching() {
+ boolean windows = SystemUtils.IS_OS_WINDOWS;
+
List<Pair<TrackedProperty, PropertyValue>> cacheProperties = Lists.newArrayList(
setupProperty("bool", "true"),
setupProperty("primitive", "1"),
setupProperty("file", "c"),
- setupProperty("path", "../d/e"),
+ setupProperty("path", windows ? "..\\d\\e" : "../d/e"),
setupProperty("list", "[a, b, c]"),
setupProperty("array", "{c,d,e}"),
setupProperty("nullObject", null));
@@ -89,12 +92,17 @@ class BuildCacheMojosExecutionStrategyTest {
when(cacheConfigMock.getTrackedProperties(executionMock)).thenReturn(trackedProperties);
when(cacheRecordMock.getProperties()).thenReturn(cacheRecordProperties);
- when(projectMock.getBasedir()).thenReturn(new File("/a/b"));
+ when(projectMock.getBasedir()).thenReturn(windows ? new File("c:\\a\\b") : new File("/a/b"));
TestMojo testMojo = TestMojo.create(
- true, 1, new File("/a/b/c"), Paths.get("../d/e"), Lists.newArrayList("a", "b", "c"), new String[] {
- "c", "d", "e"
- });
+ true,
+ 1,
+ windows
+ ? Paths.get("c:\\a\\b\\c").toFile()
+ : Paths.get("/a/b/c").toFile(),
+ Paths.get(windows ? "..\\d\\e" : "../d/e"),
+ Lists.newArrayList("a", "b", "c"),
+ new String[] {"c", "d", "e"});
assertTrue(strategy.isParamsMatched(projectMock, executionMock, testMojo, cacheRecordMock));
}
diff --git a/src/test/java/org/apache/maven/buildcache/its/RemoteCacheDavTest.java b/src/test/java/org/apache/maven/buildcache/its/RemoteCacheDavTest.java
index 55afd48..595be62 100644
--- a/src/test/java/org/apache/maven/buildcache/its/RemoteCacheDavTest.java
+++ b/src/test/java/org/apache/maven/buildcache/its/RemoteCacheDavTest.java
@@ -51,9 +51,12 @@ import org.apache.maven.buildcache.its.junit.IntegrationTestExtension;
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.jetbrains.annotations.NotNull;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@@ -64,9 +67,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@IntegrationTest("src/test/projects/remote-cache-dav")
@Testcontainers(disabledWithoutDocker = true)
-@EnabledOnOs(OS.LINUX) // github actions do not support docker on windows and osx
public class RemoteCacheDavTest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(RemoteCacheDavTest.class);
public static final String DAV_DOCKER_IMAGE =
"xama/nginx-webdav@sha256:84171a7e67d7e98eeaa67de58e3ce141ec1d0ee9c37004e7096698c8379fd9cf";
private static final String DAV_USERNAME = "admin";
@@ -118,17 +121,34 @@ public class RemoteCacheDavTest {
.withFileSystemBind(remoteCache.toString(), "/var/webdav/public");
}
- @Test
- void testRemoteCacheWithWagon() throws VerificationException, IOException {
- doTestRemoteCache("wagon");
+ @AfterEach
+ public void cleanup() throws Exception {
+
+ org.testcontainers.containers.Container.ExecResult result =
+ dav.execInContainer("ls", "-lrt", "/var/webdav/public/");
+
+ LOGGER.info("before clean in container result: {}", result);
+
+ result = dav.execInContainer("rm", "-rf", "/var/webdav/public");
+
+ LOGGER.info("clean in container result: {}", result);
+
+ result = dav.execInContainer("ls", "-lrt", "/var/webdav/");
+
+ LOGGER.info("after clean in container result: {}", result);
+
+ cleanDirs(localCache, remoteCache.resolve("mbce"));
+
+ dav.close();
}
- @Test
- void testRemoteCacheWithHttp() throws VerificationException, IOException {
- doTestRemoteCache("http");
+ public static Stream<Arguments> transports() {
+ return Stream.of(Arguments.of("wagon"), Arguments.of("http"));
}
- protected void doTestRemoteCache(String transport) throws VerificationException, IOException {
+ @ParameterizedTest
+ @MethodSource("transports")
+ public void doTestRemoteCache(String transport) throws VerificationException, IOException {
String url =
("wagon".equals(transport) ? "dav:" : "") + "http://localhost:" + dav.getFirstMappedPort() + "/mbce";
substitute(
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
index 342e954..88be419 100644
--- a/src/test/resources/logback.xml
+++ b/src/test/resources/logback.xml
@@ -31,7 +31,9 @@
</encoder>
</appender>
- <root level="DEBUG">
+ <logger name="org.apache.maven.buildcache.BuildCacheMojosExecutionStrategy" level="debug"/>
+
+ <root level="INFO">
<appender-ref ref="CONSOLE" />
</root>