use ruff for linting and formatting, update CI #2567
Workflow file for this run
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
name: Continuous Integration | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
pre-commit: | |
name: ruff and hooks. | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- uses: pre-commit/action@v3.0.1 | |
with: | |
extra_args: --all-files | |
pyright: | |
name: type checking | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
# NOTE: We pin the version of pyright to match pyproject.toml. | |
- run: pip install pyright==1.1.305 | |
- run: pyright sbi | |
test: | |
name: tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.9"] | |
torch-version: ["1.11, 2.0"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install torch==${{ matrix.torch-version }} --extra-index-url https://download.pytorch.org/whl/cpu | |
pip install . | |
- name: Test with pytest | |
run: | | |
pip install torchtestcase | |
pip install pytest pytest-cov | |
pytest -m "not slow and not gpu" tests/ --cov=sbi --cov-report=xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./coverage.xml | |
flags: unittests | |
env_vars: OS,PYTHON | |
name: codecov-umbrella | |
fail_ci_if_error: true |