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

Add unit tests for multiple python versions to CI stage #81

Merged
merged 5 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/actions/setup-poetry-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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.11"
with-docs:
required: false
description: "Install the docs dependency group"
default: 'false'


runs:
using: "composite"
steps:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Install Poetry
env:
# renovate: datasource=pypi depName=poetry
POETRY_VERSION: "1.8.3"
run: curl -sSL https://install.python-poetry.org | python - -y
shell: bash

- name: Add Poetry to Path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
shell: bash

- name: Configure Poetry virtual environment in project
run: poetry config virtualenvs.in-project true
shell: bash

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

- name: Install dependencies
run: |
if [[ "${{ inputs.with-docs }}" == "true" ]]; then
poetry install --no-interaction --with mkdocs
else
poetry install --no-interaction
fi
shell: bash
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'

65 changes: 41 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,56 @@
name: Unit tests

on:
pull_request:
fpgmaas marked this conversation as resolved.
Show resolved Hide resolved
types: [opened, synchronize, reopened]
push:
branches:
- main
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: Check lock file
run: poetry lock --check

test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fpgmaas marked this conversation as resolved.
Show resolved Hide resolved
fail-fast: false
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Check out
uses: actions/checkout@v3

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

- name: Install Poetry
uses: snok/install-poetry@v1
- name: Run tests
run: poetry run pytest tests

- name: Cache Poetry virtualenv
uses: actions/cache@v1
id: cache
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
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'

- name: Run tests with pytest
run: poetry run pytest
with-docs: true

- name: Check if documentation can be built
run: poetry run mkdocs build -s

24 changes: 5 additions & 19 deletions .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,12 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2

- name: Set up the environment
uses: ./.github/actions/setup-poetry-env
with:
python-version: 3.9
- name: Set up Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.4.0
- name: Cache Poetry virtualenv
uses: actions/cache@v1
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run:
poetry install --with mkdocs
if: steps.cache.outputs.cache-hit != 'true'
with-docs: true

- name: Setup GH
run: |
sudo apt update && sudo apt install -y git
Expand Down
24 changes: 12 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ license = "MIT"
[tool.poetry.dependencies]
python = ">=3.8,<4.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "7.4.2"
pyspark = ">3.0.0"
findspark = "1.4.2"
pytest-describe = "^2.1.0"

[tool.poetry.group.mkdocs.dependencies]
mkdocs = "^1.6.0"
mkdocstrings-python = "*"
mkdocs-gen-files = "*"
mkdocs-literate-nav = "*"
mkdocs-section-index = "*"
markdown-include = "*"

[tool.poetry.group.mkdocs]
optional = true

[tool.poetry.group.mkdocs.dependencies]
mkdocstrings-python = "^0.8.3"
mkdocs-gen-files = "^0.4.0"
mkdocs-literate-nav = "^0.6.0"
mkdocs-section-index = "^0.3.5"
markdown-include = "^0.8.1"
mkdocs = "^1.4.2"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Loading