End-to-End tests #91
This file contains hidden or 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: End-to-End tests | |
| on: | |
| workflow_call: | |
| inputs: | |
| tests: | |
| description: 'Tests to run (leave blank to run all tests!)' | |
| required: false | |
| default: '' | |
| type: string | |
| cross_service_tests: | |
| description: 'Include imms api, pds api and reporting tests' | |
| required: false | |
| default: false | |
| type: boolean | |
| github_ref: | |
| description: 'Github reference to get tests from' | |
| required: false | |
| default: 'main' | |
| type: string | |
| device: | |
| description: 'Device to test' | |
| required: false | |
| default: 'Desktop Chrome' | |
| type: string | |
| endpoint: | |
| description: 'Environment to run tests against' | |
| required: false | |
| default: 'https://qa.mavistesting.com' | |
| type: string | |
| screenshot_all_steps: | |
| description: 'Take screenshots for all steps (in addition to failures)' | |
| required: false | |
| default: false | |
| type: boolean | |
| enable_reruns: | |
| description: 'Enable test reruns on failure (up to 3 attempts)' | |
| required: false | |
| default: true | |
| type: boolean | |
| test_workers: | |
| description: 'Number of parallel test workers to use' | |
| required: false | |
| default: '4' | |
| type: string | |
| set_feature_flags: | |
| description: >- | |
| Set feature flags in the flipper page before running tests (affects all | |
| users of the environment being tested!) | |
| required: false | |
| default: false | |
| type: boolean | |
| additional_feature_flags: | |
| description: >- | |
| (If enabled above) Additional feature flags to set. api, basic_auth, | |
| dev_tools will be set by default | |
| required: false | |
| default: '' | |
| type: string | |
| secrets: | |
| IMMS_API_KEY: | |
| description: API key to use NHS Immunisations API | |
| required: false | |
| IMMS_API_KID: | |
| description: API KID to use NHS Immunisations API | |
| required: false | |
| IMMS_API_PEM: | |
| description: API PEM to use NHS Immunisations API | |
| required: false | |
| HTTP_AUTH_TOKEN_FOR_TESTS: | |
| description: HTTP Basic Auth token for the environment under test | |
| required: false | |
| workflow_dispatch: | |
| inputs: | |
| tests: | |
| description: 'Tests to run (leave blank to run all tests!)' | |
| required: false | |
| default: '' | |
| cross_service_tests: | |
| description: 'Include imms api, pds api and reporting tests' | |
| required: false | |
| default: 'true' | |
| type: choice | |
| options: | |
| - true | |
| - false | |
| device: | |
| description: 'Device to test' | |
| required: true | |
| default: 'Desktop Chrome' | |
| type: choice | |
| options: | |
| - Desktop Chrome | |
| - Desktop Edge | |
| - Desktop Firefox | |
| - Desktop Safari | |
| - Galaxy S9+ | |
| - Pixel 7 | |
| - iPad (gen 7) landscape | |
| - iPhone 15 | |
| environment: | |
| description: 'Environment to run tests on' | |
| required: true | |
| default: 'qa' | |
| type: choice | |
| options: | |
| - qa | |
| - training | |
| - sandbox-alpha | |
| - sandbox-beta | |
| screenshot_all_steps: | |
| description: 'Take screenshots for all steps (in addition to failures)' | |
| required: true | |
| default: 'false' | |
| type: choice | |
| options: | |
| - true | |
| - false | |
| enable_reruns: | |
| description: 'Enable test reruns on failure (up to 3 attempts)' | |
| required: true | |
| default: 'true' | |
| type: choice | |
| options: | |
| - true | |
| - false | |
| test_workers: | |
| description: 'Number of parallel test workers to use' | |
| required: true | |
| default: '4' | |
| type: choice | |
| options: | |
| - '1' | |
| - '2' | |
| - '3' | |
| - '4' | |
| set_feature_flags: | |
| description: >- | |
| Set feature flags in the flipper page before running tests (affects all | |
| users of the environment being tested!) | |
| required: true | |
| default: 'false' | |
| type: choice | |
| options: | |
| - true | |
| - false | |
| additional_feature_flags: | |
| description: >- | |
| (If enabled above) Additional feature flags to set. api, basic_auth, | |
| dev_tools will be set by default | |
| required: false | |
| default: '' | |
| jobs: | |
| test: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| name: End-to-End tests | |
| runs-on: ubuntu-latest | |
| env: | |
| TZ: Europe/London | |
| steps: | |
| - name: Set variables | |
| id: set-variables | |
| run: | | |
| declare -A env_map=( | |
| [qa]="https://qa.mavistesting.com" | |
| [training]="https://training.manage-vaccinations-in-schools.nhs.uk" | |
| [sandbox-alpha]="https://sandbox-alpha.mavistesting.com" | |
| [sandbox-beta]="https://sandbox-beta.mavistesting.com" | |
| ) | |
| if [ "${{ github.event_name }}" = "push" ]; then | |
| { | |
| echo "tests=" | |
| echo "cross_service_tests=true" | |
| echo "device=Desktop Chrome" | |
| echo "environment=${env_map[qa]}" | |
| echo "set_feature_flags=false" | |
| echo "additional_feature_flags=" | |
| echo "deploy_report=false" | |
| echo "screenshot_all_steps=false" | |
| echo "enable_reruns=true" | |
| echo "test_workers=4" | |
| } >> "$GITHUB_OUTPUT" | |
| else | |
| { | |
| echo "tests=${{ inputs.tests }}" | |
| echo "cross_service_tests=${{ inputs.cross_service_tests }}" | |
| echo "device=${{ inputs.device }}" | |
| input_env="${{ inputs.environment }}" | |
| if [ -n "$input_env" ]; then | |
| url="${env_map[$input_env]:-${env_map[qa]}}" | |
| echo "environment=$url" | |
| else | |
| echo "environment=${{ inputs.endpoint }}" | |
| fi | |
| echo "set_feature_flags=${{ inputs.set_feature_flags }}" | |
| echo "additional_feature_flags=${{ inputs.additional_feature_flags }}" | |
| echo "deploy_report=true" | |
| echo "screenshot_all_steps=${{ inputs.screenshot_all_steps }}" | |
| echo "enable_reruns=${{ inputs.enable_reruns }}" | |
| echo "test_workers=${{ inputs.test_workers }}" | |
| } >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| repository: NHSDigital/manage-vaccinations-in-schools-testing | |
| ref: ${{ inputs.github_ref || github.head_ref }} | |
| - name: Deployment health check | |
| uses: ./.github/actions/deployment-health-check | |
| with: | |
| environment_url: ${{ steps.set-variables.outputs.environment }} | |
| - name: Cache Playwright browsers | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| id: playwright-cache | |
| with: | |
| path: /home/runner/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }} | |
| - name: Run tests | |
| uses: ./.github/actions/run-end-to-end-tests | |
| with: | |
| tests: ${{ steps.set-variables.outputs.tests }} | |
| imms_api_tests: ${{ steps.set-variables.outputs.cross_service_tests }} | |
| pds_api_tests: ${{ steps.set-variables.outputs.cross_service_tests }} | |
| reporting_tests: ${{ steps.set-variables.outputs.cross_service_tests }} | |
| github_ref: ${{ inputs.github_ref || github.head_ref }} | |
| device: ${{ steps.set-variables.outputs.device }} | |
| base_url: ${{ steps.set-variables.outputs.environment }} | |
| screenshot_all_steps: ${{ steps.set-variables.outputs.screenshot_all_steps }} | |
| enable_reruns: ${{ steps.set-variables.outputs.enable_reruns }} | |
| test_workers: ${{ steps.set-variables.outputs.test_workers }} | |
| set_feature_flags: ${{ steps.set-variables.outputs.set_feature_flags }} | |
| additional_feature_flags: |- | |
| ${{ steps.set-variables.outputs.additional_feature_flags }} | |
| playwright_cache_hit: ${{ steps.playwright-cache.outputs.cache-hit }} | |
| env: | |
| BASIC_AUTH_TOKEN: ${{ secrets.HTTP_AUTH_TOKEN_FOR_TESTS }} | |
| IMMS_BASE_URL: ${{ vars.IMMS_BASE_URL }} | |
| IMMS_API_KEY: ${{ secrets.IMMS_API_KEY }} | |
| IMMS_API_KID: ${{ secrets.IMMS_API_KID }} | |
| IMMS_API_PEM: ${{ secrets.IMMS_API_PEM }} | |
| - name: Configure AWS credentials | |
| if: always() && steps.set-variables.outputs.deploy_report == 'true' | |
| uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0 | |
| with: | |
| aws-region: eu-west-2 | |
| role-to-assume: arn:aws:iam::393416225559:role/GitHubAssuranceTestRole | |
| - name: Process reports | |
| if: always() && steps.set-variables.outputs.deploy_report == 'true' | |
| continue-on-error: true | |
| uses: ./.github/actions/deploy-reports | |
| with: | |
| device: ${{ steps.set-variables.outputs.device }} | |
| environment: ${{ github.event.inputs.environment }} |