Skip to content

Commit 5c480f7

Browse files
committed
Use a single definition with an initial build on ubuntu + jdk 17
1 parent 2860a9a commit 5c480f7

File tree

3 files changed

+125
-217
lines changed

3 files changed

+125
-217
lines changed

.github/workflows/build-steps.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Maven Build
19+
description: Build with tests + Rebuild using the built Maven + Integration tests
20+
inputs:
21+
java-version:
22+
description: 'The Java version to use'
23+
required: true
24+
default: '17'
25+
upload-distribution:
26+
description: 'If the built distribution should be uploaded'
27+
required: false
28+
default: false
29+
runs:
30+
using: "composite"
31+
steps:
32+
- name: Set up JDK ${{ inputs.java-version }}
33+
uses: actions/setup-java@v4
34+
with:
35+
java-version: ${{ inputs.java-version }}
36+
distribution: 'temurin'
37+
38+
- name: Cache Maven packages
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.m2/repository/cached
42+
key: maven-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: maven-
44+
45+
- name: Checking out Maven
46+
uses: actions/checkout@v4
47+
with:
48+
persist-credentials: false
49+
50+
- name: Set up Maven
51+
run:
52+
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=4.0.0-beta-4"
53+
54+
- name: Build with Maven
55+
run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven
56+
57+
- name: Upload built Maven
58+
uses: actions/upload-artifact@v4
59+
if: ${{ inputs.upload-distribution }}
60+
with:
61+
name: built-maven
62+
path: apache-maven/target/
63+
64+
- name: Extract tarball
65+
shell: bash
66+
run: |
67+
set +e
68+
if [ -f ${{ env.TAR_BALL }} ]; then
69+
temp_dir=$(mktemp -d)
70+
tar -xzf ${{ env.TAR_BALL }} -C "$temp_dir" --strip 1
71+
maven_bin_dir=$temp_dir/bin
72+
if [ -d $maven_bin_dir ]; then
73+
echo "tar.gz file \"${{ env.TAR_BALL }}\" successfully extracted in temporarily directory \"$temp_dir.\""
74+
echo "TEMP_MAVEN_BIN_DIR=$maven_bin_dir" >> $GITHUB_ENV
75+
else
76+
echo "$maven_bin_dir does not exist."
77+
exit 1;
78+
fi
79+
else
80+
echo "${{ env.TAR_BALL }} does not exist."
81+
exit 1;
82+
fi
83+
env:
84+
TAR_BALL: apache-maven/target/apache-maven-bin.tar.gz
85+
86+
- name: Clean with Maven
87+
run: ./mvnw -e -B -V clean
88+
89+
- name: Build again with Maven SNAPSHOT
90+
shell: bash
91+
run: |
92+
set +e
93+
export PATH=${{ env.TEMP_MAVEN_BIN_DIR }}:$PATH
94+
mvn verify site -e -B -V -DdistributionFileName=apache-maven -Preporting
95+
96+
- name: Running integration tests
97+
shell: bash
98+
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
99+
100+
- name: Upload artifact on integration testing
101+
uses: actions/upload-artifact@v4
102+
if: failure() && matrix.os != 'windows-latest'
103+
with:
104+
name: ${{ github.run_number }}-integration-test-artifact-${{ runner.os }}-${{ inputs.java-version }}
105+
path: ./maven-integration-testing/core-it-suite/target/test-classes/

.github/workflows/maven.yml

Lines changed: 20 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -17,140 +17,36 @@
1717

1818
name: Java CI
1919

20-
on: [push, pull_request, workflow_dispatch]
20+
on:
21+
push:
22+
branches: [ master ]
23+
pull_request:
24+
branches: [ master ]
2125

2226
# clear all permissions for GITHUB_TOKEN
2327
permissions: {}
2428

2529
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
4132
steps:
42-
- uses: actions/checkout@v4
43-
with:
44-
persist-credentials: false
45-
46-
- uses: actions/setup-java@v4
33+
- name: Run common build steps
34+
uses: ./.github/workflows/build-steps.yml
4735
with:
4836
java-version: 17
49-
distribution: 'temurin'
50-
cache: 'maven'
51-
52-
- uses: actions/cache@v4
53-
with:
54-
path: ~/.m2/repository/cached
55-
key: maven-${{ hashFiles('**/pom.xml') }}
56-
restore-keys: maven-
57-
58-
- name: Set up Maven
59-
run:
60-
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=4.0.0-beta-4"
6137

