generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (227 loc) · 10.8 KB
/
end-to-end-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
name: End-to-end tests
on:
schedule:
- cron: "0 8 * * MON-FRI" # Every weekday at 08:00 UTC
workflow_call:
inputs:
test-branch:
description: The branch to run in the e2e repo
default: main
type: string
required: false
projects:
description: A JSON array of projects to deploy
type: string
required: true
outputs:
failed-projects:
description: The projects that failed end-to-end testing
value: ${{ jobs.test.outputs.failed-projects }}
passed-projects:
description: The projects that passed end-to-end testing
value: ${{ jobs.test.outputs.passed-projects }}
report-url:
description: The URL of the Playwright HTML report
value: ${{ jobs.test.outputs.report-url }}
workflow_dispatch:
inputs:
test-branch:
description: Test branch
default: main
type: string
required: true
projects:
description: Project
type: choice
required: true
options:
- 'All'
- '["approved-premises-and-delius"]'
- '["approved-premises-and-oasys"]'
- '["court-case-and-delius"]'
- '["create-and-vary-a-licence-and-delius"]'
- '["custody-key-dates-and-delius"]'
- '["domain-events-and-delius"]'
- '["effective-proposal-framework-and-delius"]'
- '["external-api-and-delius"]'
- '["make-recall-decisions-and-delius"]'
- '["manage-pom-cases-and-delius"]'
- '["offender-events-and-delius"]'
- '["pathfinder-and-delius"]'
- '["person-search-index-from-delius"]'
- '["pre-sentence-reports-to-delius"]'
- '["prison-case-notes-to-probation"]'
- '["prison-custody-status-to-delius"]'
- '["refer-and-monitor-and-delius"]'
- '["risk-assessment-scores-to-delius"]'
- '["sentence-plan-and-delius"]'
- '["sentence-plan-and-oasys"]'
- '["soc-and-delius"]'
- '["tier-to-delius"]'
- '["unpaid-work-and-delius"]'
- '["workforce-allocations-to-delius"]'
- '["manage-offences-and-delius"]'
- '["resettlement-passport-and-delius"]'
- '["prison-education-and-delius"]'
- '["opd-and-delius"]'
- '["hmpps-auth-and-delius"]'
# ^ add new projects here
# GitHub Actions doesn't support dynamic choices, we must add each project here to enable manual deployments
# See https://github.com/community/community/discussions/11795
env:
auto_pass_projects: '["manage-offences-and-delius"]'
jobs:
test:
runs-on: moj-cloud-platform
timeout-minutes: 60
outputs:
failed-projects: ${{ steps.json.outputs.failed-projects }}
passed-projects: ${{ steps.json.outputs.passed-projects }}
report-url: ${{ steps.html.outputs.report-url }}
steps:
- uses: actions/checkout@v3
with:
repository: ministryofjustice/hmpps-probation-integration-e2e-tests
ref: ${{ inputs.test-branch }}
- name: Get tests to run - all tests
if: inputs.projects == '' || inputs.projects == 'All'
run: echo "projects=$(find projects -mindepth 1 -maxdepth 1 -printf "%f\n" | jq --raw-input . | jq --slurp --compact-output .)" | tee -a "$GITHUB_ENV"
- name: Get tests to run - specific tests
if: inputs.projects != '' && inputs.projects != 'All'
run: echo 'projects=${{ inputs.projects }}' | tee -a "$GITHUB_ENV"
- name: Get report output directory
run: echo "report-dir=playwright-report/test/$REF/$(date '+%Y-%m-%d')/${{ github.sha }}/${{ github.run_id }}/${{ github.run_attempt }}" | tee -a "$GITHUB_ENV"
env:
REF: ${{ github.ref_name }}
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install
- name: Run Playwright tests
id: tests
run: echo '${{ env.projects }}' | jq -r '.[]' | xargs npx playwright test --reporter=html,junit,json,line --workers=16
env:
TZ: Europe/London
ENV: test
DELIUS_URL: https://ndelius.test.probation.service.justice.gov.uk
WORKFORCE_URL: https://workforce-management-dev.hmpps.service.justice.gov.uk
DPS_URL: https://digital-dev.prison.service.justice.gov.uk
AUTH_URL: https://sign-in-dev.hmpps.service.justice.gov.uk
PRISON_API: https://prison-api-dev.prison.service.justice.gov.uk
EPF_API: https://effective-proposal-framework-and-delius-dev.hmpps.service.justice.gov.uk
EXTERNAL_API: https://external-api-and-delius-dev.hmpps.service.justice.gov.uk
REFERANDMONITOR_URL: https://hmpps-interventions-ui-dev.apps.live-1.cloud-platform.service.justice.gov.uk
OASYS_URL: https://t2.oasys.service.justice.gov.uk/eor/f?p=100:101
APPROVEDPREMISES_URL: https://approved-premises-dev.hmpps.service.justice.gov.uk
CONSIDER_A_RECALL_URL: https://consider-a-recall-dev.hmpps.service.justice.gov.uk
MANAGE_POM_CASES_URL: https://dev.moic.service.justice.gov.uk
DELIUS_USERNAME: ${{ secrets.E2E_DELIUS_USERNAME }}
DELIUS_PASSWORD: ${{ secrets.E2E_DELIUS_PASSWORD }}
DPS_USERNAME: ${{ secrets.E2E_DPS_USERNAME }}
DPS_PASSWORD: ${{ secrets.E2E_DPS_PASSWORD }}
CRED_USERNAME: ${{ secrets.E2E_CLIENT_ID }}
CRED_PASSWORD: ${{ secrets.E2E_CLIENT_SECRET }}
REFERANDMONITOR_SUPPLIER_USERNAME: ${{ secrets.E2E_REFERANDMONITOR_SUPPLIER_USERNAME }}
REFERANDMONITOR_SUPPLIER_PASSWORD: ${{ secrets.E2E_REFERANDMONITOR_SUPPLIER_PASSWORD }}
RESETTLEMENT_PASSPORT_AND_DELIUS_API: https://resettlement-passport-and-delius-dev.hmpps.service.justice.gov.uk
OASYS_USERNAME_BOOKING: ${{ secrets.E2E_OASYS_USERNAME_BOOKING }}
OASYS_PASSWORD_BOOKING: ${{ secrets.E2E_OASYS_PASSWORD_BOOKING }}
OASYS_USERNAME_RSR: ${{ secrets.E2E_OASYS_USERNAME_RSR }}
OASYS_PASSWORD_RSR: ${{ secrets.E2E_OASYS_PASSWORD_RSR }}
OASYS_USERNAME_TIMELINE: ${{ secrets.E2E_OASYS_USERNAME_TIMELINE }}
OASYS_PASSWORD_TIMELINE: ${{ secrets.E2E_OASYS_PASSWORD_TIMELINE }}
APPROVEDPREMISES_USERNAME: ${{ secrets.E2E_DELIUS_USERNAME }}
APPROVEDPREMISES_PASSWORD: ${{ secrets.E2E_DELIUS_PASSWORD }}
CONSIDER_A_RECALL_MRD_USERNAME: ${{ secrets.E2E_CONSIDER_RECALL_MRD_USERNAME }}
CONSIDER_A_RECALL_MRD_PASSWORD: ${{ secrets.E2E_CONSIDER_RECALL_MRD_PASSWORD }}
CONSIDER_RECALL_MRD_PASSWORD: ${{ secrets.E2E_CONSIDER_RECALL_MRD_PASSWORD }}
PLAYWRIGHT_JUNIT_OUTPUT_NAME: junit.xml
PLAYWRIGHT_JSON_OUTPUT_NAME: results.json
- name: Parse JSON results
if: always()
id: json
run: |
if [ -f results.json ]; then
skipped_projects=$(echo "$all_projects" | jq -r '.[]' | while read -r project; do if [ ! -d "tests/$project" ]; then echo $project; fi; done | jq --raw-input . | jq --slurp --compact-output .)
failed_projects=$(jq -r '.suites[].specs[] | select(.ok == false).file' results.json | xargs -n1 dirname | sort -u | jq --raw-input . | jq --slurp --compact-output .)
passed_projects=$(jq --compact-output --null-input --argjson all "$all_projects" --argjson failed "$failed_projects" --argjson skipped "$skipped_projects" '{all: $all, failed: $failed, skipped: $skipped} | .all - .failed - .skipped')
merged=$(echo "$auto_pass_projects $passed_projects" | jq -s 'add')
passed_projects=$(echo "$merged $projects" | jq -sc '.[0] - (.[0] - .[1])')
fi
echo "skipped-projects=${skipped_projects:-'[]'}" | tee -a "$GITHUB_OUTPUT"
echo "failed-projects=${failed_projects:-'[]'}" | tee -a "$GITHUB_OUTPUT"
echo "passed-projects=${passed_projects:-'[]'}" | tee -a "$GITHUB_OUTPUT"
env:
all_projects: ${{ env.projects }}
- name: Publish JUnit report
if: always()
uses: mikepenz/action-junit-report@0a8a5ba57593d67b2e45de2c543b438412382b7b # v4.0.1
id: junit
with:
check_name: End-to-end test results
report_paths: junit.xml
- name: Publish HTML report
if: always()
uses: JamesIves/github-pages-deploy-action@22a6ee251d6f13c6ab1ecb200d974f1a6feb1b8d # v4
with:
folder: playwright-report
target-folder: ${{ env.report-dir }}
- name: Output HTML report URL
id: html
if: always()
run: |
echo '[🎭 Playwright HTML Report](https://ministryofjustice.github.io/hmpps-probation-integration-services/${{ env.report-dir }})' | tee -a "$GITHUB_STEP_SUMMARY"
echo 'report-url=https://ministryofjustice.github.io/hmpps-probation-integration-services/${{ env.report-dir }}' | tee -a "$GITHUB_OUTPUT"
- name: Send message to Slack
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
if: ${{ failure() && github.event_name == 'schedule' }}
with:
channel-id: probation-integration-notifications
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "🎭 *Probation Integration Services* end-to-end test failure"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": ">${{ steps.junit.outputs.total }} tests run, ${{ steps.junit.outputs.passed }} passed, ${{ steps.junit.outputs.skipped }} skipped, ${{ steps.junit.outputs.failed }} failed."
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "📈 Report"
},
"url": "https://ministryofjustice.github.io/hmpps-probation-integration-services/${{ env.report-dir }}"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "📝 Logs"
},
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}