tests #797
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Regular tests | |
# | |
# Use this to ensure your tests are passing on every push and PR (skipped on | |
# pushes which only affect documentation). | |
# There is also a cron job set to run weekly on the default branch, to check | |
# against dependency chain rot. | |
# | |
# You should make sure you run jobs on at least the *oldest* and the *newest* | |
# versions of python that your codebase is intended to support. | |
name: tests | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "0 0 * * 1" | |
branches: [ $default-branch ] | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
python-version: ["3.8", "3.10"] | |
include: | |
- os: windows-latest | |
python-version: "3.8" | |
env: | |
OS: ${{ matrix.os }} | |
PYTHON: ${{ matrix.python-version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: System information | |
run: python .github/workflows/system_info.py | |
- name: Dynamically determine extra variables depending on Python version | |
run: | | |
echo "Running on Python $PYTHON" | |
TEST_SIMA=$(python -c "import sys; print(sys.version_info[:2] <= (3, 6))") | |
echo "TEST_SIMA = $TEST_SIMA" | |
echo "test_sima=$TEST_SIMA" >> $GITHUB_ENV | |
- name: Get pip cache dir | |
id: pip-cache | |
run: echo "::set-output name=dir::$(pip cache dir)" | |
- name: pip cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('**/requirements*.txt') }} | |
restore-keys: ${{ runner.os }}-pip- | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install flake8 | |
python -m pip install --editable .[test] | |
- name: Sanity check with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings | |
python -m flake8 . --count --exit-zero --statistics | |
- name: Debug environment | |
run: python -m pip freeze | |
- name: Test with pytest | |
run: | | |
python -m pytest --timeout=180 --cov=fissa --cov-report term --cov-report xml --junitxml=testresults.xml | |
- name: Upload unittest coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: unittests | |
env_vars: OS,PYTHON | |
name: Python ${{ matrix.python-version }} on ${{ runner.os }} | |
- name: Delete current coverage files | |
run: rm .coverage.* *.xml || echo "Continuing" | |
- name: "Notebooks: Remove SIMA notebooks" | |
if: ${{ env.test_sima != 'True' }} | |
run: rm examples/*SIMA*; | |
- name: "Notebooks: Install dependencies" | |
run: | | |
if [[ "${{ env.test_sima }}" == "True" ]]; then python -m pip install sima; fi; | |
python -m pip install --editable .[plotting] | |
- name: "Notebooks: Lint check" | |
run: python -m pytest --timeout=180 --nbsmoke-lint ./examples/ | |
- name: "Notebooks: Smoke test" | |
run: python -m pytest --timeout=180 --nbsmoke-run ./examples/ --cov=fissa --cov-report term --cov-report xml --junitxml=nbsmoke.xml | |
- name: "Notebooks: Upload coverage to Codecov" | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: nbsmoke | |
env_vars: OS,PYTHON | |
name: Python ${{ matrix.python-version }} on ${{ runner.os }} | |
- name: Build HTML docs | |
run: | | |
python -m pip install --editable .[docs] | |
cd docs | |
make html | |
cd .. |