Skip to content
Closed
60 changes: 60 additions & 0 deletions .github/actions/setup-poetry-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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"
optional-dependency-groups:
required: false
description: "comma separated list of additional dependency groups to install"
default: ''


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

- name: Install Poetry
env:
POETRY_VERSION: "1.6.1"
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: Format dependency groups
id: format-dep-groups
run: |
DEP_GROUPS="${{ inputs.optional-dependency-groups }}"
echo "FORMATTED_DEP_GROUPS=${DEP_GROUPS//,}" >> $GITHUB_ENV
shell: bash

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

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

98 changes: 42 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Unit tests

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

jobs:
Expand All @@ -13,19 +14,25 @@ jobs:
strategy:
fail-fast: false
matrix:
include:
- pyspark-version: 2.4.8 # latest published 2.x version
pip-packages: "pypandoc==1.7 pyspark==2.4.8" # downgrade of pypandoc necessary
- pyspark-version: 3.0.3
pip-packages: "pyspark==3.0.3"
- pyspark-version: 3.1.3
pip-packages: "pyspark==3.1.3"
- pyspark-version: 3.2.4
pip-packages: "pyspark==3.2.4"
- pyspark-version: 3.3.2
pip-packages: "pyspark==3.3.2"
- pyspark-version: 3.4.0
pip-packages: "pyspark==3.4.0"
pyspark-version: ["3.0.3", "3.1.3", "3.2.4", "3.3.2", "3.4.0"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
- pyspark-version: "3.0.3"
python-version: "3.11"
- pyspark-version: "3.0.3"
python-version: "3.12"
- pyspark-version: "3.1.3"
python-version: "3.11"
- pyspark-version: "3.1.3"
python-version: "3.12"
- pyspark-version: "3.2.4"
python-version: "3.11"
- pyspark-version: "3.2.4"
python-version: "3.12"
- pyspark-version: "3.3.2"
python-version: "3.11"
- pyspark-version: "3.3.2"
python-version: "3.12"

steps:
- uses: actions/checkout@v1
Expand All @@ -35,52 +42,31 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8' # Supported by Spark 2.x & 3.x
distribution: "zulu"
java-version: "8" # Supported by Spark 2.x & 3.x

- name: Get supported Python Version depending on PySpark
uses: haya14busa/action-cond@v1
id: python_version
- name: Set up the environment
uses: ./.github/actions/setup-poetry-env
with:
cond: ${{ startsWith(matrix.pyspark-version, '2.') }}
if_true: '3.7' # latest supported version for PySpark 2.x
if_false: '3.9' # PySpark 3+
python-version: ${{ matrix.python-version }}
optional-dependency-groups: "development,testing,linting"

- name: Set up Python ${{ steps.python_version.outputs.value }}
uses: actions/setup-python@v2
with:
python-version: ${{ steps.python_version.outputs.value }}
- name: Change PySpark to version ${{ matrix.pyspark-version }}
run: poetry run pip install pyspark==${{ matrix.pyspark-version }} # Using pip shouldn"t mess up poetry cache

- name: Get supported Poetry version
uses: haya14busa/action-cond@v1
id: poetry_version
with:
cond: ${{ startsWith(matrix.pyspark-version, '2.') }}
if_true: '1.5.1' # latest supported version for PySpark 2.x
if_false: '1.6.1' # PySpark 3+
- name: Run tests for Python ${{ matrix.python-version }} and PySpark ${{ matrix.pyspark-version }}
run: make test

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: ${{ steps.poetry_version.outputs.value }}
check-docs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3

- name: Cache Poetry virtualenv
uses: actions/cache@v1
id: cache
- 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: make install_deps
if: steps.cache.outputs.cache-hit != 'true'
optional-dependency-groups: "docs"

- name: Change PySpark to version ${{ matrix.pyspark-version }}
env:
PIP_PACKAGES: ${{ matrix.pip-packages }}
run: poetry run pip install $PIP_PACKAGES # Using pip shouldn't mess up poetry cache

- name: Run tests with pytest against PySpark ${{ matrix.pyspark-version }}
run: make test
- name: Check if documentation can be built
run: poetry run mkdocs build
Loading