-
Notifications
You must be signed in to change notification settings - Fork 2.7k
141 lines (119 loc) · 4.72 KB
/
maven.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# 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]
# clear all permissions for GITHUB_TOKEN
permissions: {}
jobs:
build:
# execute on any push or pull request from forked repo
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork )
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-java@v4
with:
java-version: 8
distribution: 'zulu'
cache: 'maven'
- name: Set up Maven
run:
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=3.9.7"
- name: Build with Maven
run: ./mvnw verify -e -B -V -DdistributionFileName=apache-maven
- name: Upload built Maven
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: built-maven
path: apache-maven/target/
integration-test:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
java: [8, 11, 17]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Collect environment context variables
shell: bash
env:
PR_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
run: |
set e
repo=maven-integration-testing
target_branch=maven-3.9.x
target_user=apache
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
user=${PR_HEAD_LABEL%:*}
branch=${PR_HEAD_LABEL#*:}
else
user=${GITHUB_REPOSITORY%/*}
branch=${GITHUB_REF#refs/heads/}
fi
if [ $branch != "master" ]; then
git ls-remote https://github.com/$user/$repo.git | grep "refs/heads/${branch}$" > /dev/null
if [ $? -eq 0 ]; then
echo "Found a branch \"$branch\" in fork \"$user/$repo\", configuring this for the integration tests to be run against."
target_branch=$branch
target_user=$user
else
echo "Could not find fork \"$user/$repo\" or a branch \"$branch\" in this fork. Falling back to \"$target_branch\" in \"$target_user/$repo\"."
fi
else
echo "Integration tests will run against $target_user/$repo for master builds."
fi
echo "REPO_BRANCH=$target_branch" >> $GITHUB_ENV
echo "REPO_USER=$target_user" >> $GITHUB_ENV
- name: Checkout maven-integration-testing
uses: actions/checkout@v4
with:
repository: ${{ env.REPO_USER }}/maven-integration-testing
path: maven-integration-testing/
ref: ${{ env.REPO_BRANCH }}
persist-credentials: false
- name: Set up cache for ~/.m2/repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: it-m2-repo-${{ matrix.os }}-${{ hashFiles('maven-integration-testing/**/pom.xml') }}
restore-keys: |
it-m2-repo-${{ matrix.os }}-
- name: Download built Maven
uses: actions/download-artifact@v4
with:
name: built-maven
path: built-maven/
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
cache: 'maven'
- name: Set up Maven
run:
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=3.9.7"
- name: Running integration tests
shell: bash
run: ./mvnw install -e -B -V -Prun-its,embedded -Dmaven.repo.local="$HOME/.m2/repository" -DmavenDistro="$GITHUB_WORKSPACE/built-maven/apache-maven-bin.zip" -f maven-integration-testing/pom.xml