Skip to content

Tests for PR 60 by dannymeijer #69

Tests for PR 60 by dannymeijer

Tests for PR 60 by dannymeijer #69

Workflow file for this run

name: Test
run-name: ${{ 'Tests for PR ' }}${{ github.event.pull_request.number }}${{ ' by ' }}${{ github.event.pull_request.user.login }}
on:
pull_request:
branches:
- main
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
STABLE_PYTHON_VERSION: '3.11'
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
python_changed: ${{ steps.check.outputs.python_changed }}
toml_changed: ${{ steps.check.outputs.toml_changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Fetch main branch
run: git fetch origin main:main
- name: Check changes
id: check
run: |
# Set the base reference for the git diff
BASE_REF=${{ github.event.pull_request.base.ref || 'main' }}
# Check for changes in this PR / commit
git_diff_output=$(git diff --name-only $BASE_REF ${{ github.event.after }})
# Count the number of changes to Python and TOML files
python_changed=$(echo "$git_diff_output" | grep '\.py$' | wc -l)
toml_changed=$(echo "$git_diff_output" | grep '\.toml$' | wc -l)
# Write the changes to the GITHUB_OUTPUT environment file
echo "python_changed=$python_changed" >> $GITHUB_OUTPUT
echo "toml_changed=$toml_changed" >> $GITHUB_OUTPUT
tests:
needs: check_changes
if: needs.check_changes.outputs.python_changed > 0 || needs.check_changes.outputs.toml_changed > 0 || github.event_name == 'workflow_dispatch'
name: Python ${{ matrix.python-version }} with PySpark ${{ matrix.pyspark-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# os: [ubuntu-latest, windows-latest, macos-latest] # FIXME: Add Windows and macOS
os: [ubuntu-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
pyspark-version: ['33', '34', '35']
exclude:
- python-version: '3.9'
pyspark-version: '35'
- python-version: '3.11'
pyspark-version: '33'
- python-version: '3.11'
pyspark-version: '34'
- python-version: '3.12'
pyspark-version: '33'
- python-version: '3.12'
pyspark-version: '34'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
uses: pypa/hatch@install
# - name: Check Code Quality
# run: |-
# hatch fmt --check --python=${{ matrix.python-version }}
- name: Run tests
run: hatch test --python=${{ matrix.python-version }} -i version=pyspark${{ matrix.pyspark-version }}
# https://github.com/marketplace/actions/alls-green#why
final_check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- check_changes
- tests
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
allowed-skips: tests