Skip to content

ci: GitHub Actions Tests workflow — pytest matrix + mypy + gitleaks (closes #13)#19

Merged
wpak-ai merged 5 commits intomasterfrom
ci/run-tests-13
May 8, 2026
Merged

ci: GitHub Actions Tests workflow — pytest matrix + mypy + gitleaks (closes #13)#19
wpak-ai merged 5 commits intomasterfrom
ci/run-tests-13

Conversation

@timon0305
Copy link
Copy Markdown
Collaborator

@timon0305 timon0305 commented May 7, 2026

First in-repo CI workflow for cppa-cursor-browser.

What this gates

  • unittest — 3 OSes × 3 Pythons = 9 cells ([ubuntu-latest, macos-latest, windows-latest] × [3.11, 3.12, 3.13]). Required.
  • typecheck (mypy) — Python 3.12 / ubuntu-latest. Codebase already has ~70 typed functions, so mypy does real work. Lenient flags (--ignore-missing-imports --no-strict-optional) + step-level continue-on-error: true until the surface is clean.
  • secret-scan (gitleaks) — full git history walk, version 8.21.2 with SHA-256 verification. Mirrors the gitleaks setup used on the-claw.

Why this scope

  1. Python version drift is real (3.11 → 3.12 dict ordering / 3.12 → 3.13 PEP 695 / etc.) — the matrix catches it cheap
  2. Project has type hints across most of the surface; mypy can run today, no project adoption step needed
  3. Secret-scan is language-agnostic and zero-friction

What this PR deliberately does NOT add:

  • lint (ruff / black) — needs the project to adopt a config first (ruff.toml or pyproject.toml); separate decision
  • multi-OS for typecheck/secret-scanmypy and gitleaks are OS-agnostic, multi-OS would be wasted CI minutes

Test plan

  • python -m unittest discover tests137 tests pass locally
  • python yaml.safe_load + actionlint clean on the workflow
  • All action SHAs pinned (no @v4/@v5 mutable tags)
  • First CI run on this PR will exercise all 9 unittest cells + typecheck + secret-scan; mypy may surface findings in lenient mode (non-blocking via continue-on-error)

Closes #13.

Summary by CodeRabbit

  • Chores
    • Enhanced CI/CD pipeline with improved security configurations and automated secret detection.
    • Expanded test coverage across Python 3.11–3.13.
    • Added type checking validation to the continuous integration workflow.

timon0305 added 3 commits May 5, 2026 00:21
)

There was no CI on this repository — 137 unit tests in tests/ were only
ever run when a developer remembered to run them locally. A regression
that broke CLI parity, exclusion rules, exporter output, alias
inference, or search filtering could land on master with no gate.

New workflow `.github/workflows/tests.yml`:
- Triggers on every push to master and every pull request.
- Single ubuntu-latest runner, Python 3.12.
- Installs only what the tests need (flask, fpdf2). pywebview from
  requirements.txt is the desktop-launcher dep and pulls GTK / Qt
  system packages — out of scope for the unittest suite, so it is
  deliberately omitted from the CI install. The unittest suite
  imports neither.
- Runs `python -m unittest discover tests -v`.

Local sanity-check with the same command on Python 3.12: 137/137 OK.
Replace @v4 / @v5 tag refs with the matching commit SHAs on
actions/checkout and actions/setup-python. Tags are mutable — a
compromised maintainer can repoint them, silently swapping the code
that runs in our CI runner. SHAs are immutable and remove that
class of supply-chain risk.

Verified each SHA against the live tag on github.com:

  gh api repos/actions/checkout/git/ref/tags/v4 \
    --jq '.object.sha'  # 34e114876b0b11c390a56381ad16ebd13914f8d5
  gh api repos/actions/setup-python/git/ref/tags/v5 \
    --jq '.object.sha'  # a26af69be951a213d495a4c3e4e4022e16d87065

The trailing `# v4` / `# v5` comments preserve the major-version
intent so future bumps stay deliberate. The leading comment block
documents the bump procedure for the next person.
…oses #13)

The previous shape was a single ubuntu-latest / Python 3.12 unittest
job. Expanded to match the broader gate quality the team adopted on
the-claw:

- unittest: 3 OSes × 3 Pythons = 9 cells (3.11 / 3.12 / 3.13 across
  ubuntu-latest, macos-latest, windows-latest). Catches Python version
  drift and the rare path / line-ending issue single-OS hides. fail-fast
  false so cells run independently.
- typecheck: mypy on Python 3.12. Codebase already has 70+ typed
  functions across 30 .py files, so mypy actually does work. Lenient
  config (--ignore-missing-imports, --no-strict-optional) +
  continue-on-error step until the surface is clean.
- secret-scan: gitleaks 8.21.2 with checksum verification (mirrors
  the-claw's setup verbatim). No project-specific .gitleaks.toml; uses
  defaults for standard credential patterns.

Concurrency block added so a new push to the same ref cancels the
in-flight run, reducing CI minutes.

Action SHAs unchanged from the previous workflow (already pinned).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow .github/workflows/tests.yml that runs Python unit tests on ubuntu-latest across Python 3.11–3.13, a mypy typecheck job (Python 3.12, soft-fail), and a pinned gitleaks secret-scan job with checksum verification.

Changes

CI Workflow: Unit Tests, Type Checking, and Secret Scanning

Layer / File(s) Summary
Unit Testing Job
.github/workflows/tests.yml
Defines workflow triggers, read-only contents permission, concurrency cancellation, and unittest job running on ubuntu-latest with Python 3.11–3.13 matrix; installs flask>=3.0 and fpdf2>=2.7, runs python -m unittest discover tests -v.
Type Checking Job
.github/workflows/tests.yml
Adds typecheck job on ubuntu-latest with Python 3.12; installs flask, fpdf2, and mypy>=1.10, runs mypy with --ignore-missing-imports and --no-strict-optional, and uses continue-on-error: true.
Secret Scanning Job
.github/workflows/tests.yml
Adds secret-scan job that checks out full history (fetch-depth: 0), downloads pinned gitleaks 8.21.2 tarball and checksum, verifies the tarball SHA-256 against the checksum entry before extraction, installs gitleaks, then runs gitleaks detect --source . --verbose --redact --exit-code 1.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 I hopped through YAML bright and quick,
Tests on Ubuntu, Python picks,
Types softly checked with a cautious peep,
Secrets hunted where the shadows sleep,
CI hums — a carrot for the commit.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title references pytest but the PR implements unittest as the primary test runner, creating a misleading description of the main change. Change title to 'ci: GitHub Actions Tests workflow — unittest matrix + mypy + gitleaks' to accurately reflect unittest (not pytest) as the test runner.
Linked Issues check ❓ Inconclusive The PR partially implements issue #13: it adds a unittest workflow but expands scope to multi-OS/Python-version matrix, mypy, and gitleaks beyond the issue's single-version, single-OS suggestion. Clarify whether the expanded scope (multi-Python, mypy, gitleaks, reduced to ubuntu-only) aligns with issue #13's intent or represents planned follow-up work.
Out of Scope Changes check ❓ Inconclusive The PR adds mypy type-checking and gitleaks secret-scanning beyond issue #13's scope, which requested only a unittest workflow. However, these appear intentional additions rather than accidental changes. Document whether mypy and gitleaks additions are approved scope expansions or should be moved to separate issues for independent review.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/run-tests-13

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/tests.yml:
- Around line 1-12: Add an explicit top-level permissions block to the "Tests"
workflow to enforce least-privilege for GITHUB_TOKEN: insert a permissions map
under the workflow root (below the name/on/concurrency keys) that lists only the
scopes this CI actually needs (for typical test workflows that is usually
permissions: contents: read, and add only any additional scopes required such as
pull-requests: write or packages: read) so the Tests workflow no longer inherits
broad repository/org defaults; update the permissions to the minimal set and
remove any unnecessary scopes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fc934e6d-864d-4073-a7f6-27389fc46331

📥 Commits

Reviewing files that changed from the base of the PR and between f8b3cb3 and cc0e9a1.

📒 Files selected for processing (1)
  • .github/workflows/tests.yml

Comment thread .github/workflows/tests.yml
@timon0305 timon0305 self-assigned this May 7, 2026
#19)

Adds workflow-level `permissions: contents: read` so a compromised
action step in any matrix cell can't write back to the repo. None of
the jobs (unittest, typecheck, secret-scan) need write access — no
commits, PR comments, or release publishes. Read-only is enough.
@timon0305 timon0305 requested a review from bradjin8 May 7, 2026 21:54
Copy link
Copy Markdown
Collaborator

@bradjin8 bradjin8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the comments, both are optional.
Please confirm with the team for cost/scope before moving forward.

Comment thread .github/workflows/tests.yml
Comment thread .github/workflows/tests.yml
@bradjin8 bradjin8 requested a review from wpak-ai May 8, 2026 19:49
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/tests.yml (1)

49-50: ⚡ Quick win

Add upper version bounds to prevent CI breakage on major releases.

Unbounded >= constraints risk sudden failures when upstream publishes major versions with breaking changes. mypy 2.0.0 was just released with breaking changes; adding upper bounds is essential for deterministic pipelines. For Flask and fpdf2, upper bounds provide future-proofing as well.

Suggested patch
-          python -m pip install 'flask>=3.0' 'fpdf2>=2.7'
+          python -m pip install 'flask>=3.0,<4.0' 'fpdf2>=2.7,<3.0'
...
-          python -m pip install 'flask>=3.0' 'fpdf2>=2.7' 'mypy>=1.10'
+          python -m pip install 'flask>=3.0,<4.0' 'fpdf2>=2.7,<3.0' 'mypy>=1.10,<2.0'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/tests.yml around lines 49 - 50, The CI workflow uses
unbounded >= constraints for dependencies; update the pip install command to add
conservative upper bounds to prevent breakage on future major releases by
changing the package specs to include upper limits (e.g., constrain flask to
<4.0 and fpdf2 to <3.0) so replace "flask>=3.0" with "flask>=3.0,<4.0" and
"fpdf2>=2.7" with "fpdf2>=2.7,<3.0" in the python -m pip install line.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/tests.yml:
- Around line 19-25: The workflow comment and job name claim cross-OS coverage
but the job is Ubuntu-only; update the unit test comment and the "unittest" job
name to reflect Ubuntu-only scope (or convert the matrix to include multiple
OSes) so they are accurate: edit the comment block above the unittest job and
the job name string that currently uses "${{ matrix.os }} / Python ${{
matrix.python-version }}" and either remove/mutate references to matrix.os or
adjust the matrix to include other OSes; ensure consistency between the comment,
the matrix definition, and the unittest job name.

