Skip to content

ci: enforce semver bump on pull requests #192

ci: enforce semver bump on pull requests

ci: enforce semver bump on pull requests #192

Workflow file for this run

name: "CI"
on: [push, pull_request]
jobs:
all_jobs:
runs-on: ubuntu-latest
needs: [formatting, type-checking, pytest, semver-check]
if: always()
steps:
- name: Complete
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
echo "One or more required jobs failed."
exit 1
fi
echo "Complete"
semver-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: check version bump
run: |
BASE_VERSION=$(git show origin/${{ github.base_ref }}:pyproject.toml | grep '^version' | sed 's/version = "\(.*\)"/\1/')
PR_VERSION=$(grep '^version' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "Base version: $BASE_VERSION"
echo "PR version: $PR_VERSION"
if [ "$BASE_VERSION" = "$PR_VERSION" ]; then
echo "ERROR: version in pyproject.toml ($PR_VERSION) must be bumped before merging."
exit 1
fi
install-job:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13", "3.12", "3.11"]
steps:
- uses: actions/checkout@v4
- name: install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
python-version: ${{ matrix.python-version }}
- name: install dependencies
run: |
uv sync --all-extras --dev
formatting:
runs-on: ubuntu-latest
needs: [install-job]
steps:
- uses: actions/checkout@v4
- name: install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
python-version: "3.13"
- name: install dependencies
run: |
uv sync --all-extras --dev
- name: run formatting
run: |
uv run ruff format --check
type-checking:
runs-on: ubuntu-latest
needs: [install-job]
steps:
- uses: actions/checkout@v4
- name: install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
python-version: "3.13"
- name: install dependencies
run: |
uv sync --all-extras --dev
- name: run type checking
run: |
uv run ty check
pytest:
runs-on: ubuntu-latest
needs: [install-job]
steps:
- uses: actions/checkout@v4
- name: install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
python-version: "3.13"
- name: install dependencies
run: |
uv sync --all-extras --dev
- name: run pytest
run: |
uv run pytest -v