Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 92 additions & 33 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,110 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

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

permissions:
contents: read

jobs:
build:
runs-on: self-hosted # self-hosted # ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# - name: Cache pip packages
# id: cache-pip
# uses: actions/cache@v4
# with:
# path: ${{ steps.setup-python.outputs.python-packages-cache-dir }}
# key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -v test_optimize_sql_dump.py
- uses: actions/checkout@v4

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

# ===============================
# INSTALL DEPENDENCIES: LINUX/MAC
# ===============================
- name: Install dependencies (Linux/macOS)
if: runner.os != 'Windows'
shell: bash
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install ruff black isort pytest coverage

# ===============================
# INSTALL DEPENDENCIES: WINDOWS
# ===============================
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
python -m pip install --upgrade pip
if (Test-Path "requirements.txt") { pip install -r requirements.txt }
python -m pip install ruff black isort pytest coverage

# ===== LINT =====
- name: Lint with ruff
run: ruff check .

# ===== BLACK FORMAT CHECK (z diff) =====
- name: Black format verification
run: |
black --check --diff .

# ===== ISORT CHECK =====
- name: Isort check
run: isort . --check-only --diff

# ===== TESTS + COVERAGE =====
- name: Run tests with coverage
run: |
coverage run -m pytest -q
coverage xml
coverage report -m

# ===== UPLOAD COVERAGE ARTIFACT =====
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: coverage.xml
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# - name: Cache pip packages
# id: cache-pip
# uses: actions/cache@v4
# with:
# path: ${{ steps.setup-python.outputs.python-packages-cache-dir }}
# key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/requirements-dev.txt') }}
# restore-keys: |
# ${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Ensure dev tools used in CI are available
python -m pip install ruff black isort pytest

- name: Lint with ruff
run: |
ruff check .

- name: Format check (black)
run: |
black --check .

- name: Test with pytest
run: |
pytest -q
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
repos:
# ------------------------
# BLACK — formatting
# ------------------------
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3

# ------------------------
# ISORT — importy
# ------------------------
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

# ------------------------
# RUFF — lint + autofix
# ------------------------
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.3
hooks:
- id: ruff
args: ["--fix"]

# ------------------------
# MYPY — typing (opcjonalnie)
# ------------------------
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies: []

# ------------------------
# PYTEST (pre-commit test)
# ------------------------
# - repo: local
# hooks:
# - id: pytest
# name: Run pytest before commit
# entry: pytest
# language: system
# pass_filenames: false
Loading
Loading