Skip to content

[pre-commit.ci] pre-commit autoupdate #23

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #23

Workflow file for this run

# Based on the following resources:
# https://github.com/actions/starter-workflows/blob/main/ci/python-package.yml
# https://www.marwandebbiche.com/posts/python-package-tooling/
# https://github.com/marketplace/actions/install-poetry-action
name: Continuous Integration and Deployment # Pipeline name in GitHub Actions
on: # events that trigger this workflow
push:
branches:
- master
pull_request:
branches:
- master
release:
types: [created]
workflow_dispatch: # manual trigger
jobs:
# Testing
test:
# Matrix testng allows us to test multiple Python versions
# We will also fail-fast - fail the job if it fails for any context
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
# Checkout the repo so the workflow can access it
- name: Checkout
uses: actions/checkout@v3
# Install the specified version of poetry
- name: Get poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
# Load cached poetry env if it exists
- name: Load cached venv
id: cached-pip-wheels
uses: actions/cache@v3
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# Install poetry env with dev group
- name: Install poetry env with dev group
run: poetry install --with=dev
# Run tests
- name: Run tests
run: |
source $VENV
poetry run pytest
# Code coverage to codecov.io
- uses: codecov/codecov-action@v3
with:
files: tests/coverage.xml
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
# Publishes to PyPi if tests are passed and release is created
publish:
if: github.event_name == 'release' && github.event.action == 'created'
needs: test
runs-on: ubuntu-latest
steps:
# Checkout the repo so the workflow can access it
- name: Checkout
uses: actions/checkout@v3
# Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
# Install the specified version of poetry
- name: Get poetry
uses: snok/install-poetry@v1
with:
version: 1.4.0
virtualenvs-create: true
virtualenvs-in-project: true
# Load cached poetry env if it exists
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# Build and publish to PyPI
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}