|
17 | 17 |
|
18 | 18 | name: Java CI
|
19 | 19 |
|
20 |
| -on: [push, pull_request, workflow_dispatch] |
| 20 | +on: |
| 21 | + push: |
| 22 | + branches: [ master ] |
| 23 | + pull_request: |
| 24 | + branches: [ master ] |
21 | 25 |
|
22 | 26 | # clear all permissions for GITHUB_TOKEN
|
23 | 27 | permissions: {}
|
24 | 28 |
|
25 | 29 | jobs:
|
26 |
| - build: |
27 |
| - |
28 |
| - # execute on any push, workflow_dispatch or pull request from forked repo |
29 |
| - if: > |
30 |
| - github.event_name == 'push' || |
31 |
| - github.event_name == 'workflow_dispatch' || |
32 |
| - ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork ) |
33 |
| -
|
34 |
| - strategy: |
35 |
| - matrix: |
36 |
| - os: [ubuntu-latest, windows-latest, macOS-latest] |
37 |
| - fail-fast: false |
38 |
| - |
39 |
| - runs-on: ${{ matrix.os }} |
40 |
| - |
| 30 | + initial-build: |
| 31 | + runs-on: ubuntu-latest |
41 | 32 | steps:
|
42 |
| - - uses: actions/checkout@v4 |
| 33 | + - name: Set up JDK |
| 34 | + uses: actions/setup-java@v4 |
43 | 35 | with:
|
| 36 | + java-version: 17 |
| 37 | + distribution: 'temurin' |
| 38 | + |
| 39 | + - name: Checkout maven |
| 40 | + uses: actions/checkout@v4 |
| 41 | + with: |
| 42 | + path: maven/ |
44 | 43 | persist-credentials: false
|
45 | 44 |
|
46 |
| - - uses: actions/setup-java@v4 |
| 45 | + - name: Cache Maven packages |
| 46 | + uses: actions/cache@v4 |
47 | 47 | with:
|
48 |
| - java-version: 17 |
49 |
| - distribution: 'temurin' |
50 |
| - cache: 'maven' |
| 48 | + path: ~/.m2/repository/cached |
| 49 | + key: maven-${{ hashFiles('**/pom.xml') }} |
| 50 | + restore-keys: maven- |
| 51 | + enableCrossOsArchive: true |
51 | 52 |
|
52 | 53 | - name: Set up Maven
|
53 |
| - run: |
54 |
| - mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=3.9.7" |
| 54 | + shell: bash |
| 55 | + working-directory: maven |
| 56 | + run: mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=4.0.0-beta-4" |
55 | 57 |
|
56 | 58 | - name: Build with Maven
|
| 59 | + shell: bash |
| 60 | + working-directory: maven |
57 | 61 | run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven
|
58 | 62 |
|
59 | 63 | - name: Upload built Maven
|
60 | 64 | uses: actions/upload-artifact@v4
|
61 |
| - if: ${{ matrix.os == 'ubuntu-latest' }} |
62 | 65 | with:
|
63 | 66 | name: built-maven
|
64 |
| - path: apache-maven/target/ |
| 67 | + path: maven/apache-maven/target/ |
| 68 | + |
| 69 | + - name: Extract tarball |
| 70 | + shell: bash |
| 71 | + working-directory: maven |
| 72 | + run: | |
| 73 | + set +e |
| 74 | + if [ -f ${{ env.TAR_BALL }} ]; then |
| 75 | + temp_dir=$(mktemp -d) |
| 76 | + tar -xzf ${{ env.TAR_BALL }} -C "$temp_dir" --strip 1 |
| 77 | + maven_bin_dir=$temp_dir/bin |
| 78 | + if [ -d $maven_bin_dir ]; then |
| 79 | + echo "tar.gz file \"${{ env.TAR_BALL }}\" successfully extracted in temporarily directory \"$temp_dir.\"" |
| 80 | + echo "TEMP_MAVEN_BIN_DIR=$maven_bin_dir" >> $GITHUB_ENV |
| 81 | + else |
| 82 | + echo "$maven_bin_dir does not exist." |
| 83 | + exit 1; |
| 84 | + fi |
| 85 | + else |
| 86 | + echo "${{ env.TAR_BALL }} does not exist." |
| 87 | + exit 1; |
| 88 | + fi |
| 89 | + env: |
| 90 | + TAR_BALL: apache-maven/target/apache-maven-bin.tar.gz |
| 91 | + |
| 92 | + - name: Build again with Maven SNAPSHOT |
| 93 | + shell: bash |
| 94 | + working-directory: maven |
| 95 | + run: | |
| 96 | + export PATH=${{ env.TEMP_MAVEN_BIN_DIR }}:$PATH |
| 97 | + mvn clean verify site -e -B -V -DdistributionFileName=apache-maven -Preporting |
| 98 | +
|
65 | 99 |
|
66 |
| - integration-test: |
67 |
| - needs: build |
| 100 | + matrix-build: |
| 101 | + needs: initial-build |
| 102 | + runs-on: ${{ matrix.os }} |
68 | 103 | strategy:
|
69 | 104 | matrix:
|
70 |
| - os: [ubuntu-latest, windows-latest, macOS-latest] |
71 |
| - java: [17, 21] |
| 105 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 106 | + java: ['17', '21'] |
| 107 | + steps: |
| 108 | + - name: Set up JDK ${{ matrix.java }} |
| 109 | + uses: actions/setup-java@v4 |
| 110 | + with: |
| 111 | + java-version: ${{ matrix.java }} |
| 112 | + distribution: 'temurin' |
72 | 113 |
|
73 |
| - fail-fast: false |
74 |
| - runs-on: ${{ matrix.os }} |
| 114 | + - name: Checkout maven |
| 115 | + uses: actions/checkout@v4 |
| 116 | + with: |
| 117 | + path: maven/ |
| 118 | + persist-credentials: false |
75 | 119 |
|
76 |
| - steps: |
77 | 120 | - name: Collect environment context variables
|
78 | 121 | shell: bash
|
79 | 122 | env:
|
@@ -113,32 +156,71 @@ jobs:
|
113 | 156 | ref: ${{ env.REPO_BRANCH }}
|
114 | 157 | persist-credentials: false
|
115 | 158 |
|
116 |
| - - name: Set up JDK |
117 |
| - uses: actions/setup-java@v4 |
| 159 | + - name: Cache Maven packages |
| 160 | + uses: actions/cache@v4 |
118 | 161 | with:
|
119 |
| - java-version: ${{ matrix.java }} |
120 |
| - distribution: 'temurin' |
121 |
| -# cache: 'maven' - don't use cache for integration tests |
| 162 | + path: ~/.m2/repository/cached |
| 163 | + key: maven-${{ hashFiles('**/pom.xml') }} |
| 164 | + restore-keys: maven- |
| 165 | + enableCrossOsArchive: true |
| 166 | + |
| 167 | + - name: Set up Maven |
| 168 | + shell: bash |
| 169 | + working-directory: maven |
| 170 | + run: mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=4.0.0-beta-4" |
| 171 | + |
| 172 | + - name: Build with Maven |
| 173 | + shell: bash |
| 174 | + working-directory: maven |
| 175 | + run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven |
122 | 176 |
|
123 |
| - - uses: actions/checkout@v4 |
| 177 | + - name: Upload built Maven |
| 178 | + uses: actions/upload-artifact@v4 |
| 179 | + if: ${{ inputs.upload-distribution }} |
124 | 180 | with:
|
125 |
| - path: maven/ |
126 |
| - persist-credentials: false |
| 181 | + name: built-maven |
| 182 | + path: maven/apache-maven/target/ |
127 | 183 |
|
128 |
| - - name: Set up Maven |
129 |
| - run: |
130 |
| - mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=3.9.7" |
| 184 | + - name: Extract tarball |
| 185 | + shell: bash |
| 186 | + working-directory: maven |
| 187 | + run: | |
| 188 | + set +e |
| 189 | + if [ -f ${{ env.TAR_BALL }} ]; then |
| 190 | + temp_dir=$(mktemp -d) |
| 191 | + tar -xzf ${{ env.TAR_BALL }} -C "$temp_dir" --strip 1 |
| 192 | + maven_bin_dir=$temp_dir/bin |
| 193 | + if [ -d $maven_bin_dir ]; then |
| 194 | + echo "tar.gz file \"${{ env.TAR_BALL }}\" successfully extracted in temporarily directory \"$temp_dir.\"" |
| 195 | + echo "TEMP_MAVEN_BIN_DIR=$maven_bin_dir" >> $GITHUB_ENV |
| 196 | + else |
| 197 | + echo "$maven_bin_dir does not exist." |
| 198 | + exit 1; |
| 199 | + fi |
| 200 | + else |
| 201 | + echo "${{ env.TAR_BALL }} does not exist." |
| 202 | + exit 1; |
| 203 | + fi |
| 204 | + env: |
| 205 | + TAR_BALL: apache-maven/target/apache-maven-bin.tar.gz |
131 | 206 |
|
132 |
| - - name: Build Maven |
133 |
| - run: ./mvnw install -e -B -V -DdistributionFileName=apache-maven -DskipTests -f maven/pom.xml |
| 207 | + - name: Build again with Maven SNAPSHOT |
| 208 | + shell: bash |
| 209 | + working-directory: maven |
| 210 | + run: | |
| 211 | + export PATH=${{ env.TEMP_MAVEN_BIN_DIR }}:$PATH |
| 212 | + mvn clean verify site -e -B -V -DdistributionFileName=apache-maven -Preporting |
134 | 213 |
|
135 | 214 | - name: Running integration tests
|
136 | 215 | shell: bash
|
137 |
| - run: ./mvnw install -e -B -V -Prun-its,embedded -DmavenDistro="$GITHUB_WORKSPACE/maven/apache-maven/target/apache-maven-bin.zip" -f maven-integration-testing/pom.xml |
| 216 | + working-directory: maven-integration-testing |
| 217 | + run: | |
| 218 | + export PATH=${{ env.TEMP_MAVEN_BIN_DIR }}:$PATH |
| 219 | + mvn install -e -B -V -Prun-its,embedded |
138 | 220 |
|
139 | 221 | - name: Upload artifact on integration testing
|
140 | 222 | uses: actions/upload-artifact@v4
|
141 | 223 | if: failure() && matrix.os != 'windows-latest'
|
142 | 224 | with:
|
143 |
| - name: ${{ github.run_number }}-integration-test-artifact-${{ matrix.os }}-${{ matrix.java }} |
| 225 | + name: ${{ github.run_number }}-integration-test-artifact-${{ runner.os }}-${{ matrix.java }} |
144 | 226 | path: ./maven-integration-testing/core-it-suite/target/test-classes/
|
0 commit comments