Skip to content

Introduce ruff

Introduce ruff #1894

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, ready_for_review, synchronize]
push:
branches:
- main
workflow_dispatch:
jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- windows-2022
python-version: [ "3.10", "3.11" ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Python and set up Poetry
uses: bakdata/ci-templates/actions/[email protected]
with:
poetry-version: "1.4.1" # REASON: https://github.com/python-poetry/poetry/issues/8180
python-version: ${{ matrix.python-version }}
- name: Check Poetry lock file consistency
run: poetry lock --check
- name: Install dependencies
run: poetry install --no-interaction
- name: Lint (flake8)
run: poetry run pre-commit run flake8 --all-files --show-diff-on-failure
- name: Order of imports (isort)
run: poetry run pre-commit run isort --all-files --show-diff-on-failure
- name: Formatting (black)
run: poetry run pre-commit run black --all-files --show-diff-on-failure
- name: Typing (pyright)
run: poetry run pre-commit run pyright --all-files
- name: Generate schema (kpops schema)
run: poetry run pre-commit run gen-schema --all-files --show-diff-on-failure
- name: Generate CLI Usage docs (typer-cli)
run: poetry run pre-commit run gen-docs-cli --all-files --show-diff-on-failure
- name: Generate Environment variable docs
run: poetry run pre-commit run gen-docs-env-vars --all-files --show-diff-on-failure
- name: Generate pipeline definitions
run: poetry run pre-commit run gen-docs-components --all-files --show-diff-on-failure
# TODO: enable when PEP 604 incompatibilty is in typer is resolved https://github.com/tiangolo/typer/issues/348
# See https://github.com/tiangolo/typer/pull/522
# - name: Syntax (pyupgrade)
# run: poetry run pre-commit run --hook-stage manual pyupgrade --all-files
- name: Test
run: poetry run pytest tests
- name: Install docs dependencies
run: poetry install --with docs
- name: Check markdown formatting
uses: dprint/[email protected]
if: runner.os == 'Linux'
- name: Test docs build (mkdocs)
run: poetry run mkdocs build -f docs/mkdocs.yml
publish-snapshot-version:
name: Publish snapshot to TestPyPI
needs: [test]
uses: bakdata/ci-templates/.github/workflows/[email protected]
secrets:
pypi-token: ${{ secrets.TEST_PYPI_TOKEN }}
publish-docs-from-main:
runs-on: ubuntu-22.04
if: ${{ github.ref == 'refs/heads/main' }}
needs: [test]
steps:
- uses: actions/checkout@v3
- 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:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'pull_request' }}
needs: [test]
steps:
- uses: actions/checkout@v3
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@v2
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