Add homelab CI with hard ruff/pytest gates
Adds .gitea/workflows/ci.yml (python-ci with tesseract + libgl for the OCR/opencv tests, plus gitleaks secret-scan) and ruff.toml (E4/E7/E9/F/I, line-length 120). Cleans up the remaining unused-variable findings so the lint gate is green.
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
# Homelab CI — Python lane + secret scan. Lint and tests are HARD gates.
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
python-ci:
|
||||||
|
runs-on: [homelab, self-hosted, linux, python]
|
||||||
|
container:
|
||||||
|
image: node:20-bookworm
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Python tooling
|
||||||
|
run: |
|
||||||
|
apt-get update -qq
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq \
|
||||||
|
python3 python3-pip python3-venv \
|
||||||
|
tesseract-ocr libgl1 libglib2.0-0
|
||||||
|
python3 -m pip install --upgrade pip --break-system-packages
|
||||||
|
pip install -r requirements.txt --break-system-packages
|
||||||
|
pip install pytest ruff --break-system-packages
|
||||||
|
|
||||||
|
- name: Ruff lint (hard gate)
|
||||||
|
run: ruff check .
|
||||||
|
|
||||||
|
- name: Pytest (hard gate)
|
||||||
|
run: pytest -q
|
||||||
|
|
||||||
|
secret-scan:
|
||||||
|
runs-on: [homelab, self-hosted, linux, heavy]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Gitleaks
|
||||||
|
run: |
|
||||||
|
docker run --rm -v "$PWD:/repo" ghcr.io/gitleaks/gitleaks:latest \
|
||||||
|
detect --source /repo --no-banner --redact
|
||||||
@@ -130,7 +130,6 @@ def detect_document(
|
|||||||
resolution for a full-quality perspective warp.
|
resolution for a full-quality perspective warp.
|
||||||
"""
|
"""
|
||||||
h, w = image_bgr.shape[:2]
|
h, w = image_bgr.shape[:2]
|
||||||
frame_area = float(h * w)
|
|
||||||
|
|
||||||
scale = detect_width / w if w > detect_width else 1.0
|
scale = detect_width / w if w > detect_width else 1.0
|
||||||
small = (
|
small = (
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
line-length = 120
|
||||||
|
|
||||||
|
[lint]
|
||||||
|
select = ["E4", "E7", "E9", "F", "I"]
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import numpy as np
|
|
||||||
import pytest
|
import pytest
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
@@ -32,7 +31,6 @@ def test_images_to_pdf_multi_page(tmp_path):
|
|||||||
|
|
||||||
images_to_pdf(paths, out)
|
images_to_pdf(paths, out)
|
||||||
|
|
||||||
data = out.read_bytes()
|
|
||||||
# img2pdf writes one xobject image per page; a 3-page PDF should be
|
# img2pdf writes one xobject image per page; a 3-page PDF should be
|
||||||
# meaningfully larger than a 1-page PDF of the same-size images.
|
# meaningfully larger than a 1-page PDF of the same-size images.
|
||||||
single = tmp_path / "single.pdf"
|
single = tmp_path / "single.pdf"
|
||||||
|
|||||||
Reference in New Issue
Block a user