Skip to content

Improve developer workflow with pre-commit (#351) #1931

Improve developer workflow with pre-commit (#351)

Improve developer workflow with pre-commit (#351) #1931

Workflow file for this run

name: Tests
on:
push:
branches:
- master
tags:
- v[0-9].*
pull_request:
branches:
- master
jobs:
pre-commit:
runs-on: ubuntu-latest
env:
# Skipped for now since we just added pre-commit and not all of our code
# perfectly passes pylint.
SKIP: pylint
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install all deps and pylint (to be available to pre-commit)
run: pip install .[all] pylint
- uses: pre-commit/[email protected]
# The visualize extra is only tested with pinned reqs because different
# Matplotlib versions have slightly different outputs.
test:
strategy:
max-parallel: 12 # All in parallel.
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
exclude:
# To cut down on runtime since Mac seems to take the longest.
- os: macos-latest
python-version: "3.9"
- os: macos-latest
python-version: "3.10"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install core deps
run: pip install .[dev]
- name: Test core
run: >
pytest tests/archives tests/emitters tests/schedulers
pin:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install core deps
run: pip install -r pinned_reqs/install.txt .[dev]
- name: Test core
run: >
pytest tests/archives tests/emitters tests/schedulers
- name: Install extras deps
run: pip install -r pinned_reqs/extras_visualize.txt
- name: Test extras
run: pytest tests/visualize
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install deps
run: pip install .[visualize,dev]
- name: Test coverage
env:
NUMBA_DISABLE_JIT: 1
run: pytest tests
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install deps
run: pip install .[visualize,dev]
- name: Run benchmarks
run: pytest -c pytest_benchmark.ini tests
examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install deps
run: pip install .[visualize]
- name: Test Examples
run: bash tests/examples.sh
tutorials:
runs-on: ubuntu-latest
steps:
# We use Python 3.10 instead of 3.8 here since Google Colab uses 3.10.
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install deps
run: pip install .[visualize] jupyter nbconvert
- name: Test Tutorials
run: bash tests/tutorials.sh
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install deps
run: pip install .[visualize,dev]
- name: Build docs
run: make docs
deploy:
runs-on: ubuntu-latest
needs: [pre-commit, test, pin, coverage, benchmarks, examples, tutorials]
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: |
pip install -e .
pip install -e .[dev]
- name: Publish
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
make release