Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching to tox for tests #197

Merged
merged 24 commits into from
May 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .coveragerc

This file was deleted.

6 changes: 2 additions & 4 deletions .github/workflows/joss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ on:
push:
branches:
- main
- joss
pull_request:
branches:
- main
paths:
- "joss/**"

jobs:
joss:
Expand Down
98 changes: 58 additions & 40 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on:
push:
branches:
- main
tags:
- "*"
paths-ignore:
- "joss/**"
- "docs/**"
pull_request:
branches:
- main
release:
types: [published]

jobs:
tests:
Expand All @@ -17,60 +18,77 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.9"]
pymc-arviz:
- '"pymc3~=3.9.0" "arviz<0.11"'
- '"pymc3~=3.10.0" "arviz<0.11"'
- '"pymc3~=3.11.0"'
- '"https://github.com/pymc-devs/pymc3/archive/master.zip"'
pymc-version: ["3.9", "3.10", "3.11", "dev"]
include:
- python-version: "3.8"
pymc-version: "3.11"

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
name: Install Python

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install ${{ matrix.pymc-arviz }}
python -m pip install -e .[test]
python -m pip install --no-deps starry

- name: Get compiledir
id: compiledir
shell: bash -l {0}
run: |
python -c "from aesara_theano_fallback import aesara; print('::set-output name=compiledir::' + aesara.config.compiledir)"

- name: Cache compiledir
uses: actions/cache@v2
with:
path: ${{ steps.compiledir.outputs.compiledir }}
key: compiledir-${{ steps.compiledir.outputs.compiledir }}-${{ matrix.pymc-arviz }}-${{ github.sha }}
restore-keys: |
compiledir-${{ steps.compiledir.outputs.compiledir }}-${{ matrix.pymc-arviz }}-
python -m pip install -U coveralls coverage[toml] tox tox-gh-actions

- name: Run tests
run: python -m pytest --cov=exoplanet -v tests
run: python -m tox
env:
PYMC_VERSION: ${{ matrix.pymc-version }}

- name: Coveralls
uses: AndreMiras/coveralls-python-action@v20201129
with:
parallel: true
flag-name: Unit Tests
- name: Combine and upload coverage
run: |
python -m coverage combine
python -m coverage xml -i
python -m coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: py${{ matrix.python-version }}-pymc${{ matrix.pymc-version }}

coverage:
name: "Merge and upload coverage"
needs: tests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@v20201129
- name: Setup Python
uses: actions/setup-python@v2
with:
parallel-finished: true
python-version: "3.9"
- name: Finish coverage collection
run: |
python -m pip install -U pip
python -m pip install -U coveralls
python -m coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install tox

- name: Lint the code
run: python -m tox -e lint

build:
runs-on: ubuntu-latest
Expand All @@ -92,7 +110,7 @@ jobs:
path: dist/*

upload_pypi:
needs: [tests, build]
needs: [tests, lint, build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ on:
push:
branches:
- main
tags:
- "*"
paths-ignore:
- "joss/**"
pull_request:
branches:
- main
release:
types:
- published

jobs:
notebooks:
Expand Down
12 changes: 0 additions & 12 deletions environment.yml

This file was deleted.

41 changes: 26 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| docs/tutorials
)/
'''

[tool.isort]
skip_glob = ["docs/tutorials/*.py"]
Expand All @@ -28,3 +13,29 @@ include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
known_third_party = ["astropy", "corner", "jupytext", "matplotlib", "nbconvert", "nbformat", "numpy", "packaging", "pandas", "pkg_resources", "pymc3", "pytest", "requests", "scipy", "setuptools", "sphinx_typlog_theme", "theano"]

[tool.coverage.run]
parallel = true
branch = true
source = ["exoplanet"]
omit = [
"*_test.py",
"*__init__*",
"*/exoplanet/exoplanet_version.py",
"*/exoplanet/orbits/constants.py",
"*/exoplanet/light_curves/integrated.py",
"*/exoplanet/light_curves/interpolated.py",
]

[tool.coverage.paths]
source = ["src", "*/site-packages"]

[tool.coverage.report]
show_missing = true
exclude_lines = [
"raise NotImplementedError",
"except ImportError",
"pragma: no cover",
"def R_op",
"if verbose"
]
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
testpaths = "tests"
addopts =
-v
filterwarnings =
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"test": [
"scipy",
"pytest",
"pytest-cov>=2.6.1",
"coverage[toml]",
"pytest-env",
"batman-package",
],
Expand Down
33 changes: 33 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[tox]
envlist = py{38,39}-pymc{39,310,311,dev},lint

[gh-actions]
python =
3.8: py38
3.9: py39

[gh-actions:env]
PYMC_VERSION =
3.9: pymc39
3.10: pymc310
3.11: pymc311
dev: pymcdev

[testenv]
passenv = GITHUB_*
deps =
pymc{39,310}: arviz<0.11
pymc39: pymc3~=3.9.0
pymc310: pymc3~=3.10.0
pymc311: pymc3~=3.11.0
pymcdev: https://github.com/pymc-devs/pymc3/archive/v3.zip
extras = test
commands =
pip freeze
python -m coverage run -m pytest -v {posargs}

[testenv:lint]
skip_install = true
deps = pre-commit
commands =
pre-commit run --all-files