diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..90d13ab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + tests: + name: Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.10', '3.11', '3.12', '3.13'] + + steps: + - name: Check out repository + uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: pip + cache-dependency-path: pyproject.toml + + - name: Install package with test dependencies + run: python -m pip install -e '.[dev]' + + - name: Run offline test suite + run: python -m pytest -q diff --git a/README.md b/README.md index a21a1ac..cb97f93 100644 --- a/README.md +++ b/README.md @@ -196,13 +196,29 @@ except (ServerError, TimeoutError_): raise ``` -## Tests +## Entwicklung und Tests + +Die Tests benötigen die optionale Dev-Abhängigkeit `requests-mock`. Installiere +das Paket deshalb im Entwicklungsmodus mit dem `dev`-Extra, bevor du `pytest` +ausführst: + +```bash +python3 -m venv .venv +source .venv/bin/activate +python -m pip install -e ".[dev]" +python -m pytest -q +``` + +Optional mit Coverage: ```bash -.venv/bin/pytest -.venv/bin/pytest --cov=briefklick +python -m pytest --cov=briefklick ``` +Ein nacktes `python -m pytest` in einer Umgebung ohne `.[dev]` schlägt fehl, +weil `requests-mock` nur für Tests gebraucht wird und nicht zu den +Laufzeit-Abhängigkeiten gehört. + Alle Tests laufen offline. `requests-mock` fängt sämtliche HTTP-Aufrufe ab, ein API-Key ist für die Tests nicht nötig.