Skip to content

Commit 9a5038d

Browse files
authored
Separate benchmarks and coverage from tests (#108)
* Remove benchmarks from regular tests * Change benchmarks targets to benchmark * Add CI for coverage and benchmarks
1 parent 79fc754 commit 9a5038d

File tree

6 files changed

+82
-44
lines changed

6 files changed

+82
-44
lines changed

.github/workflows/testing.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,44 @@ jobs:
3131
pip install tox tox-gh-actions
3232
- name: Test with tox
3333
run: tox
34+
coverage:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v2
38+
- name: Set up Python 3.7
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: 3.7
42+
- name: Install dependencies
43+
run: |
44+
python -m pip install --upgrade pip
45+
pip install tox
46+
- name: Test with tox
47+
run: tox -e coverage
48+
benchmarks:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Set up Python 3.7
53+
uses: actions/setup-python@v2
54+
with:
55+
python-version: 3.7
56+
- name: Install dependencies
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install tox
60+
- name: Test with tox
61+
run: tox -e benchmarks
3462
deploy:
3563
runs-on: ubuntu-latest
3664
needs: test
3765
if: startsWith(github.ref, 'refs/tags')
3866
steps:
3967
- uses: actions/checkout@v2
40-
- name: Set up Python 3.6
68+
- name: Set up Python 3.7
4169
uses: actions/setup-python@v2
4270
with:
43-
python-version: 3.6
71+
python-version: 3.7
4472
- name: Install dependencies
4573
run: |
4674
python -m pip install --upgrade pip

Makefile

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Convenient commands. Run `make help` for command info.
2-
.PHONY: clean clean-test clean-pyc clean-build docs help
32
.DEFAULT_GOAL := help
43

54
define BROWSER_PYSCRIPT
@@ -18,57 +17,75 @@ help:
1817
@grep -E '^[.a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[34;1m%-30s\033[0m %s\n", $$1, $$2}'
1918

2019
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
20+
.PHONY: clean
2121

2222
clean-build: ## remove build artifacts
2323
rm -fr build/
2424
rm -fr dist/
2525
rm -fr .eggs/
2626
find . -name '*.egg-info' -exec rm -fr {} +
2727
find . -name '*.egg' -exec rm -f {} +
28+
.PHONY: clean-build
2829

2930
clean-pyc: ## remove Python file artifacts
3031
find . -name '*.pyc' -exec rm -f {} +
3132
find . -name '*.pyo' -exec rm -f {} +
3233
find . -name '*~' -exec rm -f {} +
3334
find . -name '__pycache__' -exec rm -fr {} +
35+
.PHONY: clean-pyc
3436

3537
clean-test: ## remove test and coverage artifacts
3638
rm -fr .tox/
3739
rm -f .coverage
3840
rm -fr htmlcov/
3941
rm -fr .pytest_cache
42+
.PHONY: clean-test
4043

4144
lint: ## check style with pylint
4245
pylint ribs tests examples benchmarks
46+
.PHONY: lint
4347

4448
test: ## run tests with the default Python
4549
pytest tests
50+
.PHONY: test
51+
4652
test-core: ## only test the core of ribs
4753
pytest tests/core
54+
.PHONY: test-core
55+
4856
test-extras: ## only test the extras of ribs
4957
pytest tests/extras
50-
test-failed: ## run only tests that filed
51-
pytest --last-failed
52-
test-only: ## run tests without benchmarks (which take a while)
53-
pytest -c pytest_no_benchmark.ini tests
58+
.PHONY: test-extras
59+
5460
test-coverage: ## get better test coverage by running without numba on
55-
NUMBA_DISABLE_JIT=1 pytest -c pytest_no_benchmark.ini tests
61+
NUMBA_DISABLE_JIT=1 pytest tests
62+
.PHONY: test-coverage
63+
5664
test-all: ## run tests on every Python version with tox
5765
tox
66+
.PHONY: test-all
5867

59-
NUM_CPUS=4
60-
xtest: ## run tests distributed with 4 workers
61-
pytest -n $(NUM_CPUS) tests
62-
xtest-only: ## run tests without benchmarks distributed over 4 workers
63-
pytest -n $(NUM_CPUS) -c pytest_no_benchmark.ini tests
68+
benchmark: ## run benchmarks (may take a while)
69+
pytest -c pytest_benchmark.ini tests
70+
.PHONY: benchmark
6471

65-
examples-test: ## test examples are working
72+
xtest: ## run tests with n workers (e.g. make xtest n=4)
73+
pytest -n $(n) tests
74+
.PHONY: xtest
75+
76+
xbenchmark: ## run benchmarks with n workers (e.g. make xbenchmarks n=4)
77+
pytest -n $(n) -c pytest_no_benchmark.ini tests
78+
.PHONY: xbenchmark
79+
80+
test-examples: ## test examples are working
6681
bash tests/examples.sh
82+
.PHONY: test-examples
6783

6884
docs: ## generate Sphinx HTML documentation, including API docs
6985
$(MAKE) -C docs clean
7086
$(MAKE) -C docs html
7187
$(BROWSER) docs/_build/html/index.html
88+
.PHONY: docs
7289

7390
servedocs: ## compile the docs watching for changes
7491
DOCS_MODE=dev sphinx-autobuild \
@@ -77,17 +94,18 @@ servedocs: ## compile the docs watching for changes
7794
--watch examples/ \
7895
docs/ \
7996
docs/_build/html
97+
.PHONY: servedocs
8098

8199
release-test: dist ## package and upload a release to TestPyPI
82100
twine upload --repository testpypi dist/*
101+
.PHONY: release-test
102+
83103
release: dist ## package and upload a release
84104
twine upload dist/*
105+
.PHONY: release
85106

86107
dist: clean ## builds source and wheel package
87108
python setup.py sdist
88109
python setup.py bdist_wheel
89110
ls -l dist
90111
check-wheel-contents dist/*.whl
91-
92-
install: clean ## install the package to the active Python's site-packages
93-
python setup.py install

pytest_benchmark.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Config for pytest benchmarks. Pass this file to pytest with the -c option.
2+
3+
[pytest]
4+
python_files = *_benchmark.py
5+
python_functions = benchmark_*
6+
addopts = -v --cov-report term-missing --cov=ribs --benchmark-sort=name --benchmark-name=long
7+
markers = style

pytest_no_benchmark.ini

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

setup.cfg

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ indent_width = 4
2222
[aliases]
2323

2424
[tool:pytest]
25-
python_files = *_test.py *_benchmark.py
26-
python_functions = test_* benchmark_*
27-
addopts = -v --cov-report term-missing --cov=ribs --benchmark-sort=name --benchmark-name=long
25+
python_files = *_test.py
26+
python_functions = test_*
27+
addopts = -v --cov-report term-missing --cov=ribs
2828
markers = style
29-

tox.ini

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Tests for CI.
2-
# - core: ribs core (e.g. archive, emitters, optimizers)
3-
# - extras: ribs extras (e.g. visualize)
2+
# - py*-ribs_core: ribs core (e.g. archive, emitters, optimizers)
3+
# - py*-ribs_extras: ribs extras (e.g. visualize)
44
# - coverage: everything, but with Numba disabled so we can check test coverage
5+
# - benchmarks: all pytest benchmarks under the tests directory
56

67
[tox]
7-
envlist = {py36,py37,py38,py39}-ribs_{core,extras,coverage}, pylint
8+
envlist = {py36,py37,py38,py39}-ribs_{core,extras}, coverage, benchmarks
89

910
[gh-actions]
1011
python =
@@ -13,25 +14,19 @@ python =
1314
3.8: py38
1415
3.9: py39
1516

16-
[testenv:pylint]
17-
basepython = python
18-
deps =
19-
.[all]
20-
pylint
21-
pytest
22-
commands = pylint ribs tests
23-
2417
[testenv]
2518
setenv =
2619
PYTHONPATH = {toxinidir}
27-
ribs_coverage: NUMBA_DISABLE_JIT=1
20+
coverage: NUMBA_DISABLE_JIT=1
2821
deps =
2922
.[dev]
3023
ribs_core: .
3124
ribs_extras: .[all]
32-
ribs_coverage: .[all]
25+
coverage: .[all]
26+
benchmarks: .[all]
3327
commands =
3428
pip install -U pip
3529
ribs_core: pytest --basetemp={envtmpdir} tests/core
3630
ribs_extras: pytest --basetemp={envtmpdir} tests/extras
37-
ribs_coverage: pytest --basetemp={envtmpdir} -c pytest_no_benchmark.ini tests
31+
coverage: pytest --basetemp={envtmpdir} tests
32+
benchmarks: pytest --basetemp={envtmpdir} -c pytest_benchmark.ini tests

0 commit comments

Comments
 (0)