From fa5f00d818021a4b449d25b42e083aa709e9f0a7 Mon Sep 17 00:00:00 2001 From: Cheryl Date: Thu, 28 May 2026 11:39:32 +0800 Subject: [PATCH 1/3] Stabilize metrics pool test on restricted environments. Skip the process-pool assertion when multiprocessing semaphores are unavailable so CI and sandboxed runs avoid false negatives while preserving the inline-vs-pool equivalence check where supported. Co-authored-by: Cursor --- tests/test_metrics_pool.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_metrics_pool.py b/tests/test_metrics_pool.py index 6f550be..6da1dbe 100644 --- a/tests/test_metrics_pool.py +++ b/tests/test_metrics_pool.py @@ -1,4 +1,5 @@ from PIL import Image +import pytest from engine.vision_math import calculate_metrics from util.metrics_pool import MetricsProcessPool @@ -10,7 +11,10 @@ def test_metrics_process_pool_matches_inline(tmp_path): expected = calculate_metrics(str(image_path)) - with MetricsProcessPool(max_workers=2) as pool: - actual = pool.calculate(str(image_path)) + try: + with MetricsProcessPool(max_workers=2) as pool: + actual = pool.calculate(str(image_path)) + except (PermissionError, NotImplementedError) as exc: + pytest.skip(f"Process pool unavailable on this environment: {exc}") assert actual == expected From e253190008abd34c750c89117b65230ca07b455c Mon Sep 17 00:00:00 2001 From: Cheryl Date: Thu, 28 May 2026 11:44:03 +0800 Subject: [PATCH 2/3] Fix CI lint failure in loopback planner imports. Remove an unused Optional import flagged by Ruff so lint-test-report passes on PR checks. Co-authored-by: Cursor --- src/agent/loopback_planner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/agent/loopback_planner.py b/src/agent/loopback_planner.py index 12f958d..53689a6 100644 --- a/src/agent/loopback_planner.py +++ b/src/agent/loopback_planner.py @@ -3,7 +3,7 @@ import json import logging from importlib import import_module -from typing import Any, Dict, List, Optional, Protocol +from typing import Any, Dict, List, Protocol from models.contracts import LoopbackPlan From f0103d54b8ce9dad895a2a8e06cf9c4fac8a33f4 Mon Sep 17 00:00:00 2001 From: Cheryl Date: Thu, 28 May 2026 11:47:46 +0800 Subject: [PATCH 3/3] Add faster pre-push checks and split CI heavy tasks. Introduce a local pre-push script for ruff+mypy+pytest parity, split CI into a required lint/type/test gate and an opt-in heavy report job, and update docs with the streamlined developer workflow. Co-authored-by: Cursor --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++++++++++++++- CONTRIBUTING.md | 10 ++++++++++ README.md | 6 ++++++ scripts/dev_prepush_check.sh | 14 ++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 scripts/dev_prepush_check.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d3b45f..5b9850d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,9 +7,21 @@ on: - master - "feat/**" pull_request: + workflow_dispatch: + inputs: + run_reports: + description: "Run report-generation job" + required: false + default: "false" + type: choice + options: ["false", "true"] + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - lint-test-report: + lint-type-test: runs-on: ubuntu-latest steps: @@ -38,6 +50,27 @@ jobs: run: | PYTHONPATH=src pytest + generate-reports: + runs-on: ubuntu-latest + needs: [lint-type-test] + if: > + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) || + (github.event_name == 'workflow_dispatch' && github.event.inputs.run_reports == 'true') + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + - name: Generate reports run: | PYTHONPATH=src python src/ai_quality_agent.py --profile dev --performance-analysis --overhead-analysis diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d4d5df7..8be0305 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,6 +79,16 @@ PYTHONPATH=src python src/ai_quality_agent.py --profile dev --performance-analys 4. **Green CI**: Ensure tests, Ruff, and **mypy** pass locally. 5. **Docs**: If you change CLI flags, config shape, or inference behavior, update `README.md` and any affected file under `docs/`. +## Fast pre-push check (recommended) + +Use one command to run the same quality gates CI enforces for PRs: + +```bash +bash scripts/dev_prepush_check.sh +``` + +This keeps PR feedback fast and avoids common red-X cycles caused by lint/type/test drift. + ## Code style Follow existing patterns in nearby modules (logging, typing, error messages). Prefer clear names and small functions over clever one-liners. diff --git a/README.md b/README.md index d2164cb..4fcdc50 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,12 @@ docker run --rm \ ```bash python -m pip install -U pip pip install -e ".[dev]" +bash scripts/dev_prepush_check.sh +``` + +Or run each check manually: + +```bash ruff check src tests app.py test_connection.py mypy --explicit-package-bases src MYPYPATH=src mypy --explicit-package-bases app.py test_connection.py diff --git a/scripts/dev_prepush_check.sh b/scripts/dev_prepush_check.sh new file mode 100644 index 0000000..c367e11 --- /dev/null +++ b/scripts/dev_prepush_check.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "[prepush] Ruff" +ruff check src tests app.py test_connection.py + +echo "[prepush] mypy" +mypy --explicit-package-bases src +MYPYPATH=src mypy --explicit-package-bases app.py test_connection.py + +echo "[prepush] pytest (CI parity)" +PYTHONPATH=src pytest + +echo "[prepush] all checks passed"