Skip to content

Commit 2241c66

Browse files
authored
Merge pull request #289 from NHSDigital/parallel-ci
Run tests in parallel in CI
2 parents abfd66e + 9b8162f commit 2241c66

File tree

8 files changed

+56
-116
lines changed

8 files changed

+56
-116
lines changed

.github/workflows/functional.yaml

Lines changed: 31 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -5,127 +5,53 @@ on:
55
- cron: "0 3 * * *"
66
workflow_dispatch:
77

8-
permissions:
9-
contents: write
10-
118
jobs:
129
test:
10+
name: Test
11+
12+
strategy:
13+
matrix:
14+
device:
15+
- Desktop Chrome
16+
- Desktop Edge
17+
- Desktop Firefox
18+
- Desktop Safari
19+
- Galaxy S9+
20+
- Pixel 7
21+
- iPad (gen 7) landscape
22+
- iPhone 14
23+
- iPhone 15
24+
25+
permissions: {}
26+
1327
runs-on: ubuntu-latest
28+
1429
env:
1530
TZ: "Europe/London"
16-
strategy:
17-
matrix:
18-
location: ["UK"]
1931

2032
steps:
2133
- uses: actions/checkout@v4
2234
- uses: actions/setup-python@v5
2335
with:
2436
python-version-file: .tool-versions
37+
2538
- name: Install dependencies
2639
run: |
27-
python -m pip install --upgrade pip
28-
pip install pytest
29-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30-
playwright install
31-
playwright install-deps
32-
- name: Test on Chromium
33-
env:
34-
BASE_URL: ${{ vars.BASE_URL }}
35-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
36-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
37-
run: |
38-
echo "::group::Chromium"
39-
pytest --browser chromium
40-
echo "::endgroup::"
41-
- name: Test on Chrome
42-
if: always()
43-
env:
44-
BASE_URL: ${{ vars.BASE_URL }}
45-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
46-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
47-
run: |
48-
echo "::group::Chrome"
49-
pytest --browser chromium --browser-channel chrome
50-
echo "::endgroup::"
51-
- name: Test on Firefox
52-
env:
53-
BASE_URL: ${{ vars.BASE_URL }}
54-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
55-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
56-
run: |
57-
echo "::group::Firefox"
58-
pytest --browser firefox
59-
echo "::endgroup::"
60-
- name: Test on Edge
61-
if: always()
62-
env:
63-
BASE_URL: ${{ vars.BASE_URL }}
64-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
65-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
66-
run: |
67-
echo "::group::Edge"
68-
pytest --browser chromium --browser-channel msedge
69-
echo "::endgroup::"
70-
- name: Test on iPhone 14
71-
if: always()
72-
env:
73-
BASE_URL: ${{ vars.BASE_URL }}
74-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
75-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
76-
run: |
77-
echo "::group::iPhone 14"
78-
pytest -m mobile --browser webkit --device "iPhone 14"
79-
echo "::endgroup::"
80-
- name: Test on iPhone 15
81-
if: always()
82-
env:
83-
BASE_URL: ${{ vars.BASE_URL }}
84-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
85-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
86-
run: |
87-
echo "::group::iPhone 15"
88-
pytest -m mobile --browser webkit --device "iPhone 15"
89-
echo "::endgroup::"
90-
- name: Test on iPad Gen 7
91-
if: always()
92-
env:
93-
BASE_URL: ${{ vars.BASE_URL }}
94-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
95-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
96-
run: |
97-
echo "::group::iPad Gen 7"
98-
pytest -m mobile --browser webkit --device "iPad (gen 7) landscape"
99-
echo "::endgroup::"
100-
- name: Test on Samsung Galaxy S9+
101-
if: always()
102-
env:
103-
BASE_URL: ${{ vars.BASE_URL }}
104-
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
105-
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
106-
run: |
107-
echo "::group::Samsung Galaxy S9+"
108-
pytest -m mobile --browser chromium --device "Galaxy S9+"
109-
echo "::endgroup::"
110-
- name: Test on Google Pixel 7
111-
if: always()
40+
pip install -U pip
41+
pip install -r requirements.txt
42+
43+
- name: Install Playwright
44+
run: playwright install --with-deps
45+
46+
- name: Run tests
47+
run: pytest --device "${{ matrix.device }}"
11248
env:
11349
BASE_URL: ${{ vars.BASE_URL }}
11450
BASIC_AUTH_PASSWORD: ${{ secrets.BASIC_AUTH_PASSWORD }}
11551
BASIC_AUTH_USERNAME: ${{ secrets.BASIC_AUTH_USERNAME }}
116-
run: |
117-
echo "::group::Google Pixel 7"
118-
pytest -m mobile --browser chromium --device "Pixel 7"
119-
echo "::endgroup::"
120-
- name: Upload report
121-
if: always()
122-
uses: actions/upload-artifact@v4
123-
with:
124-
name: allure-reports
125-
path: reports
126-
- name: Upload screenshots
127-
if: always()
52+
53+
- name: Upload Allure results
12854
uses: actions/upload-artifact@v4
12955
with:
130-
name: screenshots
131-
path: screenshots
56+
name: ${{ matrix.device }}
57+
path: allure-results

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,31 @@ $ pytest
6363

