-
Notifications
You must be signed in to change notification settings - Fork 5
295 lines (295 loc) · 11.1 KB
/
int-and-connected-test-run.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
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
290
291
292
293
294
295
name: Unit, Smoke, Connected and Integration tests
env:
K8_CLUSTER: 'integration-master'
# This must be defined for the bash redirection
GOOGLE_APPLICATION_CREDENTIALS: 'jade-dev-account.json'
# This must be defined for the bash redirection
GOOGLE_SA_CERT: 'jade-dev-account.pem'
# This will make test logs not use JSON
TDR_LOG_APPENDER: 'Console-Standard'
# The default Azure credentials to use to authenticate
AZURE_CREDENTIALS_APPLICATIONID: 0e29ec36-04e8-44d5-ae7c-50dc15135571
AZURE_CREDENTIALS_HOMETENANTID: fad90753-2022-4456-9b0a-c7e5b934e408
JADE_USER_EMAIL: [email protected]
RBS_CLIENT_CREDENTIAL_FILE_PATH: rbs-tools-sa.json
AZURE_CREDENTIALS_SECRET: ${{ secrets.AZURE_CREDENTIALS_SECRET }}
AZURE_SYNAPSE_SQLADMINUSER: ${{ secrets.AZURE_SYNAPSE_SQLADMINUSER }}
AZURE_SYNAPSE_SQLADMINPASSWORD: ${{ secrets.AZURE_SYNAPSE_SQLADMINPASSWORD }}
AZURE_SYNAPSE_WORKSPACENAME: tdr-snps-int-east-us-ondemand.sql.azuresynapse.net
CACHE_PATHS: |
build/jacoco
build/reports
build/spotless
build/test-results
build/jacocoHtml
on:
pull_request:
branches:
- develop
paths:
- '!*'
- 'src/**'
- 'gradle**'
- 'gradle/**'
- '**.gradle'
- 'Dockerfile'
- 'datarepo-clienttests/**'
- '.github/workflows/int-and-connected-test-run.yml'
- '.swagger-codegen-ignore'
workflow_dispatch: {}
schedule:
- cron: '0 4 * * *' # run at 4 AM UTC, 12PM EST.
concurrency:
# Don't run this workflow concurrently on the same branch
group: ${{ github.workflow }}-${{ github.ref }}
# For PRs, don't wait for completion of existing runs, cancel them instead
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test_check:
name: "Checkout, verify and run unit tests"
outputs:
job-status: ${{ job.status }}
timeout-minutes: 60
strategy:
matrix:
os: [ubuntu-latest]
if: "!contains( github.event.pull_request.labels.*.name, 'skip-ci')"
runs-on: ${{ matrix.os }}
## skips if pr label is 'skip-ci'
# run a local Postgres container in Docker for the basic check tests
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: "Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Cache build"
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-build-unit }}
- name: "Run unit tests and sonar scan via Gradle"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'gradleinttest'
pgport: ${{ job.services.postgres.ports[5432] }}
test_to_run: 'check'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
sonar_token: ${{ secrets.SONAR_TOKEN }}
test_connected:
name: "Run connected tests"
outputs:
job-status: ${{ job.status }}
timeout-minutes: 180
needs: test_check
strategy:
matrix:
os: [ubuntu-latest]
if: "!contains( github.event.pull_request.labels.*.name, 'skip-ci')"
runs-on: ${{ matrix.os }}
## skips if pr label is 'skip-ci'
# run a local Postgres container in Docker for the basic check tests
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: "Checkout code"
uses: actions/checkout@v3
- name: "Cache build"
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-build-connected
- name: "Write RBS SA to a file"
run: |
# write vault token
base64 --decode <<< ${{ secrets.B64_RBS_APPLICATION_CREDENTIALS }} > ${RBS_CLIENT_CREDENTIAL_FILE_PATH}
- name: "Run connected tests via Gradle"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'gradleinttest'
pgport: ${{ job.services.postgres.ports[5432] }}
test_to_run: 'testConnected'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
- name: "Temp: Archive all junit test reports"
uses: actions/upload-artifact@v2
if: always()
with:
name: junit-test-reports-for-connected
path: build/reports
retention-days: 5
deploy_test_integration:
name: "Run integration and smoke tests"
outputs:
job-status: ${{ job.status }}
api_image_tag: ${{ steps.configuration.outputs.git_hash }}
timeout-minutes: 300
needs: test_check
strategy:
matrix:
os: [ubuntu-latest]
if: "!contains( github.event.pull_request.labels.*.name, 'skip-ci')"
runs-on: ${{ matrix.os }}
## skips if pr label is 'skip-ci'
# run a local Postgres container in Docker for the basic check tests
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: "Checkout code"
uses: actions/checkout@v3
- name: "Cache build"
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-build-integration
- name: "Whitelist Runner IP"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'gcp_whitelist'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
- name: "Check for an available namespace to deploy API to and set state lock"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'k8_checknamespace'
k8_namespaces: 'integration-1,integration-2,integration-3,integration-6'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
- name: "Build docker container via Gradle"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'gradlebuild' # creates gcr build with git_hash tag
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
- name: "Deploy to cluster with Helm"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'helmdeploy'
helm_create_secret_manager_secret_version: 0.0.8
helm_datarepo_api_chart_version: 0.0.708
helm_datarepo_ui_chart_version: 0.0.351
helm_gcloud_sqlproxy_chart_version: 0.19.13
helm_oidc_proxy_chart_version: 0.0.44
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
- name: "Fetch gitHash for deployed integration version"
id: configuration
run: |
git_hash=$(git rev-parse --short HEAD)
echo "git_hash=${git_hash}" >> $GITHUB_OUTPUT
echo "Latest git hash for this branch: $git_hash"
- name: "Wait for deployment to come back online"
uses: broadinstitute/datarepo-actions/actions/[email protected]
timeout-minutes: 20
env:
DESIRED_GITHASH: ${{ steps.configuration.outputs.git_hash }}
DEPLOYMENT_TYPE: 'api'
- name: "Run Test Runner smoke tests via Gradle"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'gradletestrunnersmoketest'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
- name: "Run integration tests via Gradle"
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'gradleinttest'
pgport: ${{ job.services.postgres.ports[5432] }}
test_to_run: 'testIntegration'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
env:
AZURE_CREDENTIALS_APPLICATIONID: ${{ env.AZURE_CREDENTIALS_APPLICATIONID }}
AZURE_CREDENTIALS_HOMETENANTID: ${{ env.AZURE_CREDENTIALS_HOMETENANTID }}
- name: "Clean state lock from used Namespace on API deploy"
if: always()
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'k8_checknamespace_clean'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
- name: "Clean whitelisted Runner IP"
if: always()
uses: broadinstitute/datarepo-actions/actions/[email protected]
with:
actions_subcommand: 'gcp_whitelist_clean'
sa_b64_credentials: ${{ secrets.SA_B64_CREDENTIALS }}
report-to-sherlock:
uses: broadinstitute/sherlock/.github/workflows/client-report-app-version.yaml@main
needs: deploy_test_integration
# Always attempt to run if pull_request, as we want to report the appVersion even if the tests fail.
# never run on cron or other runs as we don't want extranaeous build reporting.
if: github.event_name == 'pull_request'
with:
new-version: ${{ needs.deploy_test_integration.outputs.api_image_tag }}
chart-name: 'datarepo'
permissions:
contents: 'read'
id-token: 'write'
publish_test_reports:
name: "Save execution reports"
timeout-minutes: 60
needs:
- test_check
- test_connected
- deploy_test_integration
strategy:
matrix:
os: [ubuntu-latest]
if: always()
runs-on: ${{ matrix.os }}
steps:
- name: "Load unit test cache"
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-build-unit
- name: "Load connected test cache"
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-build-connected
- name: "Load integration test cache"
uses: actions/cache@v3
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ runner.os }}-build-integration
- name: "Archive code coverage results"
uses: actions/upload-artifact@v2
with:
name: code-coverage-report
path: build/jacocoHtml
retention-days: 10
- name: "Archive all junit test reports"
uses: actions/upload-artifact@v2
if: always()
with:
name: junit-test-reports
path: build/reports
retention-days: 10
report-workflow:
uses: broadinstitute/sherlock/.github/workflows/client-report-workflow.yaml@main
if: ${{ github.ref == 'refs/heads/develop' }}
with:
relates-to-chart-releases: 'datarepo-dev'
notify-slack-channels-upon-workflow-failure: ${{ vars.SLACK_NOTIFICATION_CHANNELS }}
notify-slack-channels-upon-workflow-retry: ${{ vars.SLACK_NOTIFICATION_CHANNELS }}
permissions:
id-token: write