Migrate from Poetry to uv #3535
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
types: [opened, ready_for_review, synchronize] | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
env: | |
UV_VERSION: "0.5.14" | |
jobs: | |
lint: | |
name: Lint | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-24.04 | |
- windows-2022 | |
python-version: ["3.11", "3.12"] | |
is-draft-pr: | |
- ${{ github.event.pull_request.draft }} | |
include: | |
- python-version: "3.11" | |
os: ubuntu-24.04 | |
format-for-github: true | |
exclude: | |
# skip Windows jobs on draft PRs because they are slow | |
- os: windows-2022 | |
is-draft-pr: true | |
runs-on: ${{ matrix.os }} | |
steps: | |
# TODO: remove, only for debugging | |
- name: Write GitHub context to log | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
version: ${{ env.UV_VERSION }} | |
- name: Check uv.lock | |
run: uv lock --check | |
- name: Lint (ruff) | |
run: | | |
if [[ "${{ matrix.format-for-github }}" == "true" ]] | |
then | |
uv run --frozen ruff check . --config pyproject.toml --output-format=github --no-fix | |
else | |
uv run --frozen ruff check . --config pyproject.toml --no-fix | |
fi; | |
- name: Formatting (ruff) | |
run: uv run --frozen ruff format | |
- name: Typing (pyright) | |
run: | | |
if [[ "${{ matrix.format-for-github }}" == "true" ]] | |
then | |
echo "::add-matcher::.github/pyright-matcher.json" | |
fi; | |
uv run --frozen pyright | |
- name: Check markdown, toml, css formatting | |
uses: dprint/[email protected] | |
if: ${{ runner.os == 'Linux' }} | |
test: | |
name: Test | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-24.04 | |
- windows-2022 | |
python-version: ["3.11", "3.12"] | |
is-draft-pr: | |
- ${{ github.event.pull_request.draft }} | |
exclude: | |
# skip Windows jobs on draft PRs because they are slow | |
- os: windows-2022 | |
is-draft-pr: true | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
version: ${{ env.UV_VERSION }} | |
- name: Test | |
run: uv run --frozen pytest tests | |
docs: | |
name: Docs | |
runs-on: [ubuntu-24.04] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: "3.11" | |
version: ${{ env.UV_VERSION }} | |
- name: Generate schema (kpops schema) | |
run: uv run --frozen pre-commit run gen-schema --all-files --show-diff-on-failure | |
- name: Generate CLI Usage docs (typer-cli) | |
run: uv run --frozen pre-commit run gen-docs-cli --all-files --show-diff-on-failure | |
- name: Generate Environment variable docs | |
run: uv run --frozen pre-commit run gen-docs-env-vars --all-files --show-diff-on-failure | |
- name: Generate pipeline definitions | |
run: uv run --frozen pre-commit run gen-docs-components --all-files --show-diff-on-failure | |
- name: Test docs build (mkdocs) | |
run: uv run --frozen --group=docs mkdocs build -f docs/mkdocs.yml | |
publish-snapshot-version: | |
name: Publish snapshot to TestPyPI | |
needs: [lint, test, docs] | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
python-version: "3.11" | |
version: ${{ env.UV_VERSION }} | |
- name: Generate snapshot time | |
id: snapshot-time | |
run: | | |
snapshot_time=$(python -c "from datetime import datetime; time = datetime.now(); print(time.strftime('%Y%m%d%H%M%S'))") | |
echo "snapshot-time=${snapshot_time}" >> "$GITHUB_OUTPUT" | |
- name: Bump version patch | |
id: bump-version | |
uses: bakdata/ci-templates/actions/[email protected] | |
with: | |
release-type: patch | |
- run: git restore . | |
- name: Bump version snapshot time | |
uses: bakdata/ci-templates/actions/[email protected] | |
with: | |
release-type: patch | |
new-version: ${{ steps.bump-version.outputs.release-version }}${{ steps.snapshot-time.outputs.snapshot-time }} # e.g. 9.1.1-dev20250108102827 | |
- name: Build | |
run: uv build | |
- name: Publish TestPyPI | |
run: uv publish | |
env: | |
UV_PUBLISH_URL: https://test.pypi.org/legacy/ | |
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }} | |
publish-docs-from-main: | |
name: Publish docs (main) | |
runs-on: ubuntu-24.04 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: [lint, test, docs] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Publish docs from main branch | |
uses: ./.github/actions/update-docs | |
with: | |
username: ${{ secrets.GH_USERNAME }} | |
email: ${{ secrets.GH_EMAIL }} | |
token: ${{ secrets.GH_TOKEN }} | |
version: main | |
publish-dev-docs-from-pr: | |
name: Publish docs (dev) | |
runs-on: ubuntu-24.04 | |
if: ${{ github.event_name == 'pull_request' }} | |
needs: [lint, test, docs] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
# Checks to see if any files in the PR match one of the listed file types. | |
# This will return true if there's a file in docs folder that was added, deleted, or modified in the PR. | |
- name: Check if files in docs folder have changed | |
uses: dorny/paths-filter@v3 | |
id: docs-changes | |
with: | |
filters: | | |
docs: | |
- added|deleted|modified: 'docs/**' | |
- name: Publish dev docs from PR | |
if: steps.docs-changes.outputs.docs == 'true' | |
uses: ./.github/actions/update-docs | |
with: | |
username: ${{ secrets.GH_USERNAME }} | |
email: ${{ secrets.GH_EMAIL }} | |
token: ${{ secrets.GH_TOKEN }} | |
version: dev |