Skip to content

Commit 42f2fc6

Browse files
committed
ci: parallelise pytest execution and optimise regression workflows
1 parent 954cd3b commit 42f2fc6

5 files changed

Lines changed: 48 additions & 39 deletions

File tree

.github/workflows/daily.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ concurrency:
1111

1212
jobs:
1313
unit:
14-
name: Unit (${{ matrix.os }}, ${{ matrix.python-version }})
14+
name: Unit (${{ matrix.os }}, py${{ matrix.python-version }})
1515
runs-on: ${{ matrix.os }}
1616
timeout-minutes: 30
17+
1718
strategy:
1819
fail-fast: false
1920
matrix:
2021
os: [ubuntu-24.04, macos-15, windows-2025]
2122
python-version: ["3.12", "3.13", "3.14"]
23+
2224
steps:
2325
- name: Checkout
2426
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
@@ -29,10 +31,10 @@ jobs:
2931
python-version: ${{ matrix.python-version }}
3032
cache: pip
3133

32-
- name: Install (testing)
34+
- name: Install testing dependencies
3335
run: |
3436
python -m pip install --upgrade pip
3537
python -m pip install -e .[testing]
3638
37-
- name: Pytest (unit) • ${{ matrix.os }} • py${{ matrix.python-version }}
39+
- name: Run unit tests
3840
run: python -m pytest tests/unit

.github/workflows/pr.yaml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
matrix:
1818
os: [ubuntu-24.04, macos-15, windows-2025]
1919
python-version: ["3.12", "3.13", "3.14"]
20+
2021
steps:
2122
- name: Checkout
2223
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
@@ -36,16 +37,17 @@ jobs:
3637
run: python -m pytest tests/unit
3738

3839
regression-quick:
39-
name: Regression (quick)
40+
name: Regression (fast)
4041
needs: unit
4142
runs-on: ubuntu-24.04
4243
timeout-minutes: 35
44+
4345
steps:
4446
- name: Checkout
45-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
47+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
4648

4749
- name: Set up Python 3.14
48-
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
50+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
4951
with:
5052
python-version: "3.14"
5153
cache: pip
@@ -54,20 +56,21 @@ jobs:
5456
uses: actions/cache@v4
5557
with:
5658
path: .testdata
57-
key: codeentropy-testdata-v1-${{ runner.os }}-py3.14
59+
key: codeentropy-testdata-${{ runner.os }}-py314
5860

