Skip to content

06 Entwicklung und CI

Asterios Raptis edited this page Mar 7, 2026 · 3 revisions

Entwicklung und CI

Lokale Entwicklung

Dev-Dependencies installieren

make install-dev

Installiert pytest und ruff zusaetzlich zu den Runtime-Dependencies.

Tests

make test          # Standard
make test-v        # Verbose mit Testnamen
make test-cov      # Mit Coverage-Report (erfordert pytest-cov)

Coverage nachinstallieren falls noetig:

poetry add --group dev pytest-cov

Linting und Formatierung

Das Projekt nutzt Ruff als Linter und Formatter. Ruff ersetzt flake8, isort und black in einem einzigen Tool.

make lint          # Pruefen
make lint-fix      # Automatisch beheben
make format        # Code formatieren
make format-check  # Pruefen ohne Aenderung

Konfiguration in pyproject.toml:

[tool.ruff]
target-version = "py311"
line-length = 100

[tool.ruff.lint]
select = ["E", "F", "I", "N", "UP", "B", "SIM"]

Die aktivierten Regelgruppen:

Kuerzel Prueft
E PEP 8 Style
F Pyflakes (unbenutzte Imports, Variablen)
I Import-Sortierung
N Naming Conventions
UP pyupgrade (veraltete Syntax)
B Bugbear (haeufige Fehlerquellen)
SIM Vereinfachbare Konstrukte

Volle CI-Pipeline lokal

make ci

Fuehrt lint, format-check und test hintereinander aus. Gleicher Ablauf wie in der CI-Pipeline.

CI-Integration

GitHub Actions

# .github/workflows/ci.yml
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11", "3.12", "3.13"]

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install Poetry
        run: pip install poetry

      - name: Install dependencies
        run: poetry install --with dev

      - name: Run CI pipeline
        run: make ci

Jenkins

pipeline {
    agent any

    stages {
        stage('Setup') {
            steps {
                sh 'pip install poetry'
                sh 'poetry install --with dev'
            }
        }
        stage('Lint') {
            steps {
                sh 'make lint'
                sh 'make format-check'
            }
        }
        stage('Test') {
            steps {
                sh 'make test'
            }
        }
    }
}

Automatischer Release (GitHub Actions)

# .github/workflows/publish.yml
name: Publish to PyPI

on:
  push:
    tags: ["v*"]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      - name: Install Poetry
        run: pip install poetry

      - name: Build and publish
        env:
          POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
        run: |
          poetry install
          make ci
          poetry build
          poetry publish

Mit diesem Workflow genuegt ein git push origin v0.2.0 um automatisch auf PyPI zu publizieren, sofern alle Tests bestehen.

Conventional Commits

Das Projekt nutzt Conventional Commits. Der Git-Hook unter .githooks/commit-msg validiert jede Message automatisch.

Erlaubte Typen: feat, fix, docs, style, refactor, test, chore, perf

Erlaubte Scopes: checker, sanitizer, metrics, cli, io, models

Beispiele:

feat(checker): add rule for max line length
feat(metrics): add Flesch-DE readability score
fix(sanitizer): preserve tabs in code blocks
docs: update wiki with readability analysis
chore: bump ftfy to 6.2
test(metrics): add edge cases for syllable counting

Breaking Changes:

feat(cli)!: replace ms-lint with ms-validate

BREAKING CHANGE: ms-lint has been removed. Use ms-validate instead.

Zurueck: Publishing | Weiter: FAQ

Clone this wiki locally