Attached_screen_shots #862
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Regression Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
marker: | |
description: 'Test scenario tags' | |
required: false | |
type: string | |
default: '' | |
environment: | |
description: 'Environment to run tests against' | |
type: environment | |
required: true | |
default: "dev" | |
product: | |
description: 'The product we are testing' | |
type: choice | |
options: | |
- RAVS | |
required: false | |
default: RAVS | |
browser: | |
description: 'Browser to run tests on' | |
type: choice | |
options: | |
- chrome | |
- firefox | |
- safari | |
- edge | |
- mobile | |
required: false | |
default: "edge" | |
device: | |
description: 'Device to run tests on' | |
type: choice | |
options: | |
- iphone_12 | |
- iphone_11 | |
- pixel_5 | |
required: false | |
default: "iphone_12" | |
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" | |
push: | |
branches: | |
- '**' | |
schedule: | |
- cron: '0 6 * * *' | |
- cron: '30 6 * * *' | |
jobs: | |
regression_tests: | |
runs-on: ubuntu-latest | |
environment: ${{ github.event_name == 'push' && 'dev' || (github.event_name == 'schedule' && github.event.schedule == '0 6 * * *' && 'qa' || (github.event_name == 'workflow_dispatch' && inputs.environment || 'dev')) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache Python dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Set Environment Variables | |
run: | | |
if [[ "${{ github.event_name }}" == "schedule" ]]; then | |
case "${{ github.event.schedule }}" in | |
"0 6 * * *") | |
echo "ENV=qa" >> $GITHUB_ENV | |
;; | |
"30 6 * * *") | |
echo "ENV=dev" >> $GITHUB_ENV | |
;; | |
*) | |
echo "Unrecognized schedule. Defaulting to dev." | |
echo "ENV=dev" >> $GITHUB_ENV | |
;; | |
esac | |
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
echo "ENV=${{ github.event.inputs.environment }}" >> $GITHUB_ENV | |
elif [[ "${{ github.event_name }}" == "push" ]]; then | |
echo "ENV=dev" >> $GITHUB_ENV | |
else | |
echo "Unknown event. Defaulting to dev." | |
echo "ENV=dev" >> $GITHUB_ENV | |
fi | |
echo "BROWSER=${{ github.event.inputs.browser || 'edge' }}" >> $GITHUB_ENV | |
echo "DEVICE=${{ github.event.inputs.device || 'iphone_12' }}" >> $GITHUB_ENV | |
echo "PRODUCT=${{ github.event.inputs.product || 'RAVS' }}" >> $GITHUB_ENV | |
- name: Notify Slack - Tests Started | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
TRIGGER_SOURCE="π *Tests have been kicked off manually by* ${{ github.actor }}." | |
elif [[ "${{ github.event_name }}" == "schedule" ]]; then | |
TRIGGER_SOURCE="π *Tests have been triggered by a scheduled run.*" | |
elif [[ "${{ github.event_name }}" == "push" ]]; then | |
TRIGGER_SOURCE="π *Tests have been triggered by a code push.*" | |
else | |
TRIGGER_SOURCE="π *Tests have started.*" | |
fi | |
BROWSER_MESSAGE="${{ env.BROWSER }}" | |
if [[ "${{ env.BROWSER }}" == "mobile" ]]; then | |
BROWSER_MESSAGE="Mobile (${{ env.DEVICE }})" | |
fi | |
SLACK_MESSAGE="${TRIGGER_SOURCE}\n | |
*Environment:* ${{ env.ENV }} | |
*Product:* ${{ env.PRODUCT }} | |
*Run ID:* ${{ github.run_id }} | |
*Browser:* ${BROWSER_MESSAGE} | |
*Branch:* ${{ github.ref_name }}" | |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"${SLACK_MESSAGE}\"}" ${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Install xvfb | |
run: sudo apt-get install xvfb | |
- name: Install Playwright | |
run: | | |
python -m pip install playwright | |
playwright install | |
playwright install --with-deps webkit | |
playwright install-deps | |
- name: Install Allure Commandline | |
run: | | |
curl -o allure-commandline-2.17.3.tgz -Ls https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.17.3/allure-commandline-2.17.3.tgz && \ | |
tar -zxvf allure-commandline-2.17.3.tgz -C /opt/ && \ | |
sudo ln -s /opt/allure-2.17.3/bin/allure /usr/bin/allure && \ | |
rm -rf allure-commandline-2.17.3.tgz | |
- name: Run Tests | |
env: | |
TZ: "Europe/London" | |
LANG: "en_GB.UTF-8" | |
LC_ALL: "en_GB.UTF-8" | |
TEST_ENVIRONMENT: ${{ env.ENV }} | |
RAVS_PASSWORD: ${{ secrets.RAVS_PASSWORD }} | |
HEADLESS_MODE: "true" | |
BROWSER: ${{ env.BROWSER }} | |
DEVICE: ${{ env.DEVICE }} | |
MARKER: ${{ inputs.marker || '' }} | |
AGENTS: 3 | |
run: | | |
tox -v | |
continue-on-error: true | |
- name: Upload Allure Results | |
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: ${{ secrets.EPS_REGRESSION_TESTING_APP_ID }} | |
private-key: ${{ secrets.EPS_REGRESSION_TESTING_PEM }} | |
owner: "NHSDigital" | |
repositories: "ravs-tests,ravs-test-reports" | |
- name: Trigger test report generation | |
run: | | |
curl -X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Authorization: Bearer ${{ steps.generate-token.outputs.token }}" \ | |
-d '{"ref": "main", "inputs": {"run_id": "${{ github.run_id }}", "browser": "${{ env.BROWSER }}", "device": "${{ env.DEVICE }}"}}' \ | |
"https://api.github.com/repos/NHSDigital/ravs-test-reports/actions/workflows/publish_report.yml/dispatches" |