-
Notifications
You must be signed in to change notification settings - Fork 0
248 lines (220 loc) · 9.12 KB
/
automated-idp-web-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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
name: Run UW IdP Web Tests
on:
push:
branches:
# This branch override is meant to act as a way of validating
# the workflow itself, which is difficult to do well out
# of context. Feel free to push to this branch at any time.
# You may need to use `-f` when pushing.
- run-uw-idp-web-tests
pull_request:
paths-ignore:
- "*.md" # No reason to run tests when only docs change
workflow_dispatch:
inputs:
target-idp-env:
description: >
target-idp-env. Acceptable values are `eval`, `prod`. The idp environment
you want to test against.
required: true
default: eval
target-idp-host:
description: >
target-idp-host. Optional. If provided, will add an /etc/hosts entry
targeting this host.
required: false
reason:
description: >
reason. The reason for running this test suite; can be helpful to
provide context and distinguish different runs.
required: false
slack-channel:
description: >
slack-channel. The channel to send a notification to, detailing the
context and outcome of the test. (`/invite @iam-github-slack-crier`
in the channel, if not already done.)
required: true
default: '#iam-bot-sandbox'
pytest-args:
description: >
pytest-args. Any args you want to send to pytest. You do not ever need to
supply `log_cli` arguments.
required: false
env:
###############################################
# Do not edit the env values below this line. #
# Other defaults are set in .github/scripts/configure-workflow.sh
SLACK_BOT_TOKEN: ${{ secrets.ACTIONS_SLACK_BOT_TOKEN }}
ARTIFACT_BUCKET: ${{ secrets.IDENTITY_ARTIFACT_BUCKET }}
###############################################
jobs:
run-idp-web-tests:
name: Configure and run tests, and upload test artifacts
runs-on: ubuntu-latest
env:
UPLOAD_STATUS: 'not started'
ARTIFACT_HOST: "https://identity-artifact.iamdev.s.uw.edu"
outputs:
slack-channel: ${{ steps.configure.outputs.slack-channel }}
# These outputs come from the configure-workflow.sh script
report-object-path: ${{ steps.configure.outputs.report-object-path }}
report-url: ${{ steps.configure.outputs.report-url }}
short-sha: ${{ steps.configure.outputs.short-sha }}
pr-number: ${{ steps.configure.outputs.pr-number }}
workflow-id: ${{ steps.configure.outputs.workflow-id }}
workflow-snapshot-artifact: ${{ steps.configure.outputs.workflow-snapshot-artifact }}
idp-env: ${{ steps.configure.outputs.idp-env }}
idp-host: ${{ steps.configure.outputs.idp-host }}
run-tests-args: ${{ steps.configure.outputs.run-tests-args }}
permissions:
contents: 'read'
id-token: 'write'
pull-requests: 'write'
steps:
- uses: actions/checkout@main
- id: configure
env:
INPUT_TARGET_IDP_ENV: ${{ github.event.inputs.target-idp-env }}
INPUT_TARGET_IDP_HOST: ${{ github.event.inputs.target-idp-host }}
INPUT_REASON: ${{ github.event.inputs.reason }}
INPUT_SLACK_CHANNEL: ${{ github.event.inputs.slack-channel }}
INPUT_PYTEST_ARGS: ${{ github.event.inputs.pytest-args }}
UWCA_CERT: ${{ secrets.UWCA_CERT }}
UWCA_KEY: ${{ secrets.UWCA_KEY }}
run: |
source ./.github/scripts/configure-workflow.sh
configure-workflow
- id: set-envs
run: |
echo "SLACK_CANVAS_ID=${{ steps.configure.outputs.workflow-id }}" >> $GITHUB_ENV
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.TEST_RUNNER_GOOGLE_TOKEN }}
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
version: '>= 363.0.0'
- name: Initialize slack workflow canvas
env:
IDP_ENV: ${{ steps.configure.outputs.idp-env }}
with:
command: create-canvas
# Since your IDE may not pick up on this as JSON and help you,
# always make sure to run this through a JSON validator.
json: >
{
"channel": "${{ steps.configure.outputs.slack-channel }}",
"canvasId": "${{ steps.configure.outputs.workflow-id }}",
"status": "in progress",
"description": "${{ env.IDP_ENV }} IdP Web Tests",
"steps": [
{
"description": "Configure workflow",
"status": "succeeded",
"stepId": "configure-workflow"
},
{
"description": "Run UW IdP tests",
"stepId": "run-tests",
"status": "in progress"
},
{
"description": "Upload test artifacts",
"stepId": "upload-artifacts"
}
]
}
channel: ${{ steps.configure.outputs.slack-channel }}
description: ${{ env.IDP_ENV }} IdP Web Tests
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- name: add change information to slack canvas
with:
command: add-artifact
description: ${{ steps.configure.outputs.workflow-snapshot-artifact }}
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- env:
RUN_TESTS_ARGS: ${{ steps.configure.outputs.run-tests-args }}
IDP_ENV: ${{ steps.configure.outputs.idp-env }}
run: |
exit_status=0
if ./scripts/run-tests.sh ${{ steps.args.outputs.extra }} ${{ env.RUN_TESTS_ARGS }}
then
echo "All tests succeeded for ${{ env.IDP_ENV }} succeeded! "
test_status=succeeded
else
exit_status=$?
echo "Tests for ${{ env.IDP_ENV }} failed with status $exit_status"
test_status=failed
fi
# Only upload artifacts if the test suite actually ran.
echo "test-status=$test_status" >> $GITHUB_OUTPUT
echo "upload-artifacts=true" >> $GITHUB_OUTPUT
exit $exit_status
name: Run UW ${{ env.IDP_ENV }} IdP Web Tests
id: run-tests
- if: always()
env:
upload_step_status: >
${{ steps.run-tests.outputs.upload-artifacts == 'true' && 'in progress' || 'not started' }}
test_status: ${{ steps.run-tests.outputs.test-status }}
with:
command: update-workflow
step-id: run-tests, upload-artifacts
step-status: ${{ env.test_status }}, ${{ env.upload_step_status }}
workflow-status: ${{ env.test_status == 'succeeded' && 'in progress' || 'failed' }}
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- if: ${{ always() && steps.run-tests.outputs.upload-artifacts == 'true' }}
id: upload-artifacts
with:
path: web-tests
destination: ${{ secrets.IDENTITY_ARTIFACT_BUCKET }}
name: upload storyboards to identity-artifacts
uses: google-github-actions/upload-cloud-storage@v2
- if: ${{ always() && steps.run-tests.outputs.upload-artifacts == 'true' }}
with:
command: update-workflow
step-id: upload-artifacts
step-status: >
${{ steps.upload-artifacts.conclusion == 'success' && 'succeeded' || 'failed' }}
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- if: ${{ always() && steps.run-tests.outputs.upload-artifacts == 'true' }}
with:
command: add-artifact
description: >
*Storyboards*: ${{ steps.configure.outputs.report-url }}
name: add storyboard link to slack canvas
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- if: always()
with:
command: update-workflow
workflow-status: ${{ steps.run-tests.conclusion == 'success' && 'succeeded' || 'failed' }}
name: Update workflow status
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- if: always()
with:
command: remove-step
step-id: '*'
step-status: succeeded
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- if: always()
with:
command: finalize-workflow
name: clean up slack canvas metadata
uses: UWIT-IAM/actions/update-slack-workflow-canvas@main
- if: ${{ always() && github.event_name == 'pull_request' }}
id: update-pull-request
uses: mshick/add-pr-comment@v1
name: Add storyboard link to pull request
env:
REPORT_URL: ${{ steps.configure.outputs.report-url }}
SHORT_SHA: ${{ steps.configure.outputs.short-sha }}
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]' # Don't change
allow-repeats: true
message: |
- Test result: ${{ steps.run-tests.outcome }}
- [Storyboards](${{ env.REPORT_URL }})
**Commit ${{ env.SHORT_SHA }}**