generated from quarkiverse/quarkiverse-template
-
Notifications
You must be signed in to change notification settings - Fork 51
370 lines (322 loc) · 13.2 KB
/
build-for-quarkus-version.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
name: Build with specific Quarkus version
on:
workflow_call:
inputs:
quarkus-version-jq-cmd:
description: 'jq command to extract which Quarkus version to use from https://registry.quarkus.io/client/platforms'
type: string
required: false
quarkus-version:
type: string
required: false
java-version:
type: string
required: true
default: '17'
branch:
type: string
required: true
default: 'main'
repository:
type: string
default: ''
native-modules:
type: string
required: false
default: 'integration-tests,samples'
profiles:
type: string
required: false
default: 'default'
workflow_dispatch:
inputs:
quarkus-version-jq-cmd:
description: 'jq command to extract which Quarkus version to use from https://registry.quarkus.io/client/platforms'
type: string
required: false
default: '.platforms[0]."current-stream-id" as $current | .platforms[0].streams[] | select(.id == $current) | .releases[0].version'
josdk-pr:
description: 'JOSDK PR number (or main) to use to build QOSDK with'
type: string
required: false
quarkus-pr:
description: 'Quarkus PR number to use to run a QOSDK build with'
type: string
required: false
fkc-pr:
description: 'Fabric8 client PR number to use to run a QOSDK build with'
type: string
required: false
java-version:
description: 'Java version to build with'
type: string
required: true
default: '17'
branch:
description: 'QOSDK branch to build'
type: string
required: true
default: 'main'
native-modules:
description: 'Comma-separated list of modules that should be built natively'
type: string
required: false
default: 'integration-tests,samples'
concurrency:
group: "${{ inputs.quarkus-version }}-${{inputs.java-version}}-${{ github.ref }}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
repository: ${{ inputs.repository }}
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ inputs.java-version }}
cache: 'maven'
- name: Check-out JOSDK if building from PR is requested
uses: actions/checkout@v4
if: "${{ inputs.josdk-pr != '' }}"
with:
repository: operator-framework/java-operator-sdk
path: josdk
- name: Build JOSDK PR if requested
if: "${{ inputs.josdk-pr != '' }}"
id: build-josdk-pr
run: |
cd josdk
echo ${{ inputs.josdk-pr }}
if [ "${{ inputs.josdk-pr }}" = "main" ]; then
echo "Using JOSDK main branch"
else
echo "Checking out ${{ inputs.josdk-pr }} PR"
git fetch origin pull/${{ github.event.inputs.quarkus-pr }}/head:pr-to-check
git switch pr-to-check
fi
mvn install -DskipTests
echo "josdk_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
echo "josdk_f8_version=$(mvn help:evaluate -Dexpression=fabric8-client.version -q -DforceStdout)" >> $GITHUB_OUTPUT
cd -
- name: Set JOSDK version from build PR if requested
if: "${{ inputs.josdk-pr != '' }}"
run: mvn versions:set-property -Dproperty='java-operator-sdk.version' -DnewVersion=${{ steps.build-josdk-pr.outputs.josdk_version }}
- name: Check-out Quarkus if building from PR is requested
uses: actions/checkout@v4
if: "${{ inputs.quarkus-pr != '' }}"
with:
repository: quarkusio/quarkus
path: quarkus
- name: Build Quarkus PR if requested
if: "${{ inputs.quarkus-pr != '' }}"
id: build-quarkus-pr
run: |
cd quarkus
git fetch origin pull/${{ github.event.inputs.quarkus-pr }}/head:pr-to-check
git switch pr-to-check
./update-version.sh 999.${{ github.event.inputs.quarkus-pr }}-SNAPSHOT
echo "quarkus_f8_version=$(mvn help:evaluate -Dexpression=kubernetes-client.version -q -DforceStdout)" >> $GITHUB_OUTPUT
mvn -Dquickly
cd -
- name: Check-out Fabric8 client PR if requested
uses: actions/checkout@v4
if: "${{ inputs.fkc-pr != '' }}"
with:
repository: fabric8io/kubernetes-client
path: fkc
- name: Build Fabric8 client PR if requested
if: "${{ inputs.fkc-pr != '' }}"
id: build-fkc-pr
run: |
cd fkc
git fetch origin pull/${{ github.event.inputs.fkc-pr }}/head:pr-to-check
git switch pr-to-check
mvn versions:set -DnewVersion=999.${{ github.event.inputs.fkc-pr }}-SNAPSHOT versions:commit
echo "f8_pr_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
mvn clean install -DskipTests
cd -
- name: Retrieve Quarkus version from platform
if: "${{ inputs.quarkus-version == '' && inputs.quarkus-pr == ''}}"
id: get-quarkus-version
uses: sergeysova/jq-action@v2
with:
cmd: curl https://registry.quarkus.io/client/platforms | jq '${{inputs.quarkus-version-jq-cmd}}'
- name: Select Quarkus version
id: quarkus-version
run: |
echo ${{ inputs.quarkus-version }}
if [[ -n "${{ steps.get-quarkus-version.outputs.value }}" ]]; then
quarkus_version="${{ steps.get-quarkus-version.outputs.value }}"
fi
if [[ -n "${{ inputs.quarkus-version }}" ]]; then
quarkus_version="${{ inputs.quarkus-version }}"
fi
if [[ -n "${{ inputs.quarkus-pr }}" ]]; then
quarkus_version=999.${{ github.event.inputs.quarkus-pr }}-SNAPSHOT
fi
echo "quarkus_version=${quarkus_version}" >> $GITHUB_OUTPUT
- name: Use snapshots profile for non-main builds
id: set-mvn-profiles
run: |
maven_profiles="${{ inputs.profiles }}"
if [ "${{ inputs.branch }}" != "main" ]; then
maven_profiles="${maven_profiles},use-snapshots"
fi
echo "Computed Maven profiles: ${maven_profiles}"
echo "maven_profiles=${maven_profiles}" >> $GITHUB_OUTPUT
- name: Change Fabric8 client version
if: "${{ inputs.fkc-pr != '' }}"
run: |
echo "Using Fabric8 ${{ steps.build-fkc-pr.outputs.f8_pr_version }}"
sed -r -i "s@<fabric8-client.version>[^<]+</fabric8-client.version>@<fabric8-client.version>${{ steps.build-fkc-pr.outputs.f8_pr_version }}</fabric8-client.version>@" bom/pom.xml
- name: Change Quarkus version
run: |
echo "Using Quarkus ${{ steps.quarkus-version.outputs.quarkus_version }}"
mvn versions:set-property -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -Dproperty=quarkus.version -DnewVersion=${{ steps.quarkus-version.outputs.quarkus_version }}
- name: Output versions being used
run: |
echo "QOSDK version: $(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
echo "JOSDK version: $(mvn help:evaluate -Dexpression=java-operator-sdk.version -q -DforceStdout)"
echo "JOSDK Fabric8 version: ${{ steps.build-josdk-pr.outputs.josdk_f8_version }}"
echo "Quarkus version: $(mvn help:evaluate -Dexpression=quarkus.version -q -DforceStdout)"
echo "Quarkus Fabric8 version: ${{ steps.build-quarkus-pr.outputs.quarkus_f8_version }}"
echo "Effective Fabric8 version: $(mvn dependency:tree -Dincludes=io.fabric8:kubernetes-client-api -pl core/deployment | grep io.fabric8:kubernetes-client-api -m1 | cut -d ':' -f 4)"
- name: Build with Maven (JVM)
run: mvn -B formatter:validate install -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' --file pom.xml
- name: Dependency tree on failure
if: failure()
run: mvn -B dependency:tree -Dverbose
- name: Kubernetes KinD Cluster
uses: container-tools/kind-action@v2
with:
registry: true
- name: Install OPM and Operator SDK tool
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
opm: "latest"
operator-sdk: "latest"
- name: Install Operator Lifecycle Manager and Operator SDK into Kind
run: operator-sdk olm install --version v0.23.0
# Joke sample currently doesn't validate with OLM v1 because it bundles required Joke CRD, which v1 thinks should be owned
- name: Validate OLM bundles (excluding Joke sample)
if: false
run: |
cd samples/
find . -type d -name bundle | grep -v joke | xargs -I {} find {} -type d -maxdepth 1 -mindepth 1 | xargs -I {} operator-sdk bundle validate {} --select-optional suite=operatorframework
- name: Run Joke sample using Quarkus DEV mode
run: |
SCRIPTS=$(pwd)/.github/scripts
K8S_NAMESPACE=dev
CURRENT_PWD=$(pwd)
# Create and set namespace
kubectl create namespace $K8S_NAMESPACE
kubectl config set-context --current --namespace=$K8S_NAMESPACE
# Run operator in DEV mode
cd samples/joke
# Need to override application.properties setting to avoid using dev services instead of set up cluster
mvn quarkus:dev -Dquarkus.kubernetes-client.devservices.override-kubeconfig=false >app.log 2>&1 &
PID=$(echo $!)
cd $CURRENT_PWD
# test joke sample
ERROR=0
if ! $SCRIPTS/testJokeSample.sh $K8S_NAMESPACE; then
ERROR=1
fi
# Kill all running java processes
killall -9 java
# Delete namespace
kubectl delete namespace $K8S_NAMESPACE
if [ ERROR = 1 ]; then
echo "Tests failed"
exit 1
fi
- name: Archive Dev Mode application logs
uses: actions/upload-artifact@v1
if: failure()
with:
name: dev-mode-app.log
path: samples/joke/app.log
- name: Build with Maven (Native)
run: mvn -B install -Dnative --file pom.xml -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -pl '${{inputs.native-modules}}' -amd
- name: Run Joke sample in native mode
if: ${{ contains(inputs.native-modules, 'samples') }}
run: |
SCRIPTS=$(pwd)/.github/scripts
K8S_NAMESPACE=native
CURRENT_PWD=$(pwd)
# Create and set namespace
kubectl create namespace $K8S_NAMESPACE
kubectl config set-context --current --namespace=$K8S_NAMESPACE
# Run operator in native mode
cd samples/joke
find . -type f -name '*-runner' -exec {} \; >native.log 2>&1 &
PID=$(echo $!)
cd $CURRENT_PWD
ERROR=0
if ! $SCRIPTS/testJokeSample.sh $K8S_NAMESPACE; then
ERROR=1
fi
# Kill running process
kill -9 $PID
# Delete namespace
kubectl delete namespace $K8S_NAMESPACE
if [ ERROR = 1 ]; then
echo "Tests failed"
exit 1
fi
- name: Archive native application logs
uses: actions/upload-artifact@v1
if: failure()
with:
name: native.log
path: samples/joke/native.log
- name: Run Joke sample into Kubernetes using OLM
run: |
SCRIPTS=$(pwd)/.github/scripts
# Install Joke operator
if ! $SCRIPTS/installOperatorUsingOlm.sh joke $(pwd)/samples/joke $KIND_REGISTRY; then
echo "Failed to install operator"
exit 1;
fi
# test joke sample
if ! $SCRIPTS/testJokeSample.sh operators; then
echo "Failed to interact with operator"
exit 1;
fi;
- name: Run Ping Pong sample into Kubernetes using OLM
run: |
SCRIPTS=$(pwd)/.github/scripts
# Install Ping Pong operator
if ! $SCRIPTS/installOperatorUsingOlm.sh pingpong $(pwd)/samples/pingpong $KIND_REGISTRY; then
echo "Failed to install operator"
exit 1;
fi
# test joke sample
if ! $SCRIPTS/testPingPongSample.sh operators; then
echo "Failed to interact with operator"
exit 1;
fi
- name: (Only if it failed) Log K8s status to troubleshoot issues
if: failure()
run: |
echo "Pod statuses in olm namespace:"
kubectl get pod -n olm
echo ""
echo "------------------------------"
echo "Subscriptions:"
kubectl get subs -n operators -o yaml
echo ""
echo "------------------------------"
echo "Controllers:"
kubectl get pod -n operators
echo ""
echo "------------------------------"
echo "Events:"
kubectl get events
echo ""
echo "------------------------------"