---

Nitpick comments:
In @.github/workflows/tests.yml:
- Around line 49-50: The CI workflow uses unbounded >= constraints for
dependencies; update the pip install command to add conservative upper bounds to
prevent breakage on future major releases by changing the package specs to
include upper limits (e.g., constrain flask to <4.0 and fpdf2 to <3.0) so
replace "flask>=3.0" with "flask>=3.0,<4.0" and "fpdf2>=2.7" with
"fpdf2>=2.7,<3.0" in the python -m pip install line.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a6f50cc2-2c57-4e4f-a757-f0b4140bebf5

📥 Commits

Reviewing files that changed from the base of the PR and between b8df748 and 3dd6b20.

📒 Files selected for processing (1)
  • .github/workflows/tests.yml

Comment on lines +19 to +25
# ── Unit tests: matrix across OS and Python version ───────────────────────
# Closes #13. The unittest suite is the merge gate. Multi-OS catches the
# rare path / line-ending issue that a single-OS run hides; multi-Python
# catches API drift across LTS / current / latest interpreters.
unittest:
name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update matrix comments/name to match actual Ubuntu-only scope.

Line 19–23 describes cross-OS coverage, but Line 29 is Ubuntu-only. This is misleading during triage and maintenance.

✏️ Suggested patch
-  # ── Unit tests: matrix across OS and Python version ───────────────────────
+  # ── Unit tests: matrix across Python versions on Ubuntu ───────────────────
   # Closes `#13`. The unittest suite is the merge gate. Multi-OS catches the
-  # rare path / line-ending issue that a single-OS run hides; multi-Python
+  # rare path / line-ending issue that a single-OS run hides; multi-Python
   # catches API drift across LTS / current / latest interpreters.
   unittest:
-    name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }})
+    name: Unit tests (Ubuntu / Python ${{ matrix.python-version }})

Also applies to: 29-29

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/tests.yml around lines 19 - 25, The workflow comment and
job name claim cross-OS coverage but the job is Ubuntu-only; update the unit
test comment and the "unittest" job name to reflect Ubuntu-only scope (or
convert the matrix to include multiple OSes) so they are accurate: edit the
comment block above the unittest job and the job name string that currently uses
"${{ matrix.os }} / Python ${{ matrix.python-version }}" and either
remove/mutate references to matrix.os or adjust the matrix to include other
OSes; ensure consistency between the comment, the matrix definition, and the
unittest job name.

@wpak-ai wpak-ai merged commit df35f7b into master May 8, 2026
6 checks passed
@wpak-ai wpak-ai deleted the ci/run-tests-13 branch May 8, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: add GitHub Actions workflow that runs the unittest suite on push + PR

3 participants