Skip to content

Commit

Permalink
updated CI/CD for main project, updated Makefile (#67)
Browse files Browse the repository at this point in the history
* updated CI/CD for main project, updated Makefile

* updated ci/cd

* added pytest-cov

* removed obsolete raw statements

* fix pytest

* fixed badges

* removed deptry from precommit

* improved makefiles

* added command to quickly test deployment on github

* modified post-hook

* re-enable codecov config validation

* removed pipeline.png
  • Loading branch information
fpgmaas authored Nov 17, 2022
1 parent e284b02 commit da5b527
Show file tree
Hide file tree
Showing 28 changed files with 392 additions and 509 deletions.
19 changes: 0 additions & 19 deletions .github/actions/run-checks/action.yml

This file was deleted.

35 changes: 5 additions & 30 deletions .github/actions/setup-poetry-env/action.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,33 @@
# checkout-and-yarn/action.yml

name: "setup-poetry-env"
description: "Composite action to setup the Python and poetry environment."

inputs:
python-version:
required: false
description: "The python version to use"
default: 3.9.7
default: "3.11"

runs:
using: "composite"
steps:
#----------------------------------------------
# from: https://github.com/snok/install-poetry
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
#----------------------------------------------
# ----- 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@v2
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ inputs.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
shell: bash
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction
shell: bash
- name: Activate environment
run: source .venv/bin/activate
shell: bash
80 changes: 80 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Main

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
quality:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env

- name: Run pre-commit
run: poetry run pre-commit run -a --show-diff-on-failure

- name: Inspect dependencies
run: poetry run deptry .

- name: Check Poetry lock file consistency
run: poetry lock --check

tox:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
fail-fast: false
steps:
- name: Check out
uses: actions/checkout@v3

- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Load cached venv
uses: actions/cache@v3
with:
path: .tox
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox

- name: Upload coverage reports to Codecov with GitHub Action on Python 3.11
uses: codecov/codecov-action@v3
if: ${{ matrix.python-version == '3.11' }}

check-docs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env

- name: Check if documentation can be built
run: poetry run mkdocs build -s
48 changes: 0 additions & 48 deletions .github/workflows/on-merge-to-main.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/on-pull-request.yml

This file was deleted.

78 changes: 16 additions & 62 deletions .github/workflows/on-release-main.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,41 @@
name: release-main

on:
release:
types: [published]
branches: [main]

name: release-main

jobs:
quality:
publish:
runs-on: ubuntu-latest
steps:

- name: Check out
uses: actions/checkout@v3

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env

- name: Run checks
uses: ./.github/actions/run-checks

- name: Documentation Test
run: |
source .venv/bin/activate
make docs-test
tox:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- name: Check out
uses: actions/checkout@v3

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env
with:
python-version: ${{ matrix.python-version }}
- name: Export tag
id: vars
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT

- name: Test with tox
- name: Build and publish
run: |
source .venv/bin/activate
poetry add tox-gh-actions
tox
publish:
runs-on: ubuntu-latest
needs:
- quality
- tox
steps:

- name: Check out
uses: actions/checkout@v3
poetry version $RELEASE_VERSION
make build-and-publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env

- name: Set output
id: vars
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT

- name: Build and publish
run: |
source .venv/bin/activate
poetry version $RELEASE_VERSION
make build-and-publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

documentation:
deploy-docs:
runs-on: ubuntu-latest
needs: publish
steps:

- name: Check out
uses: actions/checkout@v3

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env

- name: Generate documentation
run: |
source .venv/bin/activate
mkdocs gh-deploy --force

- name: Deploy documentation
run: poetry run mkdocs gh-deploy --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
example-project
cookiecutter-poetry-example

# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore

Expand Down
7 changes: 1 addition & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ repos:
- repo: https://github.com/PyCQA/flake8
rev: "5.0.4"
hooks:
- id: flake8

- repo: https://github.com/fpgmaas/deptry.git
rev: d29525669a80068a8a53ac1f2d5c94321111a87d
hooks:
- id: deptry
- id: flake8
Loading

0 comments on commit da5b527

Please sign in to comment.