-
Notifications
You must be signed in to change notification settings - Fork 5
190 lines (158 loc) · 5.74 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
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: 'zzow04.zowe.marist.cloud'
ZOSMF_PORT: 10443
GATEWAY_PORT: 7554
JOBS_PORT: 8443
JOBS_LOG_DIR: .apiml/jobs-api.log
jobs:
UnitTest:
runs-on: ubuntu-latest
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
path: |
build/reports/jacoco/jacocoFullReport/html
jobs-api-server/build/reports/tests/test
- uses: ./.github/actions/teardown
IntegrationTest:
runs-on: ubuntu-latest
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.JOBS_PORT }} -l
env:
GATEWAY_PORT: ${{ env.GATEWAY_PORT }}
- name: Run Jobs API server
run: |
# start.sh uses $(pwd)/bin to locate jar file
mkdir ./bin
cp jobs-api-server/build/libs/jobs-api-server-*.jar ./bin
chmod +x ./bin/jobs-api-server-*.jar
chmod +x jobs-zowe-server-package/src/main/resources/bin/start.sh
./jobs-zowe-server-package/src/main/resources/bin/start.sh > ${{ env.JOBS_LOG_DIR }} &
env:
ZWE_configs_debug: true
ZWE_configs_port: ${{ env.JOBS_PORT }}
ZWE_configs_certificate_keystore_alias: localhost
ZWE_configs_certificate_keystore_file: .apiml/keystore/localhost.keystore.p12
ZWE_configs_certificate_keystore_password: password
ZWE_components_gateway_port: ${{ env.GATEWAY_PORT }}
- name: Validate APIML setup
# poll for 3 minutes, if GW not healthy after 2 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: jobs-integration-tests-${{ env.MARIST_HOST }}-lock
lock-avg-retry-interval: 60
- name: Integration tests for v1 - LTPA
run: >
./gradlew runIntegrationTests --info
-Pserver.host=localhost
-Pserver.port=${{ env.GATEWAY_PORT }}
-Pserver.username=${{ secrets.SSH_MARIST_USERNAMEP }}
-Pserver.password=${{ secrets.SSH_MARIST_PASSWORDP }}
-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_USERNAMEP }}
-Pserver.password=${{ secrets.SSH_MARIST_PASSWORDP }}
-Ptest.version=2
- name: Output Jobs API logs
if: always()
run: >
if [ -f ${{ env.JOBS_LOG_DIR }} ]; then
echo ">>>>>Jobs API logs"
cat ${{ env.JOBS_LOG_DIR }}
else
echo ">>>>>No Jobs 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
path: |
jobs-tests/build/reports/tests/test-1
jobs-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: 11
- 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