Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve and simplify CI configuration and fix 3.11 random failures #192

Merged
merged 12 commits into from
Nov 14, 2022
Merged
56 changes: 0 additions & 56 deletions .github/actions/check-docs/action.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/actions/deploy-docs/action.yml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/actions/run-checks/action.yml

This file was deleted.

32 changes: 4 additions & 28 deletions .github/actions/setup-poetry-env/action.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,33 @@
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@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
51 changes: 39 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- main
tags-ignore:
- '**'
pull_request:
types: [opened, synchronize, reopened]

Expand All @@ -16,11 +14,22 @@ jobs:
- 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 checks
uses: ./.github/actions/run-checks
- 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
Expand All @@ -32,22 +41,40 @@ jobs:
- name: Check out
uses: actions/checkout@v3

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Test with tox
- 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: |
source .venv/bin/activate
poetry add tox-gh-actions
tox
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: check documentation
uses: ./.github/actions/check-docs
- name: Set up the environment
uses: ./.github/actions/setup-poetry-env

- name: Check if documentation can be built
run: poetry run mkdocs build -s
54 changes: 5 additions & 49 deletions .github/workflows/on-release-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,8 @@ on:
branches: [main]

jobs:
quality:
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

tox:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
fail-fast: false
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: Test with tox
run: |
source .venv/bin/activate
poetry add tox-gh-actions
tox

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

- name: check documentation
uses: ./.github/actions/check-docs

publish:
runs-on: ubuntu-latest
needs:
- quality
- tox
- check-docs
steps:
- name: Check out
uses: actions/checkout@v3
Expand All @@ -67,7 +21,6 @@ jobs:

- name: Build and publish
run: |
source .venv/bin/activate
poetry version $RELEASE_VERSION
make build-and-publish
env:
Expand All @@ -81,5 +34,8 @@ jobs:
- name: Check out
uses: actions/checkout@v3

- name: check documentation
uses: ./.github/actions/deploy-docs
- name: Set up the environment
uses: ./.github/actions/setup-poetry-env

- name: Deploy documentation
run: poetry run mkdocs gh-deploy --force
5 changes: 2 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ development. Please note this documentation assumes you already have

pyenv local <x.y.z>

Then, install and activate the environment with:
Then, install the virtual environment with:

.. code-block:: bash

poetry install
poetry shell

| 4. Install pre-commit to run linters/formatters at commit time:

Expand Down Expand Up @@ -118,7 +117,7 @@ development. Please note this documentation assumes you already have

tox

This requires you to have multiple versions of python installed.
This requires you to have multiple versions of Python installed.
This step is also triggered in the CI/CD pipeline, so you could also choose to skip this
step locally.

Expand Down
Loading