Add poetry commands for dev env #21
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
# Source: https://github.com/marketplace/actions/install-poetry-action | |
name: Python (flake8, pytest) | |
on: | |
push: | |
branches: ['main', 'develop'] | |
pull_request: | |
branches: ['main', 'develop'] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
#---------------------------------------------- | |
# check-out repo and set-up python | |
#---------------------------------------------- | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11.5' | |
#---------------------------------------------- | |
# ----- install & configure poetry ----- | |
#---------------------------------------------- | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
#---------------------------------------------- | |
# load cached venv if cache exists | |
#---------------------------------------------- | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
#---------------------------------------------- | |
# install dependencies if cache does not exist | |
#---------------------------------------------- | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root | |
#---------------------------------------------- | |
# install root project | |
#---------------------------------------------- | |
- name: Install project | |
run: poetry install --no-interaction | |
#---------------------------------------------- | |
# run flake8 | |
#---------------------------------------------- | |
- name: Run flake8 | |
run: | | |
source .venv/bin/activate | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
#---------------------------------------------- | |
# run pytest | |
#---------------------------------------------- | |
- name: Run tests | |
run: | | |
source .venv/bin/activate | |
pytest tests |