-
-
Notifications
You must be signed in to change notification settings - Fork 77
201 lines (181 loc) · 7.39 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
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.changes.outputs.cacerts }}
steps:
- name: Checkout
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: 0
- name: Get changed files
id: changes
# Set outputs using the command.
run: |
changed_files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)
echo $changed_files
echo "all=$changed_files" >> $GITHUB_OUTPUT
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
# Set test versions if version cannot be determined from the path
versions_to_test=(
"8"
"11"
"17"
"20"
)
# If this job is being run on a pull request, only run the matrix for the changed files
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
changed_files="${{ steps.changes.outputs.all }}"
else
changed_files=$(git ls-files linux)
fi
matrix='['
for file in $(echo ${changed_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)
# test if version is a number and otherwise use versions_to_test
if ! [[ $version =~ ^[0-9]+$ ]]; then
name="temurin"
for version in "${versions_to_test[@]}"
do
matrix+='{"image_type":"'"$type"'","distro":"'"$distro"'","product":{"name":"'"$name"'","version":"'"$version"'"}},'
done
else
matrix+='{"image_type":"'"$type"'","distro":"'"$distro"'","product":{"name":"'"$name"'","version":"'"$version"'"}},'
fi
;;
esac
done
# remove trailing comma
matrix=${matrix%?}
matrix+=']'
# check if matrix is empty
if [[ $matrix == ']' ]]; then
echo "No jobs to run"
matrix='[]'
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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.8.0
with:
java-version: '17'
java-package: jdk
architecture: x64
distribution: 'temurin'
- name: Build
run: |
export _JAVA_OPTIONS="-Xmx4G"
./gradlew --parallel :ca-certificates:check --stacktrace
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: always() # always run even if the previous step fails
with:
name: test-results
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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.8.0
with:
java-version: '17'
java-package: jdk
architecture: x64
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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: always() # always run even if the previous step fails
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@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0