forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 1
192 lines (175 loc) · 6.43 KB
/
dep-diff-pull_request.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Dependency Tree Input Builder
# To deal with https://securitylab.github.com/research/github-actions-preventing-pwn-requests
# we need to split this across two jobs. The part that writes to the pull request lives in
# ./dep-diff-workflow_run.yml
on:
pull_request:
branches:
- main
paths:
- "**/pom.xml"
env:
# The modules to check for dependencies. If there is more than one they are comma separated
MODULES_TO_CHECK: ee-feature-pack/galleon-shared,ee-feature-pack/galleon-local,galleon-pack/galleon-shared,galleon-pack/galleon-local,galleon-pack,ee-feature-pack/common,microprofile/galleon-common,servlet-feature-pack/common,elytron-oidc-client/galleon-common
ADDITIONAL_BUILD_MODULES: boms/common-ee,boms/common-expansion,boms/standard-ee,boms/standard-expansion,boms/standard-test
jobs:
check:
runs-on: ubuntu-latest
env:
ARTIFACTS: .pr_artifacts
steps:
- name: Prepare
id: prepare
run: |
# Make ARTIFACTS absolute
ARTIFACTS="${GITHUB_WORKSPACE}/${ARTIFACTS}"
echo "ARTIFACTS=${ARTIFACTS}" >> $GITHUB_ENV
mkdir ${ARTIFACTS}
echo ${{ github.event.number }} > "${ARTIFACTS}/pr"
echo "base=${GITHUB_BASE_REF}" >> $GITHUB_OUTPUT
echo "artifacts=${ARTIFACTS}" >> $GITHUB_OUTPUT
- name: Clone base version
uses: actions/checkout@v4
with:
ref: ${{ steps.prepare.outputs.base }}
path: base
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
# Run the caching against the base version only
- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Clone PR version
uses: actions/checkout@v4
with:
path: pr
- name: Find valid base modules to check
working-directory: base
run: |
i=0
validBaseModules=""
for module in $(echo "${MODULES_TO_CHECK}" | sed "s/,/ /g")
do
if [ -d ${module} ]; then
if [ $i -gt 0 ]; then
validBaseModules="${validBaseModules},${module}"
else
validBaseModules="${module}"
fi
i=$((i + 1))
fi
done
echo "validBaseModules="$validBaseModules
echo "validBaseModules=${validBaseModules}" >> $GITHUB_ENV
- name: Find valid base additional modules
working-directory: base
run: |
i=0
validAddlBaseModules=""
for module in $(echo "${ADDITIONAL_BUILD_MODULES}" | sed "s/,/ /g")
do
if [ -d ${module} ]; then
if [ $i -gt 0 ]; then
validAddlBaseModules="${validAddlBaseModules},${module}"
else
validAddlBaseModules="${module}"
fi
i=$((i + 1))
fi
done
echo "validAddlBaseModules="validAddlBaseModules
echo "validAddlBaseModules=${validAddlBaseModules}" >> $GITHUB_ENV
- name: Find valid PR modules to check
working-directory: pr
run: |
i=0
validPRModules=""
for module in $(echo "${MODULES_TO_CHECK}" | sed "s/,/ /g")
do
if [ -d ${module} ]; then
if [ $i -gt 0 ]; then
validPRModules="${validPRModules},${module}"
else
validPRModules="${module}"
fi
i=$((i + 1))
fi
done
echo "validPRModules="$validPRModules
echo "validPRModules=${validPRModules}" >> $GITHUB_ENV
- name: Find valid pr additional modules
working-directory: pr
run: |
i=0
validAddlPRModules=""
for module in $(echo "${ADDITIONAL_BUILD_MODULES}" | sed "s/,/ /g")
do
if [ -d ${module} ]; then
if [ $i -gt 0 ]; then
validAddlPRModules="${validAddlPRModules},${module}"
else
validAddlPRModules="${module}"
fi
i=$((i + 1))
fi
done
echo "validAddlPRModules="validAddlPRModules
echo "validAddlPRModules=${validAddlPRModules}" >> $GITHUB_ENV
- name: Build base
working-directory: base
run: |
mvn -B -ntp install -DskipTests -pl ${{ env.validBaseModules }},${{ env.validAddlBaseModules }} -am
- name: Grab base dependencies
id: base-versions
working-directory: base
run: |
i=0
baseVersionFiles=""
for module in $(echo "${{ env.validBaseModules }}" | sed "s/,/ /g")
do
baseVersionFile="_base-versions-$i.txt"
mvn -B -ntp dependency:tree -pl "${module}" -DoutputFile="${ARTIFACTS}/${baseVersionFile}" || exit 1
if [ $i -gt 0 ]; then
baseVersionFiles="${baseVersionFiles},${baseVersionFile}"
else
baseVersionFiles="${baseVersionFile}"
fi
i=$((i + 1))
done
echo "${baseVersionFiles}" > ${ARTIFACTS}/baseVersions
- name: Build PR
working-directory: pr
run: |
echo "validPRModules="$validPRModules
echo "env.validPRModules="${{ env.validPRModules }}
mvn -B -ntp install -DskipTests -pl ${{ env.validPRModules }},${{ env.validAddlPRModules }} -am
- name: Grab PR Dependencies
working-directory: pr
id: new-versions
run: |
i=0
newVersionFiles=""
for module in $(echo "${{ env.validPRModules }}" | sed "s/,/ /g")
do
newVersionFile="_new-versions-$i.txt"
mvn -B -ntp dependency:tree -pl "${module}" -DoutputFile="${ARTIFACTS}/${newVersionFile}" || exit 1
if [ $i -gt 0 ]; then
newVersionFiles="${newVersionFiles},${newVersionFile}"
else
newVersionFiles="${newVersionFile}"
fi
i=$((i + 1))
done
echo "${newVersionFiles}" > ${ARTIFACTS}/newVersions
- uses: actions/upload-artifact@v4
with:
name: input-artifacts
path: ${{ steps.prepare.outputs.artifacts }}
include-hidden-files: true