-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwildfly-cloud-tests-callable.yml
More file actions
289 lines (249 loc) · 11.4 KB
/
Copy pathwildfly-cloud-tests-callable.yml
File metadata and controls
289 lines (249 loc) · 11.4 KB
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
name: WildFly Cloud Tests Internal
on:
workflow_call:
inputs:
runtimeImage:
description: 'Name/tag of the base runtime image'
type: string
required: true
type:
description: "Openshift or Kubernetes"
type: string
required: true
base64EncodedEnvVars:
# We are doing this because there is a max of 10 inputs on GH Actions
description: 'Env vars (one per line) encoded with base64'
type: string
required: false
outputs:
status:
description: 0 if job pased, 1 if not
value: ${{ jobs.run-tests.outputs.status }}
env:
# Env vars for authentication for the tests using OpenShift
OPENSHIFT_USER: admin
OPENSHIFT_PWD: admin
OPENSHIFT_NS: testing
STATUS_BRANCH: run-status
jobs:
run-tests:
runs-on: ubuntu-latest
outputs:
status: ${{ steps.output-status.outputs.status }}
steps:
# - name: Output event
# run: echo "${{ toJSON(github.event) }}"
- name: Output clientPayload
if: ${{ github.event.client_payload }}
run: |
echo "*****"
echo "${{ toJSON(github.event.client_payload) }}"
echo "*****"
echo "${{ toJSON(github.event.client_payload.triggerRepo) }}"
echo "*****"
echo "${{ toJSON(github.event.client_payload.githubSha) }}"
- name: Determine type
run: |
TMP=${{inputs.type}}
if [ $TMP != "Openshift" ] && [ $TMP != "Kubernetes" ]; then
echo "inputs.type must be either 'Kubernetes' or 'Openshift'"
exit 1
fi
echo "TYPE=${TMP}" >> $GITHUB_ENV
- name: Set runtime image override variable
if: ${{inputs.runtimeImage}}
run: |
# Set the system property to choose a different image when running the tests
echo Overriding the runtime image to be: ${{inputs.runtimeImage}}
TMP="-Dimage.name.wildfly.runtime=${{inputs.runtimeImage}}"
echo "RUNTIME_IMAGE_OVERRIDE=${TMP}" >> $GITHUB_ENV
- name: Unencode env vars for the tests
if: ${{inputs.base64EncodedEnvVars}}
run: |
echo "Decoding base64 encoded env vars"
echo ${{inputs.base64EncodedEnvVars}} > encodedVars.txt
base64 --decode encodedVars.txt > envVars.env
while IFS= read -r line; do
echo "$line" >> $GITHUB_ENV
done < envVars.env
########################################################################################
# Use this step to read environment variables required for your manual test, and set
# an env var to trigger a later step to run the test, as well as any env vars for
# maven options etc.
- name: Check which manual jobs to run and set env vars
run: |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout WildFly main branch
if: ${{!github.event.client_payload}}
uses: actions/checkout@v5
with:
path: wildfly
fetch-depth: 1
repository: 'wildfly/wildfly'
- name: Checkout WildFly PR branch
if: ${{github.event.client_payload}}
uses: actions/checkout@v5
with:
path: wildfly
fetch-depth: 1
repository: ${{github.event.client_payload.triggerRepo}}
ref: ${{github.event.client_payload.githubSha}}
- name: Checkout WildFly Cloud Tests
uses: actions/checkout@v5
with:
path: cloud-tests
fetch-depth: 1
- name: Setup Java JDK
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build WildFly
# WildFly main doesn't build without preview at the moment
# run: mvn -B install -DskipTests -Dskip.preview
run: mvn -B install -DskipTests
working-directory: wildfly
- name: Grab WildFly Version
id: grab-version
run: |
mvn -B help:evaluate -Dexpression=project.version -pl .
TMP="$(mvn -B help:evaluate -Dexpression=project.version -pl . | grep -v '^\[')"
echo "version: ${TMP}"
echo "VERSION_WILDFLY=${TMP}" >> $GITHUB_ENV
cd ..
rm -rfv wildfly
working-directory: wildfly
- name: Free up disk space
if: inputs.type == 'Kubernetes'
# Current SHA of main branch (and 1.3.1 tag) of https://github.com/jlumbroso/free-disk-space
uses: jlumbroso/free-disk-space@45c205b781c1e37e569708310a10ebcc893976ee
with:
# Retain tools that might be needed for builds
tool-cache: false
# Removing this caused an error
large-packages: false
- name: Setup Minikube
id: minikube
if: inputs.type == 'Kubernetes'
uses: manusa/actions-setup-minikube@v2.14.0
with:
driver: docker
container runtime: containerd
# Fixed Minikube/kubernetes versions
minikube version: 'v1.33.0'
kubernetes version: 'v1.30.0'
github token: ${{ secrets.GITHUB_TOKEN }}
start args: "--memory='4gb' --cpus='2' --insecure-registry=10.0.0.0/8"
- name: Setup Local Docker Registry
if: inputs.type == 'Kubernetes'
run: |
echo "Starting local Docker registry container..."
# Start registry on default bridge network with port binding
docker run -d -p 5000:5000 --restart=always --name local-registry \
-e REGISTRY_STORAGE_DELETE_ENABLED=true \
registry:2
# Wait for registry to be ready
echo "Waiting for registry to be ready..."
timeout 30 bash -c 'until curl -f http://localhost:5000/v2/ >/dev/null 2>&1; do sleep 1; done'
echo "✓ Registry is ready at localhost:5000"
# Find minikube's docker network
MINIKUBE_NETWORK=$(docker inspect minikube --format='{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}')
echo "Minikube is on network: $MINIKUBE_NETWORK"
# Connect registry to the same network as minikube
echo "Connecting registry to minikube network..."
docker network connect "$MINIKUBE_NETWORK" local-registry
# Get registry's IP on minikube's network
REGISTRY_IP=$(docker inspect local-registry --format="{{.NetworkSettings.Networks.${MINIKUBE_NETWORK}.IPAddress}}")
echo "Registry IP on minikube network: $REGISTRY_IP"
# Configure containerd inside minikube to use registry IP for localhost:5000
echo "Configuring minikube containerd to use registry at $REGISTRY_IP:5000..."
minikube ssh "sudo mkdir -p /etc/containerd/certs.d/localhost:5000"
minikube ssh "printf '[host.\"http://${REGISTRY_IP}:5000\"]\n capabilities = [\"pull\", \"resolve\"]\n' | sudo tee /etc/containerd/certs.d/localhost:5000/hosts.toml"
minikube ssh "cat /etc/containerd/certs.d/localhost:5000/hosts.toml"
echo "Restarting containerd..."
minikube ssh "sudo systemctl restart containerd"
echo "Waiting for containerd to be ready..."
sleep 10
minikube ssh "sudo crictl info | grep -i runtime || echo 'containerd running'"
# Verify registry is accessible from minikube
echo "Testing registry access from minikube..."
minikube ssh "curl -f http://${REGISTRY_IP}:5000/v2/ && echo '✓ Minikube can reach registry at ${REGISTRY_IP}:5000'" || {
echo "ERROR: Minikube cannot reach registry at $REGISTRY_IP:5000"
exit 1
}
# Verify registry catalog
echo "Registry catalog:"
curl -s http://localhost:5000/v2/_catalog
echo ""
- name: Kubernetes profiles
run: |
# The kubernetes-ci profile cleans the kubernetes registry between tests.
# When specifying another profile, we need to explicitly enable the kubernetes-tests profile
echo "TEST_MAVEN_PARAMETERS=-Pkubernetes-tests,kubernetes-ci" >> $GITHUB_ENV
- name: Setup OpenShift
if: inputs.type == 'Openshift'
uses: manusa/actions-setup-openshift@v1.1.5
with:
oc version: v3.11.0
github token: ${{ secrets.GITHUB_TOKEN }}
- name: Openshift usage
if: inputs.type == 'Openshift'
run: |
# Not sure if this is the right fix but there are a few instances where the connection
# to the registry is refused.
echo "Logging in..."
oc login -u $OPENSHIFT_USER -p $OPENSHIFT_PWD
echo "New project: $OPENSHIFT_NS"
oc new-project $OPENSHIFT_NS
echo "Registry login"
oc registry login --skip-check
echo "Registry info"
OPENSHIFT_IMAGE_REGISTRY=$(oc registry info)
echo "OPENSHIFT_IMAGE_REGISTRY=${OPENSHIFT_IMAGE_REGISTRY}" >> $GITHUB_ENV
echo "Registry url: $OPENSHIFT_IMAGE_REGISTRY"
# echo "login to docker registry"
# docker login -u $(oc whoami) -p $(oc whoami -t) $OPENSHIFT_IMAGE_REGISTRY
# Set extra Maven parameters for OpenShift
TMP=" -Popenshift-tests -Ddekorate.docker.registry=$OPENSHIFT_IMAGE_REGISTRY -Ddekorate.docker.group=$OPENSHIFT_NS"
echo "TEST_MAVEN_PARAMETERS=${TMP}" >> $GITHUB_ENV
# Sometimes the login to the registry fails with a connection refused
# See if a retry helps
- name: Login to OpenShift Image Registry
if: inputs.type == 'Openshift'
uses: nick-fields/retry@v3
with:
timeout_minutes: 2
retry_wait_seconds: 10
max_attempts: 3
command: docker login -u $(oc whoami) -p $(oc whoami -t) $OPENSHIFT_IMAGE_REGISTRY
- name: Run Cloud Tests
# This builds the provisioned images and runs the main (i.e. non-manual) tests
# Since the manual tests reuse these images, we don't need to use
# ${RUNTIME_IMAGE_OVERRIDE} elsewhere.
run: |
echo "Runtime image: ${RUNTIME_IMAGE_OVERRIDE}"
# No longer build the base images at the start. Instead build them on demand for each test via the
# docker-cleanup profile, which also deletes them once the test is complete
# mvn -B install -Pimages -fae -Dversion.wildfly=${VERSION_WILDFLY} ${RUNTIME_IMAGE_OVERRIDE} ${TEST_MAVEN_PARAMETERS} -Dmaven.test.redirectTestOutputToFile=false
mvn -B install -Pdocker-cleanup -fae -Dversion.wildfly=${VERSION_WILDFLY} ${RUNTIME_IMAGE_OVERRIDE} ${TEST_MAVEN_PARAMETERS} -Dmaven.test.redirectTestOutputToFile=false
working-directory: cloud-tests
- name: Update permissions for Cache post job
# Needed because the OpenShift installation adds some files which are not readable/writable
# resulting in the Cache post job failing when trying to calculate the hashes
run: sudo bash -c 'sudo chmod -R 777 .'
##################################################
# Following steps are to report back to the pull request runner remote_dispatch job
- id: output-status
if: ${{ always() }}
run: |
STATUS=${{ job.status }}
if [ "${STATUS}" == "success" ]; then
echo "Status is: success (0)"
MY_STATUS=0
else
echo "Status is: ${STATUS} - treating as failure (1)"
MY_STATUS=1
fi
echo "Setting 'status' output to ${MY_STATUS}"
echo "status=${MY_STATUS}" >> $GITHUB_OUTPUT