62-
- name: Build with Maven
63-
run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven
64-
65-
- name: Upload built Maven
66-
uses: actions/upload-artifact@v4
67-
if: ${{ matrix.os == 'ubuntu-latest' }}
68-
with:
69-
name: built-maven
70-
path: apache-maven/target/
71-
72-
integration-test:
73-
needs: build
38+
matrix-build:
39+
needs: initial-build
40+
runs-on: ${{ matrix.os }}
7441
strategy:
7542
matrix:
76-
os: [ubuntu-latest, windows-latest, macOS-latest]
77-
java: [17, 21]
78-
79-
fail-fast: false
80-
runs-on: ${{ matrix.os }}
81-
43+
os: [ubuntu-latest, macos-latest, windows-latest]
44+
java: ['17', '21']
45+
exclude:
46+
- os: ubuntu-latest
47+
java: '17'
8248
steps:
83-
- name: Collect environment context variables
84-
shell: bash
85-
env:
86-
PR_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
87-
run: |
88-
set +e
89-
repo=maven-integration-testing
90-
target_branch=master
91-
target_user=apache
92-
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
93-
user=${PR_HEAD_LABEL%:*}
94-
branch=${PR_HEAD_LABEL#*:}
95-
else
96-
user=${GITHUB_REPOSITORY%/*}
97-
branch=${GITHUB_REF#refs/heads/}
98-
fi
99-
if [ $branch != "master" ]; then
100-
git ls-remote https://github.com/$user/$repo.git | grep "refs/heads/${branch}$" > /dev/null
101-
if [ $? -eq 0 ]; then
102-
echo "Found a branch \"$branch\" in fork \"$user/$repo\", configuring this for the integration tests to be run against."
103-
target_branch=$branch
104-
target_user=$user
105-
else
106-
echo "Could not find fork \"$user/$repo\" or a branch \"$branch\" in this fork. Falling back to \"$target_branch\" in \"$target_user/$repo\"."
107-
fi
108-
else
109-
echo "Integration tests will run against $target_user/$repo for master builds."
110-
fi
111-
echo "REPO_BRANCH=$target_branch" >> $GITHUB_ENV
112-
echo "REPO_USER=$target_user" >> $GITHUB_ENV
113-
114-
- name: Checkout maven-integration-testing
115-
uses: actions/checkout@v4
116-
with:
117-
repository: ${{ env.REPO_USER }}/maven-integration-testing
118-
path: maven-integration-testing/
119-
ref: ${{ env.REPO_BRANCH }}
120-
persist-credentials: false
121-
122-
- name: Set up JDK
123-
uses: actions/setup-java@v4
124-
with:
125-
java-version: ${{ matrix.java }}
126-
distribution: 'temurin'
127-
# cache: 'maven' - don't use cache for integration tests
128-
129-
- uses: actions/checkout@v4
130-
with:
131-
path: maven/
132-
persist-credentials: false
133-
134-
- name: Set up Maven
135-
run:
136-
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=4.0.0-beta-4"
137-
138-
- uses: actions/cache@v4
139-
with:
140-
path: ~/.m2/repository/cached
141-
key: maven-${{ hashFiles('**/pom.xml') }}
142-
restore-keys: maven-
143-
144-
- name: Build Maven
145-
run: ./mvnw install -e -B -V -DdistributionFileName=apache-maven -DskipTests -f maven/pom.xml
146-
147-
- name: Running integration tests
148-
shell: bash
149-
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
150-
151-
- name: Upload artifact on integration testing
152-
uses: actions/upload-artifact@v4
153-
if: failure() && matrix.os != 'windows-latest'
49+
- name: Run common build steps
50+
uses: ./.github/workflows/build-steps.yml
15451
with:
155-
name: ${{ github.run_number }}-integration-test-artifact-${{ matrix.os }}-${{ matrix.java }}
156-
path: ./maven-integration-testing/core-it-suite/target/test-classes/
52+
java-version: ${{ matrix.java }}

.github/workflows/maven_build_itself.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)