Comments, formatting #45
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
# Heavily inspired by https://github.com/snok/install-poetry#testing | |
name: lint-and-test | |
on: | |
push: | |
branches: [ "main", "dev" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
linting: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up python3.9 | |
id: setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip | |
restore-keys: ${{ runner.os }}-pip | |
- run: python -m pip install flakeheaven | |
- run: | | |
flakeheaven lint | |
test: | |
needs: linting | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ "ubuntu-latest", "macos-latest" ] | |
python-version: [ "3.9", "3.10", "3.11" ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up python ${{ matrix.python-version }} | |
id: setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Load cached Poetry installation | |
# NB: This saves ≈10s, but is perhaps "experimental", and can be removed. | |
# PS: To reset the cache, (manually) increment the digit in `key`. | |
uses: actions/cache@v3 | |
with: | |
path: ~/.local # wont work on Windows | |
key: poetry-2-${{ runner.os }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Load cached venv if exists | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies if not loaded from cache | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
- name: Install package itself | |
run: poetry install --no-interaction | |
- name: Run tests | |
run: | | |
source .venv/bin/activate | |
pytest tests/ |