|
| 1 | +name: Accessibility tests |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 2 * * *" |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tests: |
| 9 | + description: 'Tests to run (leave blank to run all tests!)' |
| 10 | + required: false |
| 11 | + default: '' |
| 12 | + device: |
| 13 | + description: 'Device to test' |
| 14 | + required: true |
| 15 | + default: 'Desktop Chrome' |
| 16 | + type: choice |
| 17 | + options: |
| 18 | + - Desktop Chrome |
| 19 | + - Desktop Edge |
| 20 | + - Desktop Firefox |
| 21 | + - Desktop Safari |
| 22 | + - Galaxy S9+ |
| 23 | + - Pixel 7 |
| 24 | + - iPad (gen 7) landscape |
| 25 | + - iPhone 15 |
| 26 | + programmes: |
| 27 | + description: 'Programmes to use (HPV, MENACWY, TD_IPV, FLU)' |
| 28 | + required: true |
| 29 | + default: 'HPV,MENACWY,TD_IPV,FLU' |
| 30 | + environment: |
| 31 | + description: 'Environment to run tests on' |
| 32 | + required: true |
| 33 | + default: 'qa' |
| 34 | + type: choice |
| 35 | + options: |
| 36 | + - qa |
| 37 | + - training |
| 38 | + - sandbox-alpha |
| 39 | + - sandbox-beta |
| 40 | + screenshot_all_steps: |
| 41 | + description: 'Take screenshots for all steps (in addition to failures)' |
| 42 | + required: true |
| 43 | + default: 'false' |
| 44 | + type: choice |
| 45 | + options: |
| 46 | + - true |
| 47 | + - false |
| 48 | + set_feature_flags: |
| 49 | + description: 'Set feature flags in the flipper page before running tests (affects all users of the environment being tested!)' |
| 50 | + required: true |
| 51 | + default: 'false' |
| 52 | + type: choice |
| 53 | + options: |
| 54 | + - true |
| 55 | + - false |
| 56 | + additional_feature_flags: |
| 57 | + description: '(If enabled above) Additional feature flags to set. api, basic_auth, dev_tools will be set by default' |
| 58 | + required: false |
| 59 | + default: '' |
| 60 | + |
| 61 | +jobs: |
| 62 | + test: |
| 63 | + permissions: |
| 64 | + contents: write |
| 65 | + |
| 66 | + name: Functional tests |
| 67 | + runs-on: ubuntu-latest |
| 68 | + |
| 69 | + env: |
| 70 | + TZ: "Europe/London" |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: Set variables |
| 74 | + id: set-variables |
| 75 | + run: | |
| 76 | + declare -A env_map=( |
| 77 | + [qa]="https://qa.mavistesting.com" |
| 78 | + [training]="https://training.manage-vaccinations-in-schools.nhs.uk" |
| 79 | + [sandbox-alpha]="https://sandbox-alpha.mavistesting.com" |
| 80 | + [sandbox-beta]="https://sandbox-beta.mavistesting.com" |
| 81 | + ) |
| 82 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 83 | + echo "tests=" >> $GITHUB_OUTPUT |
| 84 | + echo "device=Desktop Chrome" >> $GITHUB_OUTPUT |
| 85 | + echo "environment=${env_map[qa]}" >> $GITHUB_OUTPUT |
| 86 | + echo "programmes=HPV,MENACWY,TD_IPV,FLU" >> $GITHUB_OUTPUT |
| 87 | + echo "set_feature_flags=false" >> $GITHUB_OUTPUT |
| 88 | + echo "additional_feature_flags=" >> $GITHUB_OUTPUT |
| 89 | + echo "deploy_report=false" >> $GITHUB_OUTPUT |
| 90 | + echo "screenshot_all_steps=false" >> $GITHUB_OUTPUT |
| 91 | + else |
| 92 | + echo "tests=${{ github.event.inputs.tests }}" >> $GITHUB_OUTPUT |
| 93 | + echo "device=${{ github.event.inputs.device }}" >> $GITHUB_OUTPUT |
| 94 | +
|
| 95 | + input_env="${{ github.event.inputs.environment }}" |
| 96 | + url="${env_map[$input_env]:-${env_map[qa]}}" |
| 97 | + echo "environment=$url" >> $GITHUB_OUTPUT |
| 98 | +
|
| 99 | + echo "programmes=${{ github.event.inputs.programmes }}" >> $GITHUB_OUTPUT |
| 100 | + echo "set_feature_flags=${{ github.event.inputs.set_feature_flags }}" >> $GITHUB_OUTPUT |
| 101 | + echo "additional_feature_flags=${{ github.event.inputs.additional_feature_flags }}" >> $GITHUB_OUTPUT |
| 102 | + echo "deploy_report=true" >> $GITHUB_OUTPUT |
| 103 | + echo "screenshot_all_steps=${{ github.event.inputs.screenshot_all_steps }}" >> $GITHUB_OUTPUT |
| 104 | + fi |
| 105 | +
|
| 106 | + - uses: actions/checkout@v5 |
| 107 | + |
| 108 | + - name: Cache Playwright browsers |
| 109 | + uses: actions/cache@v4 |
| 110 | + id: playwright-cache |
| 111 | + with: |
| 112 | + path: /home/runner/.cache/ms-playwright |
| 113 | + key: playwright-${{ runner.os }}-${{ hashFiles('**/pyproject.toml') }} |
| 114 | + |
| 115 | + - name: Run tests |
| 116 | + uses: ./.github/actions/run-functional-tests |
| 117 | + with: |
| 118 | + tests: ${{ steps.set-variables.outputs.tests }} |
| 119 | + accessibility_tests: 'true' |
| 120 | + device: ${{ steps.set-variables.outputs.device }} |
| 121 | + base_url: ${{ steps.set-variables.outputs.environment }} |
| 122 | + programmes_enabled: ${{ steps.set-variables.outputs.programmes }} |
| 123 | + screenshot_all_steps: ${{ steps.set-variables.outputs.screenshot_all_steps }} |
| 124 | + set_feature_flags: ${{ steps.set-variables.outputs.set_feature_flags }} |
| 125 | + additional_feature_flags: ${{ steps.set-variables.outputs.additional_feature_flags }} |
| 126 | + playwright_cache_hit: ${{ steps.playwright-cache.outputs.cache-hit }} |
| 127 | + env: |
| 128 | + BASIC_AUTH_TOKEN: ${{ secrets.HTTP_AUTH_TOKEN_FOR_TESTS }} |
| 129 | + IMMS_BASE_URL: ${{ vars.IMMS_BASE_URL }} |
| 130 | + IMMS_API_KEY: ${{ secrets.IMMS_API_KEY }} |
| 131 | + IMMS_API_KID: ${{ secrets.IMMS_API_KID }} |
| 132 | + IMMS_API_PEM: ${{ secrets.IMMS_API_PEM }} |
| 133 | + |
| 134 | + - name: Process reports |
| 135 | + if: always() && steps.set-variables.outputs.deploy_report == 'true' |
| 136 | + uses: ./.github/actions/deploy-reports |
| 137 | + with: |
| 138 | + device: ${{ steps.set-variables.outputs.device }} |
| 139 | + environment: ${{ github.event.inputs.environment }} |
| 140 | + env: |
| 141 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments