-
-
Notifications
You must be signed in to change notification settings - Fork 75
202 lines (178 loc) · 7.25 KB
/
linux.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
193
194
195
196
197
198
199
200
201
202
name: Check Linux Packages
on:
workflow_dispatch:
push:
paths:
- 'linux/**'
- '.github/workflows/linux.yml'
pull_request:
branches: [ master ]
paths:
- 'linux/**'
- '.github/workflows/linux.yml'
# Cancel existing runs if user makes another push.
concurrency:
group: "${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
generate-matrix:
if: github.event_name == 'pull_request' || github.repository_owner != 'adoptium'
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
cacerts: ${{ steps.cacerts.outputs.cacerts }}
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
fetch-depth: 0
- name: Check if cacerts changed
id: cacerts
# Set outputs using the command.
run: |
cacerts=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep ca-certificates | xargs)
echo "cacerts=$cacerts" >> $GITHUB_OUTPUT
- name: Generate CI matrix
id: generate-matrix
run: |
# Generate the matrix based on the changed files
# Loop through the changed files and generate a matrix of jobs to run
# The matrix is a JSON string that is used in the next step
all_files=$(git ls-files linux)
# Add versions here to be skipped from CI once they've reached EOL
skipped_versions='["19","20"]'
matrix='['
for file in $(echo ${all_files} | tr " " "\n")
do
# capitalize distro unless it's redhat (set as RedHat)
capitalize () {
if [[ $1 == "redhat" ]]; then
echo "RedHat"
else
echo $1 | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}'
fi
}
case $file in
linux/jdk/*|linux/jre/*)
# extract values from the path
type=$(echo $file | cut -d'/' -f 2 | tr '[a-z]' '[A-Z]')
distro=$(echo $file | cut -d'/' -f 3)
# if distro = build.gradle skip it
if [[ $distro == "build.gradle" ]]; then
continue
fi
distro=$(capitalize $distro)
name=$(echo $file | cut -d'/' -f 7)
# if name != temurin and !microsoft skip it
if [[ $name != "temurin" && $name != "microsoft" ]]; then
continue
fi
version=$(echo $file | cut -d'/' -f 8)
# if version in skipped_versions skip
if [[ $skipped_versions == *"$version"* ]]; then
continue
fi
matrix+='{"image_type":"'"$type"'","distro":"'"$distro"'","product":{"name":"'"$name"'","version":"'"$version"'"}},'
;;
esac
done
# remove trailing comma
matrix=${matrix%?}
matrix+=']'
# check if matrix is empty
if [[ $matrix == ']' ]]; then
echo "error: No matrix generated"
exit 1
else
# remove any duplicate entries
matrix=$(echo $matrix | jq -S 'unique')
fi
echo "matrix<<EOF"$'\n'"$matrix"$'\n'EOF >> $GITHUB_OUTPUT
check-ca-certificates:
name: "Check ca-certificates"
needs: generate-matrix
if: (github.event_name == 'pull_request' && needs.generate-matrix.outputs.cacerts) || github.repository_owner != 'adoptium'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./linux
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
java-package: jdk
distribution: temurin
- name: Build
run: |
export _JAVA_OPTIONS="-Xmx4G"
./gradlew --parallel :ca-certificates:check --stacktrace
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always() # always run even if the previous step fails
with:
name: test-results-ca-certificates
path: '**/build/test-results/**/TEST-*.xml'
check-packages:
name: "Check ${{ matrix.image_type }} on ${{ matrix.product.name }} ${{ matrix.product.version }} ${{ matrix.distro }}"
if: github.event_name == 'pull_request' || github.repository_owner != 'adoptium'
needs: generate-matrix
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./linux
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
java-version: 17
java-package: jdk
distribution: temurin
- name: Build # only simulate in Jenkins when select ARCH="all"
run: |
export _JAVA_OPTIONS="-Xmx4G"
export DOCKER_BUILDKIT=1
./gradlew --parallel package$( echo "${{ matrix.image_type }}" | tr [DKRE] [dkre] )${{ matrix.distro }} check${{ matrix.image_type }}${{ matrix.distro }} -PPRODUCT=${{ matrix.product.name }} -PPRODUCT_VERSION=${{ matrix.product.version }} --stacktrace
- name: Relocate test results
if: always() # always run even if the previous step fails
run: |
mkdir ${{ matrix.product.version }}
mv $( echo "${{ matrix.image_type }}" | tr [:upper:] [:lower:] ) ${{ matrix.product.version }}
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always() # always run even if the previous step fails
with:
name: test-results-${{ matrix.product.name }}-${{ matrix.product.version }}-${{ matrix.distro }}-${{ matrix.image_type }}
path: '**/build/test-results/**/TEST-*.xml'
merge-results:
name: Merge Test Results
needs: check-packages
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
with:
pattern: test-results-*
merge-multiple: true
- uses: geekyeggo/delete-artifact@24928e75e6e6590170563b8ddae9fac674508aa1 # v5.0.0
with:
name: test-results-*
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: test-results
path: '**/build/test-results/**/TEST-*.xml'
# Ensures we don't accept a Gradle Wrapper update that has been tampered with.
validation:
name: "Validate Gradle Wrapper"
if: github.event_name == 'pull_request' || github.repository_owner != 'adoptium'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- uses: gradle/actions/wrapper-validation@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2