diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5bcd132..b787123 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,14 @@ # ----------------------------------------------------------------------------- -# - invoked on push, pull_request, or manual trigger +# - invoked on push, pull_request, manual trigger, or schedule # - test under at least 3 versions of python # ----------------------------------------------------------------------------- name: build -on: [push, pull_request, workflow_dispatch] +on: + push: + pull_request: + workflow_dispatch: + schedule: + - cron: "0 8 * * *" jobs: build: @@ -31,7 +36,11 @@ jobs: pip install .[dev] - name: Test run: | - pytest ./tests + if github.event_name == 'schedule'; then + pytest --runslow ./tests + else + pytest ./tests + fi - name: Doc build run: | make html -C docs/ SPHINXOPTS="-W --keep-going -n" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 520a2d5..8af4243 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -17,6 +17,10 @@ jobs: run: | python -m pip install --upgrade pip pip install setuptools wheel twine + - name: Test + run: | + pip install .[test] + pytest ./tests - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} diff --git a/README.rst b/README.rst index 66f73eb..ee7240f 100644 --- a/README.rst +++ b/README.rst @@ -4,8 +4,8 @@ Risk Distributions .. image:: https://badge.fury.io/py/risk_distributions.svg :target: https://badge.fury.io/py/risk-distributions -.. image:: https://travis-ci.org/ihmeuw/risk_distributions.svg?branch=master - :target: https://travis-ci.org/ihmeuw/risk_distributions +.. image:: https://github.com/ihmeuw/risk_distributions/actions/workflows/build.yml/badge.svg?branch=main + :target: https://github.com/ihmeuw/risk_distributions :alt: Latest Version .. image:: https://readthedocs.org/projects/risk-distributions/badge/?version=latest diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..3178a8f --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +import pytest + + +def pytest_addoption(parser): + parser.addoption("--runslow", action="store_true", default=False, help="run slow tests") + + +def pytest_configure(config): + config.addinivalue_line("markers", "slow: mark test as slow to run") + + +def pytest_collection_modifyitems(config, items): + if config.getoption("--runslow"): + # --runslow given in cli: do not skip slow tests + return + skip_slow = pytest.mark.skip(reason="need --runslow option to run") + for item in items: + if "slow" in item.keywords: + item.add_marker(skip_slow)