59-
- name: Install (testing)
61+
- name: Install testing dependencies
6062
run: |
6163
python -m pip install --upgrade pip
6264
python -m pip install -e .[testing]
6365
64-
- name: Pytest (regression quick)
66+
- name: Run fast regression tests (parallel)
6567
run: |
6668
python -m pytest tests/regression \
6769
-m "not slow" \
6870
-n auto \
71+
--dist=loadscope \
6972
-vv \
70-
--durations=0
73+
--durations=20
7174
7275
- name: Upload artifacts (failure)
7376
if: failure()
@@ -76,11 +79,7 @@ jobs:
7679
name: quick-regression-failure
7780
path: |
7881
.testdata/**
79-
tests/regression/**/.pytest_cache/**
80-
/tmp/pytest-of-*/pytest-*/**/config.yaml
81-
/tmp/pytest-of-*/pytest-*/**/codeentropy_stdout.txt
82-
/tmp/pytest-of-*/pytest-*/**/codeentropy_stderr.txt
83-
/tmp/pytest-of-*/pytest-*/**/codeentropy_output.json
82+
/tmp/pytest-of-*/pytest-*/**
8483
8584
docs:
8685
name: Docs
@@ -98,7 +97,7 @@ jobs:
9897
python-version: "3.14"
9998
cache: pip
10099

101-
- name: Install
100+
- name: Install docs dependencies
102101
run: |
103102
python -m pip install --upgrade pip
104103
python -m pip install -e .[docs]
@@ -119,6 +118,7 @@ jobs:
119118
name: Pre-commit
120119
runs-on: ubuntu-24.04
121120
timeout-minutes: 15
121+
122122
steps:
123123
- name: Checkout
124124
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
@@ -129,13 +129,12 @@ jobs:
129129
python-version: "3.14"
130130
cache: pip
131131

132-
- name: Install (pre-commit)
132+
- name: Install pre-commit dependencies
133133
run: |
134134
python -m pip install --upgrade pip
135135
python -m pip install -e .[pre-commit]
136136
137137
- name: Run pre-commit
138-
shell: bash
139138
run: |
140139
pre-commit install
141140
pre-commit run --all-files || {
@@ -149,8 +148,9 @@ jobs:
149148
needs: unit
150149
runs-on: ubuntu-24.04
151150
timeout-minutes: 30
151+
152152
steps:
153-
- name: Checkout repo
153+
- name: Checkout
154154
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
155155

156156
- name: Set up Python 3.14
@@ -159,20 +159,20 @@ jobs:
159159
python-version: "3.14"
160160
cache: pip
161161

162-
- name: Install (testing)
162+
- name: Install testing dependencies
163163
run: |
164164
python -m pip install --upgrade pip
165165
python -m pip install -e .[testing]
166166
167-
- name: Run unit test suite with coverage
167+
- name: Run coverage
168168
run: |
169169
pytest tests/unit \
170170
--cov CodeEntropy \
171171
--cov-report term-missing \
172172
--cov-report xml \
173173
-q
174174
175-
- name: Upload to Coveralls
175+
- name: Upload coverage to Coveralls
176176
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e
177177
with:
178178
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/weekly-regression.yaml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Weekly Regression Tests
22

33
on:
44
schedule:
5-
- cron: '0 8 * * 1' # Weekly Monday checks
5+
- cron: '0 8 * * 1'
66
workflow_dispatch:
77

88
concurrency:
@@ -13,12 +13,13 @@ jobs:
1313
discover:
1414
name: Discover regression systems
1515
runs-on: ubuntu-24.04
16+
1617
outputs:
1718
systems: ${{ steps.set.outputs.systems }}
1819

1920
steps:
20-
- name: Checkout repo
21-
uses: actions/checkout@v4
21+
- name: Checkout
22+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
2223

2324
- name: Generate system matrix
2425
id: set
@@ -30,46 +31,47 @@ jobs:
3031
name: Regression (${{ matrix.system }})
3132
needs: discover
3233
runs-on: ubuntu-24.04
34+
timeout-minutes: 360
3335

3436
strategy:
3537
fail-fast: false
3638
matrix:
3739
system: ${{ fromJson(needs.discover.outputs.systems) }}
3840

3941
steps:
40-
- name: Checkout repo
41-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
42+
- name: Checkout
43+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
4244

4345
- name: Set up Python 3.14
44-
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
46+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
4547
with:
4648
python-version: "3.14"
4749
cache: pip
4850

49-
- name: Cache regression test data downloads
51+
- name: Cache regression test data
5052
uses: actions/cache@v4
5153
with:
5254
path: .testdata
5355
key: codeentropy-testdata-${{ runner.os }}-py314
5456

55-
- name: Install CodeEntropy and dependencies
57+
- name: Install testing dependencies
5658
run: |
5759
pip install --upgrade pip
5860
pip install -e .[testing]
5961
60-
- name: Run regression tests for system
62+
- name: Run regression tests (slow)
6163
run: |
62-
pytest tests/regression -k "${{ matrix.system }}" --run-slow -vv
64+
pytest tests/regression \
65+
-k "${{ matrix.system }}" \
66+
--run-slow \
67+
-vv \
68+
--durations=20
6369
64-
- name: Upload regression artifacts on failure
70+
- name: Upload regression artifacts (failure)
6571
if: failure()
6672
uses: actions/upload-artifact@v4
6773
with:
6874
name: regression-${{ matrix.system }}-artifacts
6975
path: |
7076
.testdata/**
71-
tests/regression/**/.pytest_cache/**
72-
/tmp/pytest-of-*/pytest-*/**/config.yaml
73-
/tmp/pytest-of-*/pytest-*/**/codeentropy_stdout.txt
74-
/tmp/pytest-of-*/pytest-*/**/codeentropy_stderr.txt
75-
/tmp/pytest-of-*/pytest-*/**/codeentropy_output.json
77+
/tmp/pytest-of-*/pytest-*/**

conda-recipe/meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ requirements:
3838
- dask >=2026.1.2,<2026.2.0
3939
- distributed >=2026.1.2,<2026.2.0
4040
- dask-jobqueue >=0.9,<0.10
41+
- pytest-xdist >=3.8, <3.9
4142

4243
test:
4344
imports:

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ Documentation = "https://codeentropy.readthedocs.io"
6161
testing = [
6262
"pytest>=9.0,<10.0",
6363
"pytest-cov>=7.0,<8.0",
64-
"pytest-sugar>=1.1,<2.0"
64+
"pytest-sugar>=1.1,<2.0",
65+
"pytest-xdist"
6566
]
6667
pre-commit = [
6768
"pre-commit>=4.5,<5.0",
@@ -83,6 +84,9 @@ docs = [
8384
[project.scripts]
8485
CodeEntropy = "CodeEntropy.cli:main"
8586

87+
[tool.pytest.ini_options]
88+
addopts = "-n auto -m 'not slow' -vv"
89+
8690
[tool.ruff]
8791
line-length = 88
8892
target-version = "py311"

0 commit comments

Comments
 (0)