6464
#### Browsers and devices
6565

66-
By default, the tests will run using `Chromium` with no particular device,
67-
however it's possible to run the tests in different browsers and devices.
68-
Some examples are listed below.
66+
By default, the tests will run using the `Desktop Chrome` device, however it's
67+
possible to run the tests in devices. Some examples are listed below.
6968
7069
##### iPhone 15
7170
7271
```shell
73-
$ pytest --browser webkit --device "iPhone 15"
72+
$ pytest --device "iPhone 15"
7473
```
7574
7675
##### Firefox
7776
7877
```shell
79-
$ pytest --browser firefox
78+
$ pytest --device "Desktop Firefox"
8079
```
8180
8281
##### Google Pixel 7
8382
8483
```shell
85-
$ pytest --browser chromium --device "Pixel 7"
84+
$ pytest --device "Pixel 7"
8685
```
8786
8887
##### Microsoft Edge
8988
9089
```shell
91-
$ pytest --browser chromium --browser-channel msedge
90+
$ pytest --device "Desktop Edge"
9291
```
9392
9493
#### Headless mode

mavis/test/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
from .hooks import pytest_runtest_logreport, pytest_sessionfinish, pytest_sessionstart
1+
from .hooks import (
2+
pytest_runtest_logreport,
3+
pytest_sessionfinish,
4+
pytest_sessionstart,
5+
)
26
from .fixtures import (
37
admin,
48
archive_consent_response_page,
59
base_url,
610
basic_auth,
711
browser_context_args,
12+
browser_type,
813
children_page,
914
clinics,
1015
consent_page,
@@ -46,6 +51,7 @@
4651
"base_url",
4752
"basic_auth",
4853
"browser_context_args",
54+
"browser_type",
4955
"children_page",
5056
"clinics",
5157
"consent_page",

mavis/test/fixtures/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
base_url,
3636
basic_auth,
3737
browser_context_args,
38+
browser_type,
3839
playwright_operations,
3940
screenshots_path,
4041
)
@@ -45,6 +46,7 @@
4546
"base_url",
4647
"basic_auth",
4748
"browser_context_args",
49+
"browser_type",
4850
"children_page",
4951
"clinics",
5052
"consent_page",

mavis/test/fixtures/playwright.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
from typing import Optional
55

6+
from playwright.sync_api import BrowserType, Playwright
67
import pytest
78

89
from ..playwright_ops import PlaywrightOperations
@@ -34,6 +35,13 @@ def screenshots_path(pytestconfig) -> Optional[Path]:
3435
return path
3536

3637

38+
@pytest.fixture(scope="session")
39+
def browser_type(playwright: Playwright, device: Optional[str]) -> BrowserType:
40+
device = device or "Desktop Chrome"
41+
browser_name = playwright.devices[device]["default_browser_type"]
42+
return getattr(playwright, browser_name)
43+
44+
3745
@pytest.fixture(scope="session")
3846
def browser_context_args(browser_context_args, basic_auth):
3947
return {**browser_context_args, "http_credentials": basic_auth}

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ markers =
1414
consentworkflow
1515
e2e
1616
log_in
17-
mobile
1817
order
1918
rav
2019
regression

tests/test_online_consent_doubles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from mavis.test.mavis_constants import Programme
44

5-
pytestmark = [pytest.mark.consent, pytest.mark.mobile]
5+
pytestmark = pytest.mark.consent
66

77

88
@pytest.fixture

tests/test_online_consent_hpv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from mavis.test.mavis_constants import Programme
44

5-
pytestmark = [pytest.mark.consent, pytest.mark.mobile]
5+
pytestmark = pytest.mark.consent
66

77

88
@pytest.fixture

0 commit comments

Comments
 (0)