Fix tips and add jupyter lab to the environment (#75) #293
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
# Continuous integration | |
name: CI | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
paths: | |
- "sleap_roots/**" | |
- "tests/**" | |
- ".github/workflows/ci.yml" | |
- "environment.yml" | |
push: | |
branches: | |
- main | |
paths: | |
- "sleap_roots/**" | |
- "tests/**" | |
- ".github/workflows/ci.yml" | |
- "environment.yml" | |
jobs: | |
# Lint with black and docstring check with pydocstyle | |
lint: | |
# This job runs: | |
# | |
# 1. Linting with black | |
# | |
# 2. Docstring style checking with pydocstyle | |
# Note: This uses Google-style docstring convention | |
# Ref: https://google.github.io/styleguide/pyguide.html | |
name: Lint | |
runs-on: "ubuntu-22.04" | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies | |
run: | | |
pip install --editable .[dev] | |
- name: Run Black | |
run: | | |
black --check sleap_roots tests | |
- name: Run pydocstyle | |
run: | | |
pydocstyle --convention=google sleap_roots/ | |
# Tests with pytest | |
tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-22.04", "windows-2022"] | |
python: [3.9] | |
name: Tests (${{ matrix.os }}, Python ${{ matrix.python }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
lfs: true # Fetch large files with Git LFS | |
- name: Setup Micromamba | |
# https://github.com/mamba-org/setup-micromamba | |
# Note: Set channel-priority in .condarc if needed | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-file: environment.yml | |
cache-environment: true | |
cache-environment-key: environment-${{ hashFiles('environment.yml') }}-${{ hashFiles('pyproject.toml') }} | |
init-shell: >- | |
bash | |
powershell | |
post-cleanup: all | |
- name: Print environment info | |
shell: bash -l {0} | |
run: | | |
which python | |
micromamba info | |
micromamba list | |
pip freeze | |
- name: Test with pytest | |
if: ${{ !(startsWith(matrix.os, 'ubuntu') && matrix.python == 3.9) }} | |
shell: bash -l {0} | |
run: | | |
pytest | |
- name: Test with pytest (with coverage) | |
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.python == 3.9 }} | |
shell: bash -l {0} | |
run: | | |
pytest --cov=sleap_roots --cov-report=xml tests/ | |
- name: Upload coverage | |
uses: codecov/codecov-action@v4 | |
if: ${{ startsWith(matrix.os, 'ubuntu') && matrix.python == 3.9 }} | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
verbose: false |