Skip to content

Run tests

Run tests #404

Workflow file for this run

name: Run tests
on:
schedule:
- cron: '19 3 * * 1-5'
push:
pull_request:
workflow_call:
secrets:
TNG_API_KEY:
required: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Black
uses: psf/black@stable
with:
options: "--check --verbose"
jupyter: true
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Run flake8
uses: py-actions/flake8@v2
- name: Install mypy
run: pip install mypy
- name: Install types
run: mypy --install-types --non-interactive
- name: Run mypy
run: mypy
- name: Install martini
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Run stubtest
run: ./run_stubtest
- name: Install numpydoc
run: pip install numpydoc
- name: Run docstring validation
run: ./run_validate_docstrings
tests:
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v4
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f optional_requirements.txt ]; then pip install -r optional_requirements.txt; fi
pip install -e .
- name: Test with pytest
env:
TNG_API_KEY: ${{ secrets.TNG_API_KEY }}
run: |
pytest
tests-and-coverage:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Cache pip
uses: actions/cache@v4
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f optional_requirements.txt ]; then pip install -r optional_requirements.txt; fi
pip install -e .
- name: Test with pytest including coverage report
env:
TNG_API_KEY: ${{ secrets.TNG_API_KEY }}
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}