@@ -21,20 +21,30 @@ jobs:
2121 outputs :
2222 playwright-version : ${{ steps.playwright-version.outputs.version }}
2323 steps :
24- - name : Checkout
25- uses : actions/checkout@v4
24+ - uses : actions/checkout@v4
2625
27- - name : Set up Python
28- uses : actions/setup-python@v5
26+ - uses : actions/setup-python@v5
2927 with :
3028 python-version : " 3.11"
3129
32- - name : Install Playwright
33- run : pip install playwright
30+ - name : Install hatch
31+ run : pip install hatch
32+
33+ - name : Cache hatch environment
34+ uses : actions/cache@v4
35+ with :
36+ path : ~/.local/share/hatch
37+ key : hatch-${{ runner.os }}-3.11-${{ hashFiles('pyproject.toml') }}
38+ restore-keys : |
39+ hatch-${{ runner.os }}-3.11-
40+
41+ - name : Create test environment
42+ run : hatch env create test
3443
3544 - name : Get Playwright version
3645 id : playwright-version
37- run : echo "version=$(pip show playwright | grep Version | cut -d' ' -f2)" >> $GITHUB_OUTPUT
46+ run : |
47+ echo "version=$(hatch run test:python -c 'import playwright; print(playwright.__version__)')" >> $GITHUB_OUTPUT
3848
3949 - name : Cache Playwright browsers
4050 uses : actions/cache@v4
@@ -47,11 +57,10 @@ jobs:
4757
4858 - name : Install browsers
4959 if : steps.playwright-cache.outputs.cache-hit != 'true'
50- run : |
51- playwright install chromium firefox
52- playwright install-deps
60+ run : hatch run test:install-browsers
61+
5362 test :
54- name : pf-${{ matrix.pf-version }} (🐍 ${{ matrix.python-version }}, ${{ matrix.browser }})
63+ name : pf-v ${{ matrix.pf-version }} (🐍 ${{ matrix.python-version }}, ${{ matrix.browser }})
5564 runs-on : ubuntu-latest
5665 needs : setup-browsers
5766 timeout-minutes : 30
@@ -60,23 +69,36 @@ jobs:
6069 matrix :
6170 browser : [chromium, firefox]
6271 python-version : ["3.12", "3.13"]
63- pf-version : ["v5", "v6"]
64- # Reduce redundancy: only run coverage for one combination
72+ # Values are the numeric suffix only so they compose directly into
73+ # the hatch script names pf5 / pf6 and the --pf-version=v5 / v6 flag.
74+ pf-version : ["5", "6"]
75+ # Run coverage only for one combination to keep CI lean
6576 include :
6677 - browser : chromium
6778 python-version : " 3.13"
68- pf-version : " v6 "
79+ pf-version : " 6 "
6980 run-coverage : true
7081 exclude : []
7182 steps :
7283 - uses : actions/checkout@v4
7384
7485 - uses : actions/setup-python@v5
7586 with :
76- python-version : ${{ matrix.python-version }}
87+ python-version : ${{ matrix.python-version }}
88+
89+ - name : Install hatch
90+ run : pip install hatch
91+
92+ - name : Cache hatch environment
93+ uses : actions/cache@v4
94+ with :
95+ path : ~/.local/share/hatch
96+ key : hatch-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
97+ restore-keys : |
98+ hatch-${{ runner.os }}-${{ matrix.python-version }}-
7799
78- - name : Install Playwright
79- run : pip install playwright
100+ - name : Create test environment
101+ run : hatch env create test
80102
81103 - name : Restore Playwright browsers cache
82104 uses : actions/cache/restore@v4
@@ -85,22 +107,22 @@ jobs:
85107 key : playwright-${{ runner.os }}-${{ needs.setup-browsers.outputs.playwright-version }}-browsers
86108 fail-on-cache-miss : true
87109
88- - name : Install dependencies
89- run : |
90- pip install -U pip wheel
91- pip install -e .[dev]
92-
93110 - name : Test with pytest (with coverage)
94111 if : matrix.run-coverage == true
95112 timeout-minutes : 25
96113 run : |
97- pytest -v -n 2 --headless --browser=${{ matrix.browser }} --pf-version=${{ matrix.pf-version }} --cov=./src --cov-report=xml --reruns 2 --reruns-delay 5
114+ hatch run test:pf${{ matrix.pf-version }} \
115+ -n 2 --browser=${{ matrix.browser }} \
116+ --reruns 2 --reruns-delay 5 \
117+ --cov=./src --cov-report=xml
98118
99119 - name : Test with pytest (without coverage)
100120 if : matrix.run-coverage != true
101121 timeout-minutes : 25
102122 run : |
103- pytest -v -n 2 --headless --browser=${{ matrix.browser }} --pf-version=${{ matrix.pf-version }} --reruns 2 --reruns-delay 5
123+ hatch run test:pf${{ matrix.pf-version }} \
124+ -n 2 --browser=${{ matrix.browser }} \
125+ --reruns 2 --reruns-delay 5
104126
105127 - name : Upload coverage to Codecov
106128 if : matrix.run-coverage == true
0 commit comments