Skip to content

Regression Tests

Regression Tests #8010

name: Regression Tests
on:
workflow_dispatch:
inputs:
tags:
description: 'Test scenario tags'
required: true
type: string
default: "@regression"
environment:
description: 'Environment to run tests against'
type: environment
required: true
default: "DEV"
product:
description: 'The product we are testing'
type: choice
options:
- CPTS-UI
- EPS-FHIR
- EPS-FHIR-PRESCRIBING
- EPS-FHIR-DISPENSING
- PFP-APIGEE
- PFP-AWS
- PSU
required: false
default: EPS-FHIR
id:
description: 'Unique run identifier (Do not change this)'
required: false
default: "Manually Triggered Run"
pull_request_id:
description: 'The ID of the pull request. This should be in the format pr-xxxx where xxxx is the pull request id'
required: false
default: ""
github_tag:
description: 'The github tag to run the test pack from'
required: false
default: "main"
jobs:
regression_tests:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 0 # This causes all history to be fetched, which is required for calculate-version to function
ref: ${{ inputs.github_tag }}
- name: ${{github.event.inputs.id}}
env:
ID: ${{github.event.inputs.id}}
ENV: ${{ inputs.environment }}
PRODUCT: ${{ inputs.product }}
PULL_REQUEST_ID: ${{ inputs.pull_request_id }}
run: |
echo run identifier "$ID"-"$PRODUCT"-"$ENV"-"$PULL_REQUEST_ID"
echo run identifier "$ID"-"$PRODUCT"-"$ENV"-"$PULL_REQUEST_ID" >> "$GITHUB_STEP_SUMMARY"
# using git commit sha for version of action to ensure we have stable version
- name: Install asdf
uses: asdf-vm/actions/setup@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
- name: Cache asdf
uses: actions/cache@a2ed59d39b352305bdd2f628719a53b2cc4f9613
with:
path: |
~/.asdf
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
restore-keys: |
${{ runner.os }}-asdf-
- name: Install asdf dependencies in .tool-versions
uses: asdf-vm/actions/install@05e0d2ed97b598bfce82fd30daf324ae0c4570e6
env:
PYTHON_CONFIGURE_OPTS: --enable-shared
- name: Cache Virtualenv
uses: actions/cache@a2ed59d39b352305bdd2f628719a53b2cc4f9613
id: cache-venv
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-venv-
- name: Install Dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: make install
- name: Regression Tests
id: tests
continue-on-error: true
env:
PRODUCT: ${{ inputs.product }}
ENVIRONMENT: ${{ inputs.environment }}
PULL_REQUEST_ID: ${{ inputs.pull_request_id }}
TAGS: ${{ inputs.tags }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
CERTIFICATE: ${{ secrets.CERTIFICATE }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
JWT_KID: ${{ secrets.JWT_KID }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
run: |
export CLIENT_ID="$CLIENT_ID"
export CLIENT_SECRET="$CLIENT_SECRET"
export CERTIFICATE="$CERTIFICATE"
export PRIVATE_KEY="$PRIVATE_KEY"
export JWT_KID="$JWT_KID"
export JWT_PRIVATE_KEY="$JWT_PRIVATE_KEY"
export PULL_REQUEST_ID="$PULL_REQUEST_ID"
echo Pull request ID = "$PULL_REQUEST_ID"
poetry run python ./runner.py --env="$ENVIRONMENT" --product="$PRODUCT" --tags="$TAGS"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: allure-results
path: allure-results
if-no-files-found: error
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.REGRESSION_TESTS_APP_ID }}
private-key: ${{ secrets.REGRESSION_TESTS_PEM }}
owner: "NHSDigital"
repositories: "electronic-prescription-service-api-regression-tests,eps-test-reports"
- name: Report failure on test failure
if: steps.tests.outcome != 'success'
run: |
poetry run python scripts/send_test_results.py --token=${{ steps.generate-token.outputs.token }} --run_id ${{GITHUB.RUN_ID}}
echo The regression tests step failed, this likely means there are test failures.
echo A test report will be generated shortly and can be viewed at: https://nhsdigital.github.io/eps-test-reports
exit 1