Skip to content

End-to-end tests

End-to-end tests #498

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 }}