Skip to content

Regression Tests

Regression Tests #2277

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:
- EPS-FHIR
- PFP-APIGEE
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 }}
run: |
export CLIENT_ID="$CLIENT_ID"
export CLIENT_SECRET="$CLIENT_SECRET"
export CERTIFICATE="$CERTIFICATE"
export PRIVATE_KEY="$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@0b2256b8c012f0828dc542b3febcab082c67f72b
with:
name: allure-results
path: allure-results
if-no-files-found: error
- name: checkout github page repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
repository: NHSDigital/eps-test-reports
token: ${{ secrets.REGRESSION_TESTS_PAT }}
path: ${{ env.GITHUB_REF_NAME }}
- name: Download Artifact
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
with:
name: allure-results
path: allure-results
- name: Commit results to GitHub Pages Repo
env:
PRODUCT: ${{ inputs.product }}
ENVIRONMENT: ${{ inputs.environment }}
PULL_REQUEST_ID: ${{ inputs.pull_request_id }}
run: |
DATE_TIME=$(date +"%Y%m%d%H%M%S")
git checkout -b regression-tests-"$DATE_TIME"-"$PRODUCT"-"$ENVIRONMENT"-"$PULL_REQUEST_ID"
git config user.name github-actions
git config user.email [email protected]
git add allure-results/*
git commit -m "regression-tests-$DATE_TIME-$PRODUCT-$ENVIRONMENT-$PULL_REQUEST_ID"
git push --set-upstream origin regression-tests-"$DATE_TIME"-"$PRODUCT"-"$ENVIRONMENT"-"$PULL_REQUEST_ID"
- name: Report failure on test failure
if: steps.tests.outcome != 'success'
run: |
echo The regression tests step failed, this likely means there are test failures.
echo The report will be generated shortly
exit 1