Skip to content

Instantly share code, notes, and snippets.

@dzieciou
Created December 21, 2021 14:28
Show Gist options
  • Save dzieciou/3d6b6a1ae9792d7f683650bbe0fe1448 to your computer and use it in GitHub Desktop.
Save dzieciou/3d6b6a1ae9792d7f683650bbe0fe1448 to your computer and use it in GitHub Desktop.
name: test
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.9
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Load cached Poetry installation
uses: actions/cache@v2
with:
path: ~/.local # the path depends on the OS
key: poetry-0 # increment to reset cache
- 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@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ 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 your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests
run: |
source .venv/bin/activate
coverage run -m pytest
coverage report
#----------------------------------------------
# run code quality
#----------------------------------------------
- name: Code quality
run: |
source .venv/bin/activate
black . --check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment