Skip to content

Commit 049f592

Browse files
committed
try to parallelize workflow
1 parent 767a480 commit 049f592

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: prototype tests
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
device:
7+
description: 'Device to test (exact name)'
8+
required: false
9+
default: 'Desktop Chrome'
10+
programmes:
11+
description: 'Programmes to use (HPV, MENACWY, TD_IPV, FLU)'
12+
required: false
13+
default: 'HPV,MENACWY,TD_IPV,FLU'
14+
environment:
15+
description: 'Environment to run tests on (qa, test, training)'
16+
required: false
17+
default: 'qa'
18+
set_feature_flags:
19+
description: 'Enable feature flags to be changed in the flipper page (true/false)'
20+
required: false
21+
default: 'false'
22+
additional_feature_flags:
23+
description: '(If enabled above) Additional feature flags to set. api, basic_auth, dev_tools will be set by default'
24+
required: false
25+
default: ''
26+
pull_request:
27+
28+
jobs:
29+
test:
30+
name: prototype tests
31+
runs-on: ubuntu-latest
32+
strategy:
33+
matrix:
34+
partition: [0, 1, 2, 3]
35+
fail-fast: false
36+
37+
permissions:
38+
contents: write
39+
40+
env:
41+
TZ: "Europe/London"
42+
43+
steps:
44+
- name: Install uv
45+
uses: astral-sh/setup-uv@v6
46+
47+
- name: Install Playwright
48+
run: uv run playwright install --with-deps
49+
shell: bash
50+
51+
- name: Install Node.js
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20'
55+
56+
- name: Set variables
57+
id: set-variables
58+
run: |
59+
declare -A env_map=(
60+
[qa]="https://qa.mavistesting.com"
61+
[test]="https://test.mavistesting.com"
62+
[training]="https://training.manage-vaccinations-in-schools.nhs.uk"
63+
)
64+
if [ "${{ github.event_name }}" = "pull_request" ]; then
65+
echo "device=Desktop Chrome" >> $GITHUB_OUTPUT
66+
echo "environment=${env_map[qa]}" >> $GITHUB_OUTPUT
67+
echo "programmes=HPV,MENACWY,TD_IPV,FLU" >> $GITHUB_OUTPUT
68+
echo "set_feature_flags=false" >> $GITHUB_OUTPUT
69+
echo "additional_feature_flags=" >> $GITHUB_OUTPUT
70+
echo "deploy_report=false" >> $GITHUB_OUTPUT
71+
else
72+
echo "device=${{ github.event.inputs.device }}" >> $GITHUB_OUTPUT
73+
74+
input_env="${{ github.event.inputs.environment }}"
75+
url="${env_map[$input_env]:-${env_map[qa]}}"
76+
echo "environment=$url" >> $GITHUB_OUTPUT
77+
78+
echo "programmes=${{ github.event.inputs.programmes }}" >> $GITHUB_OUTPUT
79+
echo "set_feature_flags=${{ github.event.inputs.set_feature_flags }}" >> $GITHUB_OUTPUT
80+
echo "additional_feature_flags=${{ github.event.inputs.additional_feature_flags }}" >> $GITHUB_OUTPUT
81+
echo "deploy_report=true" >> $GITHUB_OUTPUT
82+
fi
83+
84+
- uses: actions/checkout@v4
85+
86+
- name: Run tests
87+
run: |
88+
pip install pytest-xdist pytest-split
89+
pytest tests/ \
90+
--splits 4 --group ${{ matrix.partition }} \ # Split into groups
91+
-n 4 \ # Parallelize WITHIN this group
92+
--dist=loadscope # Minimize conflicts
93+
with:
94+
device: ${{ steps.set-variables.outputs.device }}
95+
base_url: ${{ steps.set-variables.outputs.environment }}
96+
programmes_enabled: ${{ steps.set-variables.outputs.programmes }}
97+
set_feature_flags: ${{ steps.set-variables.outputs.set_feature_flags }}
98+
additional_feature_flags: ${{ steps.set-variables.outputs.additional_feature_flags }}
99+
env:
100+
BASIC_AUTH_TOKEN: ${{ secrets.HTTP_AUTH_TOKEN_FOR_TESTS }}
101+
IMMS_BASE_URL: ${{ vars.IMMS_BASE_URL }}
102+
IMMS_API_KEY: ${{ secrets.IMMS_API_KEY }}
103+
IMMS_API_KID: ${{ secrets.IMMS_API_KID }}
104+
IMMS_API_PEM: ${{ secrets.IMMS_API_PEM }}
105+
106+
# - name: Process reports
107+
# if: always() && steps.set-variables.outputs.deploy_report == 'true'
108+
# uses: ./.github/actions/deploy-reports
109+
# with:
110+
# device: ${{ steps.set-variables.outputs.device }}
111+
# env:
112+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)