forked from wildfly-extras/wildfly-cloud-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (216 loc) · 8.79 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
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.ref) }}"
- name: Output event
run: echo "${{ toJSON(github.event) }}"
- 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: |
# RHOSAK_PARAMETERS
if [ -v KAFKA_HOST ]; then
if [ -v RHOAS_CLIENT_ID ]; then
if [ -v RHOAS_CLIENT_SECRET ]; then
TMP="-Pmanual-rhosak -pl tests/manual/rhosak -Dwildfly.cloud.test.manual.rhoas.kafka.host=$KAFKA_HOST -Dwildfly.cloud.test.manual.rhoas.client.id=$RHOAS_CLIENT_ID -Dwildfly.cloud.test.manual.rhoas.client.secret=$RHOAS_CLIENT_SECRET"
echo "RHOSAK_PARAMETERS=${TMP}" >> $GITHUB_ENV
fi
fi
fi
# 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@v3
with:
path: wildfly
fetch-depth: 1
repository: 'wildfly/wildfly'
- name: Checkout WildFly PR branch
if: ${{github.event.client_payload}}
uses: actions/checkout@v3
with:
path: wildfly
fetch-depth: 1
repository: ${{github.event.client_payload.triggerRepo}}
ref: ${{github.event.client_payload.ref}}
- name: Setup Java JDK
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Checkout WildFly Cloud Tests
uses: actions/checkout@v3
with:
path: cloud-tests
fetch-depth: 1
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-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
working-directory: wildfly
- name: Start minikube
id: minikube
if: inputs.type == 'Kubernetes'
with:
driver: docker
container-runtime: containerd
cpus: 2
memory: 4000m
cni: bridge
uses: medyagh/setup-minikube@master
- name: Enable minikube registry
if: inputs.type == 'Kubernetes'
run: |
minikube addons enable registry
kubectl port-forward --namespace kube-system service/registry 5000:80 &
- name: Setup OpenShift
if: inputs.type == 'Openshift'
uses: manusa/actions-setup-openshift@v1.1.3
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 "OPENSHIFT_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@v2
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}"
mvn -B install -Pimages -fae -Dversion.wildfly=${VERSION_WILDFLY} ${RUNTIME_IMAGE_OVERRIDE} ${OPENSHIFT_MAVEN_PARAMETERS}
working-directory: cloud-tests
- name: Run RHOSAK Tests
if: ${{env.RHOSAK_PARAMETERS}}
working-directory: cloud-tests
run: |
mvn -B install -fae -Dversion.wildfly=${VERSION_WILDFLY} ${RHOSAK_PARAMETERS} ${OPENSHIFT_MAVEN_PARAMETERS}
- 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
- name: Report failure
if: ${{ failure() }}
run: |
echo "It failed"
STATUS="failed"
echo "STATUS=1" >> $GITHUB_ENV
- name: Report success
if: ${{ success() }}
run: |
echo "It passed"
STATUS="passed"
echo "STATUS=0" >> $GITHUB_ENV
- id: output-status
if: ${{ always() }}
run: |
echo "Setting 'status' output to ${STATUS}"
echo "::set-output name=status::${STATUS}"