Skip to content

Commit 5739a3e

Browse files
authored
use pytest-split (#845)
* try pytest-split * minor fix, 3 groups * update contributing guide
1 parent 672c66e commit 5739a3e

File tree

5 files changed

+463
-97
lines changed

5 files changed

+463
-97
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ jobs:
138138
max-parallel: 4
139139
matrix:
140140
python-version: [3.7, 3.8, 3.9]
141+
group: [1, 2, 3]
141142
defaults:
142143
run:
143144
working-directory: webknossos
@@ -156,18 +157,21 @@ jobs:
156157
poetry install --extras all
157158
158159
- name: Check formatting
160+
if: matrix.group == 1
159161
run: ./format.sh check
160162

161163
- name: Lint code
164+
if: matrix.group == 1
162165
run: ./lint.sh
163166

164167
- name: Check typing
168+
if: matrix.group == 1
165169
run: ./typecheck.sh
166170

167171
- name: Python tests
168172
env:
169173
WK_TOKEN: ${{ secrets.WK_TOKEN }}
170-
run: ./test.sh
174+
run: ./test.sh --splits 5 --group ${{ matrix.group }}
171175

172176
- name: Check if git is dirty
173177
run: |

CONTRIBUTING.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ See below for specifics of the different packages. Let's have a look at the comm
114114

115115
To install the dependencies for all sub-projects, run `make install`.
116116
* **Tooling** we use across the sub-projects to enforce coding styles and tests:
117-
* `format.sh`: black and isort
118-
* `lint.sh`: pylint
119-
* `typecheck.sh`: mypy
120-
* `test.sh`: pytest and custom scripts
117+
* `./format.sh`: black and isort
118+
* `./lint.sh`: pylint
119+
* `./typecheck.sh`: mypy
120+
* `./test.sh`: pytest and custom scripts
121121

122122
Those are also accessible via make commands from the top-level directory, running the respective scripts for each sub-project
123123
, e.g. `make format`, `make lint`, …
@@ -138,9 +138,13 @@ The `webknossos` folder contains examples, which are not part of the package, bu
138138

139139
The tests also contain functionality for the webKnossos client. There a two modes to run the tests:
140140

141-
1. `test.sh --refresh-snapshots`, sending network requests to a webKnossos instance:
142-
This expects a local webKnossos setup with specific test data, which is shipped with webKnossos. If you're starting and running webKnossos manually, please use port 9000 (the default) and run the `tools/postgres/prepareTestDb.sh` script in the webKnossos repository (⚠️ this overwrites your local webKnossos database). Alternatively, a docker-compose setup is started automatically for the tests, see `test.sh` and `tests/docker-compose.yml` for details. The network requests & response are recorded as "cassettes" by [vcr.py](https://vcrpy.readthedocs.io), see next point:
143-
2. `test.sh` replays responses from previous network snapshots using [vcr.py](https://vcrpy.readthedocs.io) via [pytest-recording](https://github.com/kiwicom/pytest-recording). No additional network requests are allowed in this mode.
141+
1. `./test.sh --refresh-snapshots`, sending network requests to a webKnossos instance:
142+
This expects a local webKnossos setup with specific test data, which is shipped with webKnossos. If you're starting and running webKnossos manually, please use port 9000 (the default) and run the `tools/postgres/prepareTestDb.sh` script in the webKnossos repository (⚠️ this overwrites your local webKnossos database). Alternatively, a docker-compose setup is started automatically for the tests, see `./test.sh` and `tests/docker-compose.yml` for details. The network requests & response are recorded as "cassettes" by [vcr.py](https://vcrpy.readthedocs.io), see next point:
143+
2. `./test.sh` replays responses from previous network snapshots using [vcr.py](https://vcrpy.readthedocs.io) via [pytest-recording](https://github.com/kiwicom/pytest-recording). No additional network requests are allowed in this mode.
144+
145+
`./test.sh --store-durations` updates the durations for
146+
[`pytest-split`](https://jerry-git.github.io/pytest-split),
147+
which is used in the CI to split the tests for different runners.
144148

145149
The code under `webknossos/client/_generated` is auto-generated! Please don't adapt anything in the `generated` folder manually, but re-run the code generation.
146150

@@ -154,14 +158,8 @@ To re-generate the code, run
154158

155159
#### `wkcuber` package
156160

157-
Currently the test setup consists of different scripts as well as pytest tests. The following commands are run in CI:
158-
```bash
159-
tar -xzvf testdata/WT1_wkw.tar.gz
160-
poetry run pytest tests
161-
poetry run tests/scripts/all_tests.sh
162-
```
163-
164-
There is also a `test.sh` which is currently outdated, see [issue #580](https://github.com/scalableminds/webknossos-libs/issues/580).
161+
Simply use the default scripts mentioned above, such as
162+
`./format.sh`, `./lint.sh`, `./typecheck.sh`, `./test.sh`.
165163

166164

167165
#### `cluster_tools` package

0 commit comments

Comments
 (0)