Skip to content

Commit a6d5af7

Browse files
committed
Update PyTest workflow and configuration
- Change runner to Ubuntu 22.04 - Update Python setup action to a specific version - Install dependencies from requirements.txt instead of hardcoding - Enhance test recording and execution with Launchable CLI - Remove obsolete Launchable configuration file - Add requirements.txt for dependency management - Introduce conftest.py for pytest item modification
1 parent 8067c57 commit a6d5af7

5 files changed

Lines changed: 36 additions & 27 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,34 @@ env:
1616

1717
jobs:
1818
tests:
19-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-22.04
2020
defaults:
2121
run:
2222
working-directory: pytest
2323
steps:
2424
- uses: actions/checkout@v2
25-
- uses: actions/setup-python@v2
2625
- name: Set up Python 3.7
27-
uses: actions/setup-python@v2
26+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
2827
with:
2928
python-version: 3.7
3029
- name: Install dependencies
3130
run: |
3231
python -m pip install --upgrade pip
33-
pip install pytest==4.2.0 attrs==19.1.0 pytest-launchable
32+
pip install -r requirements.txt
3433
- run: launchable verify
3534
- name: Run Pytest
36-
run: pytest --launchable .
35+
run: |
36+
launchable record build --name ${GITHUB_RUN_ID}
37+
launchable record session --build ${GITHUB_RUN_ID} > session.txt
38+
39+
pytest --collect-only -q > test_list.txt
40+
cat test_list.txt | launchable subset --session $(cat session.txt) --target 100% pytest > launchable-subset.txt
41+
42+
function record() {
43+
# Record test results
44+
launchable record tests --session $(cat session.txt) pytest --json test-results/results.json
45+
}
46+
trap record EXIT
47+
48+
pytest --report-log=test-results/results.json $(cat launchable-subset.txt)
49+

pytest/.launchable.d/config.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

pytest/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pytest
2+
launchable
3+
pytest-reportlog
4+
pytest-dependency
5+
pytest-order

pytest/tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def pytest_collection_modifyitems(session, config, items):
2+
for item in items:
3+
for marker in item.iter_markers():
4+
item.user_properties.append(("name", marker.name))
5+
item.user_properties.append(("args", marker.args))
6+
item.user_properties.append(("kwargs", marker.kwargs))

pytest/tests/funcs3_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
import pytest
2+
3+
4+
@pytest.mark.order(1)
5+
@pytest.mark.dependency(name="a")
16
def test_func4():
27
assert 1 == True
38

9+
@pytest.mark.order(2)
10+
@pytest.mark.dependency(name="b", depends=["a"])
411
def test_func5():
512
assert 1 == False

0 commit comments

Comments
 (0)