-
Notifications
You must be signed in to change notification settings - Fork 13
234 lines (204 loc) · 8.69 KB
/
wildfly-cloud-tests-callable.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
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@v4
with:
path: wildfly
fetch-depth: 1
repository: 'wildfly/wildfly'
- name: Checkout WildFly PR branch
if: ${{github.event.client_payload}}
uses: actions/checkout@v4
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@v4
with:
path: cloud-tests
fetch-depth: 1
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
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: Setup Minikube
id: minikube
if: inputs.type == 'Kubernetes'
uses: manusa/[email protected]
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'"
# - name: Enable minikube registry
# if: inputs.type == 'Kubernetes'
# run: |
# minikube addons enable registry
# kubectl port-forward --namespace kube-system service/registry 5000:80 &
- 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/[email protected]
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