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
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
47
35
with :
48
36
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"
61
37
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 }}
74
41
strategy :
75
42
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'
82
48
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
154
51
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 }}
0 commit comments