Skip to content

Quality gate: add file-scoped pytest + Python lint hooks (no-op without Python); same pattern for future Bash tests #12

Description

@DenWin

Problem

The quality gate runs pre-commit hooks only, and no hook covers Python. A repo scaffolded from this template that later grows Python code gets no test or lint gating for it — the suite runs only when someone remembers to run it by hand. This happened in DenWin/openIdea#2: 30 pytest cases existed with green local runs, but CI never executed them.

Proposal (ported from openIdea, commit DenWin/openIdea@872b6be)

All additions are file-scoped, so in a repo without Python files every one of them is a no-op:

  1. Managed lint hooksastral-sh/ruff-pre-commit (ruff-check, ruff-format). Both match *.py only.

  2. Local test hook — pytest fast lane under the same orchestrator as every other check:

    - id: pytest-fast
      name: pytest (fast lane)
      entry: uv run pytest -q
      language: system
      pass_filenames: false
      files: (\.py$|^pyproject\.toml$|^uv\.lock$)
      stages: [pre-commit]

    The files: filter means scoped PR runs skip it when no Python changed, and a repo with no Python never triggers it at all.

  3. Workflow — one pinned step in quality-gate.yml so CI can back the hook: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2. Harmless when the hook never fires.

  4. Convention note — repos that grow an application should commit uv.lock, so CI resolves the exact environment used locally.

Bash analog

shellcheck + shfmt are already file-scoped no-ops, so Bash linting needs nothing. If shell scripts ever gain tests, apply the same pattern: bats-core as a local hook with a files: \.(sh|bats)$ filter — dormant until the first script/test exists, no gate changes needed on that day.

Related fix worth porting

The gate's token has contents: read only, but gitleaks-action v3 lists PR commits via the API on pull_request events and 403s without pull-requests: read — every PR fails before any check runs. Fixed in openIdea commit DenWin/openIdea@2657d57 (adds the read scope, token stays read-only).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions