-
Notifications
You must be signed in to change notification settings - Fork 4
389 lines (371 loc) · 16.7 KB
/
rawls-run-azure-e2e-tests.yaml
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
name: rawls-run-azure-e2e-tests
# This workflow can be run on schedule OR dispatched (manually or by another dispatcher workflow)
# When thw workflow is triggered on schedule, it will use the parameters specified on
# the RHS of || in init-github-context.extract-inputs step. Otherwise, if the workflow is
# triggered by a dispatch event, it will use the parameters specified on LHS of || in
# the init-github-context.extract-inputs step.
#
# Ex.
#
# echo "student-subjects=${{ toJson(inputs.student-subjects || '["[email protected]","[email protected]"]') }}" >> "$GITHUB_OUTPUT"
#
# On schedule: student-subjects output will use '["[email protected]","[email protected]"]'
# Dispatch event: student-subjects output will use inputs.student-subjects
on:
schedule:
# run twice a day at 10:00 and 22:00 UTC every day of the week
- cron: "0 10/12 * * *"
workflow_dispatch:
inputs:
build-branch:
description: 'Build a custom image of Rawls from the specified branch. Default is false, meaning tests are run against the version specified by bee-version-template.'
required: true
default: 'false'
type: choice
options:
- true
- false
branch:
description: 'Branch of Rawls to build a custom image from. Ignored if custom image option is false.'
required: false
default: 'develop'
type: string
bee-version-template:
description: 'The version of services to install on the bee (default is dev, staging is supported). If the custom image option is false, this will also specify the Rawls version.'
required: true
default: 'dev'
type: string
delete-bee:
description: 'Delete created bee after running tests'
required: true
default: 'true'
type: choice
options:
- true
- false
owner-subject:
description: 'Owner subject (used for creating billing project in E2E testing)'
required: true
default: '[email protected]'
type: string
student-subjects:
description: 'A JSON array of Student subjects used for E2E testing'
required: true
default: '["[email protected]","[email protected]"]'
type: string
service-account:
description: 'Email address or unique identifier of the Google Cloud service account for which to generate credentials'
required: true
default: '[email protected]'
type: string
# E2E_ENV is the name of a .env file that contains envvars for E2E tests
env:
RAWLS_BUILD_RUN_NAME: 'rawls-build-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
RAWLS_SWAT_TESTS_RUN_NAME: 'rawls-swat-tests-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
BEE_CREATE_RUN_NAME: 'bee-create-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
BEE_DESTROY_RUN_NAME: 'bee-destroy-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
ATTACH_BP_TO_LZ_RUN_NAME: 'attach-billing-project-to-landing-zone-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
DEL_BP_V2_RUN_NAME: 'delete-billing-project-v2-from-bee-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}'
BEE_NAME: '${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}-dev'
TOKEN: '${{ secrets.BROADBOT_TOKEN }}' # github token for access to kick off a job in the private repo
E2E_ENV: 'azure_e2e.env'
STAGING_CHANNELS: 'C03F21QEWV7,C53JYBV9A' # C53JYBV9A channel is for #dsde-qa
DEV_CHANNELS: 'C03F21QEWV7' #dsp-workspaces-test-alerts
jobs:
init-github-context:
runs-on: ubuntu-latest
outputs:
build-branch: ${{ steps.extract-inputs.outputs.build-branch }}
branch: ${{ steps.extract-inputs.outputs.branch }}
bee-version-template: ${{ steps.extract-inputs.outputs.bee-version-template }}
fully-specified-branch: refs/heads/${{ steps.extract-inputs.outputs.branch }}
delete-bee: ${{ steps.extract-inputs.outputs.delete-bee }}
student-subjects: ${{ steps.extract-inputs.outputs.student-subjects }}
owner-subject: ${{ steps.extract-inputs.outputs.owner-subject }}
service-account: ${{ steps.extract-inputs.outputs.service-account }}
steps:
- name: Get inputs or use defaults
id: extract-inputs
run: |
echo "build-branch=${{ inputs.build-branch || 'false' }}" >> "$GITHUB_OUTPUT"
echo "branch=${{ inputs.branch || 'develop' }}" >> "$GITHUB_OUTPUT"
echo "bee-version-template=${{ inputs.bee-version-template || 'dev' }}" >> "$GITHUB_OUTPUT"
echo "delete-bee=${{ inputs.delete-bee || 'true' }}" >> "$GITHUB_OUTPUT"
echo "owner-subject=${{ inputs.owner-subject || '[email protected]' }}" >> "$GITHUB_OUTPUT"
echo "student-subjects=${{ toJson(inputs.student-subjects || '["[email protected]","[email protected]"]') }}" >> "$GITHUB_OUTPUT"
echo "service-account=${{ inputs.service-account || '[email protected]' }}" >> "$GITHUB_OUTPUT"
rawls-build-tag-publish-job:
runs-on: ubuntu-latest
needs:
- init-github-context
permissions:
contents: 'read'
id-token: 'write'
outputs:
custom-version-json: ${{ needs.init-github-context.outputs.build-branch == 'true' && steps.render-rawls-version.outputs.custom-version-json || ''}}
steps:
- uses: 'actions/checkout@v3'
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
with:
ref: ${{ needs.init-github-context.outputs.branch }}
- name: Bump the tag to a new version
uses: databiosphere/github-actions/actions/[email protected]
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
id: tag
env:
DEFAULT_BUMP: patch
GITHUB_TOKEN: ${{ env.TOKEN }}
RELEASE_BRANCHES: main
WITH_V: true
- name: dispatch build to terra-github-workflows
uses: broadinstitute/[email protected]
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
with:
run-name: "${{ env.RAWLS_BUILD_RUN_NAME }}"
workflow: rawls-build
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: |
{
"run-name": "${{ env.RAWLS_BUILD_RUN_NAME }}",
"repository": "${{ github.event.repository.full_name }}",
"ref": "${{ needs.init-github-context.outputs.fully-specified-branch }}",
"rawls-release-tag": "${{ steps.tag.outputs.tag }}"
}
- name: Render Rawls version
if: ${{ needs.init-github-context.outputs.build-branch == 'true' }}
id: render-rawls-version
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
echo "$GITHUB_CONTEXT"
echo "custom-version-json={\\\"rawls\\\":{\\\"appVersion\\\":\\\"${{ steps.tag.outputs.tag }}\\\"}}" >> $GITHUB_OUTPUT
create-bee-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- rawls-build-tag-publish-job
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Echo Rawls version and version template
run: |
echo "built custom Rawls=${{ needs.init-github-context.outputs.build-branch}}"
echo "custom build Rawls version=${{ needs.rawls-build-tag-publish-job.outputs.custom-version-json }}"
echo "version-template=${{ needs.init-github-context.outputs.bee-version-template }}"
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.BEE_CREATE_RUN_NAME }}"
workflow: bee-create
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.BEE_CREATE_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"bee-template-name": "rawls-e2e-azure-tests",
"version-template": "${{ needs.init-github-context.outputs.bee-version-template }}",
"custom-version-json": "${{ needs.rawls-build-tag-publish-job.outputs.custom-version-json }}"
}'
# This job can be used for generating parameters for E2E tests (e.g. a random project name).
params-gen:
runs-on: ubuntu-latest
outputs:
project-name: ${{ steps.gen.outputs.project_name }}
steps:
- uses: 'actions/checkout@v3'
- name: Generate a random billing project name
id: 'gen'
run: |
project_name=$(echo "tmp-billing-project-$(uuidgen)" | cut -c -30)
echo "project_name=${project_name}" >> $GITHUB_OUTPUT
# Azure Managed App Coordinates are defined in the following workflow:
# https://github.com/broadinstitute/terra-github-workflows/blob/main/.github/workflows/attach-landing-zone-to-bee.yaml
attach-billing-project-to-landing-zone-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- create-bee-workflow
- params-gen
steps:
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.ATTACH_BP_TO_LZ_RUN_NAME }}"
workflow: attach-billing-project-to-landing-zone.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.ATTACH_BP_TO_LZ_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"billing-project": "${{ needs.params-gen.outputs.project-name }}",
"billing-project-creator": "${{ needs.init-github-context.outputs.owner-subject }}",
"service-account": "${{ needs.init-github-context.outputs.service-account }}"
}'
rawls-swat-e2e-test-job:
runs-on: ubuntu-latest
needs:
- init-github-context
- create-bee-workflow
- params-gen
- attach-billing-project-to-landing-zone-workflow
steps:
- name: Configure the user subjects for the test
run: |
escapedJSON=$(echo '${{ needs.init-github-context.outputs.student-subjects }}' | sed 's/"/\"/g')
echo "USER_SUBJECTS={\"service_account\":\"${{ needs.init-github-context.outputs.service-account }}\", \"owners\": [\"${{ needs.init-github-context.outputs.owner-subject }}\"], \"students\": $escapedJSON}" >> $GITHUB_ENV
- name: dispatch to terra-github-workflows
env:
rawls_test_command: "testOnly -- -l ProdTest -l NotebooksCanaryTest -n org.broadinstitute.dsde.test.api.WorkspacesAzureTest"
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.RAWLS_SWAT_TESTS_RUN_NAME }}"
workflow: .github/workflows/rawls-swat-tests.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: |
{
"additional-args": "{\"logging\":\"true\",\"java-version\":\"17\",\"billing-project\":\"${{ needs.params-gen.outputs.project-name }}\"}",
"run-name": "${{ env.RAWLS_SWAT_TESTS_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"ENV": "qa",
"ref": "${{ needs.init-github-context.outputs.build-branch == 'true' && needs.init-github-context.outputs.fully-specified-branch || '' }}",
"test-group-name": "workspaces_azure",
"test-command": "${{ env.rawls_test_command }}",
"e2e-env": "${{ env.E2E_ENV }}",
"user-subjects": ${{ toJson(env.USER_SUBJECTS) }}
}
delete-billing-project-v2-from-bee-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- params-gen
- rawls-swat-e2e-test-job
if: always()
steps:
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.DEL_BP_V2_RUN_NAME }}"
workflow: .github/workflows/delete-billing-project-v2-from-bee.yaml
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.DEL_BP_V2_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}",
"billing-project": "${{ needs.params-gen.outputs.project-name }}",
"billing-project-owner": "${{ needs.init-github-context.outputs.owner-subject }}",
"service-account": "${{ needs.init-github-context.outputs.service-account }}",
"silent-on-failure": "false"
}'
destroy-bee-workflow:
runs-on: ubuntu-latest
needs:
- init-github-context
- rawls-swat-e2e-test-job
- delete-billing-project-v2-from-bee-workflow
if: ${{ needs.init-github-context.outputs.delete-bee == 'true' }}
steps:
- name: dispatch to terra-github-workflows
uses: broadinstitute/[email protected]
with:
run-name: "${{ env.BEE_DESTROY_RUN_NAME }}"
workflow: bee-destroy
repo: broadinstitute/terra-github-workflows
ref: refs/heads/main
token: ${{ env.TOKEN }}
inputs: '{
"run-name": "${{ env.BEE_DESTROY_RUN_NAME }}",
"bee-name": "${{ env.BEE_NAME }}"
}'
wait-for-completion: false
notify-slack-on-success:
runs-on: ubuntu-latest
needs:
- init-github-context
- destroy-bee-workflow
if: ${{ success() }}
steps:
- name: Notify slack
uses: slackapi/[email protected]
with:
channel-id: ${{ needs.init-github-context.outputs.bee-version-template == 'staging' && env.STAGING_CHANNELS || env.DEV_CHANNELS }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Azure Workspaces E2E Test*"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Environment:*\n${{ needs.init-github-context.outputs.build-branch == 'true' && needs.init-github-context.outputs.branch || needs.init-github-context.outputs.bee-version-template }}"
},
{
"type": "mrkdwn",
"text": "*Result:*\n✅ PASSED"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Link to workflow run>"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACKBOT_TOKEN }}
notify-slack-on-failure:
runs-on: ubuntu-latest
needs:
- init-github-context
- destroy-bee-workflow
if: ${{ failure() }}
steps:
- name: Notify slack
uses: slackapi/[email protected]
with:
channel-id: ${{ needs.init-github-context.outputs.bee-version-template == 'staging' && env.STAGING_CHANNELS || env.DEV_CHANNELS }}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Azure Workspaces E2E Test*"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Environment:*\n${{ needs.init-github-context.outputs.build-branch == 'true' && needs.init-github-context.outputs.branch || needs.init-github-context.outputs.bee-version-template }}"
},
{
"type": "mrkdwn",
"text": "*Result:*\n❌ FAILED"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Link to workflow run>"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACKBOT_TOKEN }}