This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/master by this push: new 12b3dae3ce Add CI cache (#1914) 12b3dae3ce is described below commit 12b3dae3ce26e4f7d04ecf69516b4b515db705b7 Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Sun Nov 17 15:50:32 2024 +0100 Add CI cache (#1914) * Add cache for all steps * Pass through the maven.repo.loca.tail property --- .github/workflows/maven.yml | 31 +++++++++++++++++----- its/core-it-suite/pom.xml | 22 +++++++++++++++ .../maven/it/MavenITmng8181CentralRepoTest.java | 1 + .../main/java/org/apache/maven/it/Verifier.java | 14 ++++++++-- 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 15de9cda99..6d05d23547 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -45,9 +45,10 @@ jobs: uses: actions/cache@v4 with: path: ~/.m2/repository/cached - key: maven-${{ hashFiles('**/pom.xml') }} - restore-keys: maven- - enableCrossOsArchive: true + key: maven-${{ runner.os }}-initial-${{ hashFiles('**/pom.xml') }} + restore-keys: | + maven-${{ runner.os }}-initial- + maven-${{ runner.os }}- - name: Set up Maven shell: bash @@ -55,7 +56,7 @@ jobs: - name: Build Maven distributions shell: bash - run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven + run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven -Dmaven.repo.local=$HOME/.m2/repository/cached - name: List contents of target directory shell: bash @@ -123,9 +124,18 @@ jobs: echo "MAVEN_HOME=$PWD/maven-local" >> $GITHUB_ENV echo "$PWD/maven-local/bin" >> $GITHUB_PATH + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2/repository/cached + key: maven-${{ runner.os }}-full-${{ hashFiles('**/pom.xml') }} + restore-keys: | + maven-${{ runner.os }}-full- + maven-${{ runner.os }}- + - name: Build site with downloaded Maven shell: bash - run: mvn verify site -e -B -V -DdistributionFileName=apache-maven -Preporting + run: mvn verify site -e -B -V -Preporting -Dmaven.repo.local=$HOME/.m2/repository/cached integration-tests: needs: initial-build @@ -174,9 +184,18 @@ jobs: echo "MAVEN_HOME=$PWD/maven-local" >> $GITHUB_ENV echo "$PWD/maven-local/bin" >> $GITHUB_PATH + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2/repository/cached + key: maven-${{ runner.os }}-its-${{ hashFiles('**/pom.xml') }} + restore-keys: | + maven-${{ runner.os }}-its + maven-${{ runner.os }}- + - name: Run integration tests shell: bash - run: mvn install -e -B -V -Prun-its,embedded + run: mvn install -e -B -V -Prun-its,embedded -Dmaven.repo.local=$HOME/.m2/repository/local -Dmaven.repo.local.tail=$HOME/.m2/repository/cached - name: Upload test artifacts uses: actions/upload-artifact@v4 diff --git a/its/core-it-suite/pom.xml b/its/core-it-suite/pom.xml index c3d1ec5e25..c0a642f490 100644 --- a/its/core-it-suite/pom.xml +++ b/its/core-it-suite/pom.xml @@ -633,6 +633,28 @@ under the License. </plugins> </build> </profile> + <profile> + <id>maven-repo-local-tail</id> + <activation> + <property> + <name>maven.repo.local.tail</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <!-- Pass this through to the tests (if set!) to have them + pick the right repository --> + <maven.repo.local.tail>${maven.repo.local.tail}</maven.repo.local.tail> + </systemPropertyVariables> + </configuration> + </plugin> + </plugins> + </build> + </profile> <profile> <id>maven-repo-local-layout</id> <activation> diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8181CentralRepoTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8181CentralRepoTest.java index 9f66ae7886..3aea83f526 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8181CentralRepoTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8181CentralRepoTest.java @@ -48,6 +48,7 @@ public class MavenITmng8181CentralRepoTest extends AbstractMavenIntegrationTestC verifier.addCliArgument("--install-settings=install-settings.xml"); verifier.addCliArgument("--settings=settings.xml"); verifier.addCliArgument("-Dmaven.repo.local=" + testDir.toPath().resolve("target/local-repo")); + verifier.addCliArgument("-Dmaven.repo.local.tail=target/null"); verifier.addCliArgument("-Dmaven.repo.central=http://repo1.maven.org/"); verifier.addCliArgument("validate"); assertThrows(VerificationException.class, verifier::execute); diff --git a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java index 55e447e1fc..b7b81d3bb9 100644 --- a/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java +++ b/its/core-it-support/maven-it-helper/src/main/java/org/apache/maven/it/Verifier.java @@ -29,11 +29,17 @@ import org.apache.maven.shared.verifier.VerificationException; public class Verifier extends org.apache.maven.shared.verifier.Verifier { public Verifier(String basedir) throws VerificationException { - super(basedir); + this(basedir, false); } public Verifier(String basedir, boolean debug) throws VerificationException { - super(basedir, debug); + super(basedir, null, debug, defaultCliArguments()); + } + + static String[] defaultCliArguments() { + return new String[] { + "-e", "--batch-mode", "-Dmaven.repo.local.tail=" + System.getProperty("maven.repo.local.tail") + }; } public String loadLogContent() throws IOException { @@ -95,4 +101,8 @@ public class Verifier extends org.apache.maven.shared.verifier.Verifier { public static long textOccurencesInLog(List<String> lines, String text) { return lines.stream().filter(line -> stripAnsi(line).contains(text)).count(); } + + public void execute() throws VerificationException { + super.execute(); + } }