Merge pull request #32 from jeafreezy/ci #19
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: Python tests | |
# Based of: https://github.com/developmentseed/lonboard/blob/main/.github/workflows/test.yml | |
# On every pull request and push to main branch | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# try other python versions | |
python-version: [3.8, 3.9, "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install and configure Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.7.0 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Check Poetry lockfile up to date | |
run: | | |
poetry check --lock | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
# Note: we don't install the "watchfiles" group on CI because it gives | |
# threading errors when running tests. See | |
# https://github.com/developmentseed/lonboard/pull/234 | |
# https://github.com/manzt/anywidget/issues/374 | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Install root project | |
run: poetry install --no-interaction | |
- name: Run tests | |
run: poetry run pytest | |
- name: Run tests (all deps) | |
# installing the extras and running the tests | |
run: | | |
poetry install -E standard -E cli | |
poetry run pytest | |
# Ensure docs build without warnings | |
- name: Check docs | |
if: matrix.python-version == 3.9 | |
run: poetry run mkdocs build --strict | |
- name: Cache pre-commit virtualenvs | |
uses: actions/cache@v4 | |
if: matrix.python-version == 3.9 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }} | |
# TODO: switch this to run on e.g. 3.11 (how to get the if statement to | |
# work?) | |
# Run pre-commit (only for python-3.9) | |
- name: run pre-commit | |
if: matrix.python-version == 3.9 | |
run: | | |
poetry run pre-commit run --show-diff-on-failure --color=always --all-files |