Skip to content

Commit 8aaf051

Browse files
authored
Parallelize tests (#221)
* Add pytest-xdist for parallel testing * Reduce number of samples from the hypothesis space Mainly because the test runs for long. I will have to look into what an appropriate number is, but I suspect 500 will still find most of the failures that 5000 samples would. * Split up job matrix and parallelize each invocation * Change types of parametrization and avoid starting php if possible * Give a readable name to each job * [no ci] use names that are clearer
1 parent 73e998e commit 8aaf051

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

.github/workflows/tests.yml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ permissions:
1212
contents: write
1313

1414
jobs:
15-
compare-php:
15+
tests:
16+
name: "${{ matrix.php_api == true && 'Migration' || 'Python-only' }} ${{ matrix.mutations == true && 'with mutations' || 'read-only' }}"
17+
strategy:
18+
matrix:
19+
php_api: [true, false]
20+
mutations: [true, false]
1621
runs-on: ubuntu-latest
1722
steps:
1823
- uses: actions/checkout@v6
@@ -21,23 +26,20 @@ jobs:
2126
python-version: 3.x
2227

2328
# https://github.com/docker/compose/issues/10596
24-
- run: docker compose --profile "python" --profile "php" up --detach --wait --remove-orphans || exit $(docker compose ps -q | xargs docker inspect -f '{{.State.ExitCode}}' | grep -v '^0' | wc -l)
25-
- run: docker exec openml-python-rest-api coverage run -m pytest -v -m "php_api"
26-
- run: docker exec openml-python-rest-api coverage xml
27-
- name: Upload results to Codecov
28-
uses: codecov/codecov-action@v4
29-
with:
30-
token: ${{ secrets.CODECOV_TOKEN }}
31-
python:
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v6
35-
- uses: actions/setup-python@v6
36-
with:
37-
python-version: 3.x
38-
- run: docker compose --profile "python" up --detach --wait --remove-orphans || exit $(docker compose ps -q | xargs docker inspect -f '{{.State.ExitCode}}' | grep -v '^0' | wc -l)
39-
- run: docker exec openml-python-rest-api coverage run -m pytest -v -m "not php_api"
40-
- run: docker exec openml-python-rest-api coverage xml
29+
- name: Start services
30+
run: |
31+
profiles="--profile python"
32+
if [ "${{ matrix.php_api }}" = "true" ]; then
33+
profiles="$profiles --profile php"
34+
fi
35+
docker compose $profiles up --detach --wait --remove-orphans || exit $(docker compose ps -q | xargs docker inspect -f '{{.State.ExitCode}}' | grep -v '^0' | wc -l)
36+
37+
- name: Run tests
38+
run: |
39+
marker="${{ matrix.php_api == true && 'php_api' || 'not php_api' }} and ${{ matrix.mutations == true && 'mut' || 'not mut' }}"
40+
docker exec openml-python-rest-api coverage run -m pytest -n auto -v -m "$marker"
41+
- name: Produce coverage report
42+
run: docker exec openml-python-rest-api coverage xml
4143
- name: Upload results to Codecov
4244
uses: codecov/codecov-action@v4
4345
with:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dev = [
3131
"httpx",
3232
"hypothesis",
3333
"deepdiff",
34+
"pytest-xdist",
3435
]
3536
docs = [
3637
"mkdocs-material",

tests/routers/openml/datasets_list_datasets_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def test_list_data_quality(quality: str, range_: str, count: int, py_api: TestCl
225225

226226
@pytest.mark.slow
227227
@hypothesis.settings( # type: ignore[untyped-decorator] # 108
228-
max_examples=5000,
228+
max_examples=500, # This number needs to be better motivated
229229
suppress_health_check=[hypothesis.HealthCheck.function_scoped_fixture],
230230
deadline=None,
231231
)

0 commit comments

Comments
 (0)