diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 551bf98b2ec..89b3ef09df4 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -21,12 +21,13 @@ jobs: --ignore=pymc3/tests/test_distributions_timeseries.py --ignore=pymc3/tests/test_examples.py --ignore=pymc3/tests/test_gp.py + --ignore=pymc3/tests/test_mixture.py --ignore=pymc3/tests/test_parallel_sampling.py --ignore=pymc3/tests/test_posteriors.py --ignore=pymc3/tests/test_quadpotential.py --ignore=pymc3/tests/test_random.py --ignore=pymc3/tests/test_sampling.py - --ignore=pymc3/tests/test_shape_handling + --ignore=pymc3/tests/test_shape_handling.py --ignore=pymc3/tests/test_shared.py --ignore=pymc3/tests/test_smc.py --ignore=pymc3/tests/test_updates.py @@ -44,6 +45,7 @@ jobs: - | pymc3/tests/test_examples.py pymc3/tests/test_gp.py + pymc3/tests/test_mixture.py pymc3/tests/test_posteriors.py pymc3/tests/test_quadpotential.py - | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c6ab6619493..7e3b09244a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,14 +31,21 @@ repos: - repo: local hooks: - id: watermark - name: Check notebooks have watermark (see Jupyter style guide from PyMC3 Wiki) - types: [jupyter] + args: [--negate, --multiline] entry: '%load_ext watermark.*%watermark -n -u -v -iv -w' language: pygrep - args: [--negate, --multiline] minimum_pre_commit_version: 2.8.0 + name: Check notebooks have watermark (see Jupyter style guide from PyMC3 Wiki) + types: [jupyter] - id: check-toc + entry: python scripts/check_toc_is_complete.py + language: python name: Check all notebooks appear in table of contents + pass_filenames: false types: [jupyter] - entry: python scripts/check_toc_is_complete.py + - id: check-no-tests-are-ignored + entry: python scripts/check_all_tests_are_covered.py + files: ^\.github/workflows/pytest\.yml$ language: python + name: Check no tests are ignored + pass_filenames: false diff --git a/scripts/check_all_tests_are_covered.py b/scripts/check_all_tests_are_covered.py new file mode 100644 index 00000000000..54221fa21bb --- /dev/null +++ b/scripts/check_all_tests_are_covered.py @@ -0,0 +1,24 @@ +""" +In .github/workflows/pytest.yml, tests are split between multiple jobs. + +Here, we check that the jobs ignored by the first job actually end up getting +run by the other jobs. +This is intended to be used as a pre-commit hook, see `.pre-commit-config.yaml`. +You can run it manually with `pre-commit run check-no-tests-are-ignored --all`. +""" + +from pathlib import Path + +import re + +if __name__ == "__main__": + pytest_ci_job = Path(".github") / "workflows/pytest.yml" + txt = pytest_ci_job.read_text() + ignored_tests = set(re.findall(r"(?<=--ignore=)(pymc3/tests.*\.py)", txt)) + non_ignored_tests = set(re.findall(r"(?