-
Notifications
You must be signed in to change notification settings - Fork 5
226 lines (194 loc) · 8.26 KB
/
ci-tests.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
name: CI Testing
on:
push:
branches:
- v1.x/master
- v2.x/master
pull_request:
branches:
- v1.x/master
- v2.x/master
workflow_dispatch:
env:
MARIST_HOST: ${{ secrets.SSH_MARIST_RACF_HOST }}
MARIST_SSH_PORT: ${{ secrets.SSH_MARIST_ALLSYS_PORT }}
MARIST_TMP_DIRECTORY: /ZOWE/tmp
MARIST_TEST_DIRECTORY: /ZOWE/tmp/files-integration-test-${{ github.run_id }}_${{ github.run_number }}
JOB_ID: ${{ github.run_id }}-${{ github.run_number }}
MARIST_FILE_SETUP_SCRIPT: prepare-integration-test-folders.sh
ZOSMF_PORT: 10443
GATEWAY_PORT: 7554
FILES_PORT: 8443
FILES_LOG_DIR: .apiml/files-api.log
jobs:
UnitTest:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: ./.github/actions/setup
- name: Build with Gradle
run: ./gradlew build
- name: Unit test with Gradle
run: ./gradlew coverage
- name: Store test results
uses: actions/upload-artifact@v2
if: always()
with:
name: UnitTestResults-${{ env.JOB_ID }}
path: |
build/reports/jacoco/jacocoFullReport/html
data-sets-api-server/build/reports/tests/test
- uses: ./.github/actions/teardown
IntegrationTest:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: ./.github/actions/setup
- name: Build with Gradle
run: ./gradlew build
- name: Run APIML containers
run: |
chmod +x scripts/run-containerized-apiml.sh
./scripts/run-containerized-apiml.sh -h ${{ env.MARIST_HOST }} -p ${{ env.ZOSMF_PORT }} -f ${{ env.FILES_PORT }} -l
env:
GATEWAY_PORT: ${{ env.GATEWAY_PORT }}
- name: Run Files API server
run: |
chmod +x data-sets-zowe-server-package/src/main/resources/bin/start.sh
data-sets-zowe-server-package/src/main/resources/bin/start.sh > ${{ env.FILES_LOG_DIR }} &
env:
LAUNCH_COMPONENT: data-sets-api-server/build/libs # point start.sh to jar file directory
EXPLORER_API_LOG_LEVEL: debug
FILES_API_PORT: ${{ env.FILES_PORT }}
KEY_ALIAS: localhost
KEYSTORE: .apiml/keystore/localhost.keystore.p12
KEYSTORE_PASSWORD: password
GATEWAY_PORT: ${{ env.GATEWAY_PORT }}
- name: Validate APIML setup
# poll for 2 minutes, if GW not healthy after 3 minutes then exit
run: |
set +e # curl -s doesn't swallow the error alone
attemptCounter=1
maxAttempts=18
until [ $attemptCounter -gt $maxAttempts ]; do
sleep 10
gwHealth=$(curl -k -s https://localhost:${{ env.GATEWAY_PORT }}/application/health)
echo "Polling for GW health: $attemptCounter"
echo $gwHealth
gatewayUp=$(echo $gwHealth | jq -r '.status')
authUp=$(echo $gwHealth | jq -r '.components.gateway.details.auth')
if [ "$gatewayUp" = "UP" ] && [ "$authUp" = "UP" ]; then
echo ">>>>>APIML is ready"
break
fi
attemptCounter=$((attemptCounter+1))
done
if [ "$gatewayUp" != "UP" ] || [ "$authUp" != "UP" ]; then
echo ">>>>>APIML is not ready"
exit 1
fi
- uses: zowe-actions/shared-actions/prepare-workflow@main
- name: Lock marist server
uses: zowe-actions/shared-actions/lock-resource@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lock-resource-name: files-integration-tests-${{ env.MARIST_HOST }}-lock
lock-avg-retry-interval: 60
- name: Prepare server side files
timeout-minutes: 3
run: |
sshpass -e sftp -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${{ env.MARIST_SSH_PORT }} ${{ secrets.SSH_MARIST_USERNAMEP }}@${{ env.MARIST_HOST }} << EOF
cd ${{ env.MARIST_TMP_DIRECTORY }}
put scripts/${{ env.MARIST_FILE_SETUP_SCRIPT }}
EOF
sshpass -e ssh -tt -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -p ${{ env.MARIST_SSH_PORT }} ${{ secrets.SSH_MARIST_USERNAMEP }}@${{ env.MARIST_HOST }} << EOF
cd ${{ env.MARIST_TMP_DIRECTORY }}
iconv -f ISO8859-1 -t IBM-1047 ${{ env.MARIST_FILE_SETUP_SCRIPT }} > ${{ env.MARIST_FILE_SETUP_SCRIPT }}.new
mv ${{ env.MARIST_FILE_SETUP_SCRIPT }}.new ${{ env.MARIST_FILE_SETUP_SCRIPT }} && chmod +x ${{ env.MARIST_FILE_SETUP_SCRIPT }}
./${{ env.MARIST_FILE_SETUP_SCRIPT }} "${{ env.MARIST_TEST_DIRECTORY }}_v1" || { echo "[${{ env.MARIST_FILE_SETUP_SCRIPT }} v1] failed"; exit 1; }
./${{ env.MARIST_FILE_SETUP_SCRIPT }} "${{ env.MARIST_TEST_DIRECTORY }}_v2" || { echo "[${{ env.MARIST_FILE_SETUP_SCRIPT }} v2] failed"; exit 1; }
echo "[${{ env.MARIST_FILE_SETUP_SCRIPT }}] successful for v1 and v2" && exit 0
EOF
env:
SSHPASS: ${{ secrets.SSH_MARIST_PASSWORDP }}
- name: Integration tests for v1 - LTPA
run: >
./gradlew runIntegrationTests --info
-Pserver.host=localhost
-Pserver.port=${{ env.GATEWAY_PORT }}
-Pserver.username=${{ secrets.SSH_MARIST_USERNAMEL }}
-Pserver.password=${{ secrets.SSH_MARIST_PASSWORDL }}
-Pserver.test.directory=${{ env.MARIST_TEST_DIRECTORY }}_v1
-Ptest.version=1
- name: Integration tests for v2 - JWT
run: >
./gradlew runIntegrationTests --info
-Pserver.host=localhost
-Pserver.port=${{ env.GATEWAY_PORT }}
-Pserver.username=${{ secrets.SSH_MARIST_USERNAMEL }}
-Pserver.password=${{ secrets.SSH_MARIST_PASSWORDL }}
-Pserver.test.directory=${{ env.MARIST_TEST_DIRECTORY }}_v2
-Ptest.version=2
- name: Clean up integration test files
timeout-minutes: 3
if: always()
run: |
sshpass -e ssh -tt -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -p ${{ env.MARIST_SSH_PORT }} ${{ secrets.SSH_MARIST_USERNAMEP }}@${{ env.MARIST_HOST }} << EOF
cd ${{ env.MARIST_TMP_DIRECTORY }}
[ -f "${{ env.MARIST_FILE_SETUP_SCRIPT }}" ] && rm ${{ env.MARIST_FILE_SETUP_SCRIPT }}
[ -d "${{ env.MARIST_TEST_DIRECTORY }}_v1" ] && rm -rf ${{ env.MARIST_TEST_DIRECTORY }}_v1
[ -d "${{ env.MARIST_TEST_DIRECTORY }}_v2" ] && rm -rf ${{ env.MARIST_TEST_DIRECTORY }}_v2
echo "Done cleaning up integration test files" && exit 0
EOF
env:
SSHPASS: ${{ secrets.SSH_MARIST_PASSWORDP }}
- name: Output Files API logs
if: always()
run: >
if [ -f ${{ env.FILES_LOG_DIR }} ]; then
echo ">>>>>Data Set API logs"
cat ${{ env.FILES_LOG_DIR }}
else
echo ">>>>>No Data Set API logs"
fi
- name: Output APIML logs
if: always()
run: docker-compose -f .apiml/docker-compose.yml logs
- name: Store test results
uses: actions/upload-artifact@v2
if: always()
with:
name: IntegrationTestResults-${{ env.JOB_ID }}
path: |
data-sets-tests/build/reports/tests/test-1
data-sets-tests/build/reports/tests/test-2
- uses: ./.github/actions/teardown
SonarQubeScan:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: ./.github/actions/setup
with:
jdkVersion: 17
- name: Sonar scan with Gradle
run: >
./gradlew compileJava compileTestJava sonarqube --info
-x test
-Psonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_TOKEN
-Partifactory_user=$ARTIFACTORY_USERNAME -Partifactory_password=$ARTIFACTORY_PASSWORD
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: ./.github/actions/teardown