Skip to content

ci: add GitHub Actions workflow that runs the unittest suite (closes #13)#14

Closed
timon0305 wants to merge 2 commits intocppalliance:masterfrom
timon0305:ci/run-tests-13
Closed

ci: add GitHub Actions workflow that runs the unittest suite (closes #13)#14
timon0305 wants to merge 2 commits intocppalliance:masterfrom
timon0305:ci/run-tests-13

Conversation

@timon0305
Copy link
Copy Markdown
Collaborator

@timon0305 timon0305 commented May 4, 2026

Problem

No CI. 137 existing unit tests only run when a developer remembers to run them locally — regressions can land on master ungated.

Change

Add .github/workflows/tests.yml. Triggers on every push to master and every pull request. Single Ubuntu runner, Python 3.12. Installs flask + fpdf2 (omits pywebview — desktop-launcher dep, not exercised by the test suite, pulls GTK/Qt system packages). Runs python -m unittest discover tests -v.

Test plan

  • Local run with the exact command the workflow uses: 137/137 OK on Python 3.12.
  • YAML parses; 4 steps (checkout → setup-python → install → run tests).
  • Once merged, every future PR will show a Tests / Unit tests check that must pass before merge.

Closes #13.

Summary by CodeRabbit

  • Chores
    • Added continuous integration to run the unit test suite on pushes and pull requests, installing test dependencies and reporting results to ensure code quality.

…ppalliance#13)

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7fdc862e-5054-494b-b90a-95d737b98f5c

📥 Commits

Reviewing files that changed from the base of the PR and between fec00ae and 7177d9d.

📒 Files selected for processing (1)
  • .github/workflows/tests.yml
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/tests.yml

📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow .github/workflows/tests.yml that runs the repository's unit test suite on pushes to master and on all pull requests using Python 3.12; it installs flask>=3.0 and fpdf2>=2.7 and runs python -m unittest discover tests -v.

Changes

CI: Add tests workflow

Layer / File(s) Summary
Workflow Configuration
.github/workflows/tests.yml
New GitHub Actions workflow Tests triggered on push to master and pull_request.
Runner / Job
.github/workflows/tests.yml
Defines single job unittest running on ubuntu-latest.
Action pins / Environment
.github/workflows/tests.yml
Pins actions/checkout (v4 by SHA) and actions/setup-python (v5 by SHA); sets Python version to 3.12.
Dependency installation
.github/workflows/tests.yml
Upgrades pip and installs test/runtime deps flask>=3.0 and fpdf2>=2.7.
Test execution
.github/workflows/tests.yml
Runs test discovery with python -m unittest discover tests -v.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped a patch into the night,
CI lights now blink with gentle might,
Tests march on every push and PR,
Catching bugs both near and far,
A quiet blossom — green CI sprite.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a GitHub Actions workflow to run unit tests, with appropriate CI prefix convention and issue reference.
Linked Issues check ✅ Passed The pull request fully addresses all coding objectives from issue #13: adds workflow triggered on push/PR, runs 137 unit tests with Python 3.12, installs only test dependencies (flask, fpdf2), and omits pywebview.
Out of Scope Changes check ✅ Passed All changes are in scope: the pull request adds only the .github/workflows/tests.yml file directly addressing the CI requirements from issue #13 with no extraneous modifications.
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

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

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

26-27: ⚡ Quick win

Use compatible release constraints instead of floating lower bounds in CI.

Line 27 uses >= constraints on flask and fpdf2, which can cause unpredictable CI failures when upstream releases include breaking changes. Use compatible release constraints (~=) to pin major and minor versions while allowing patch updates.

♻️ Suggested change
-          python -m pip install 'flask>=3.0' 'fpdf2>=2.7'
+          python -m pip install 'flask~=3.0.0' 'fpdf2~=2.7.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 26 - 27, The CI uses floating
lower-bound pip constraints in the pip install step ("python -m pip install
'flask>=3.0' 'fpdf2>=2.7'"), which can introduce breaking upstream changes;
update that pip install invocation to use compatible release operators (~=) for
the packages (e.g., replace "flask>=3.0" and "fpdf2>=2.7" with "flask~=3.0" and
"fpdf2~=2.7") so CI allows patch releases but prevents accidental major/minor
upgrades.
🤖 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 14-17: The workflow uses floating tags for actions
(actions/checkout@v4 and actions/setup-python@v5); replace those tags with their
corresponding immutable commit SHAs by updating the uses fields for
actions/checkout and actions/setup-python to the current verified commit SHA
strings (rather than `@v4/`@v5), ensuring the checkout and setup-python steps
reference the exact commit SHAs to pin the actions.

---

Nitpick comments:
In @.github/workflows/tests.yml:
- Around line 26-27: The CI uses floating lower-bound pip constraints in the pip
install step ("python -m pip install 'flask>=3.0' 'fpdf2>=2.7'"), which can
introduce breaking upstream changes; update that pip install invocation to use
compatible release operators (~=) for the packages (e.g., replace "flask>=3.0"
and "fpdf2>=2.7" with "flask~=3.0" and "fpdf2~=2.7") so CI allows patch releases
but prevents accidental major/minor upgrades.
🪄 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: aa24d2b5-c034-4a8e-85a7-446a6c9a47d6

📥 Commits

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

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

Comment thread .github/workflows/tests.yml Outdated
…palliance#14)

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.
@timon0305
Copy link
Copy Markdown
Collaborator Author

Superseded by #19 — moved in-repo (cppalliance/ci/run-tests-13 instead of fork) so CI actually runs. New PR also expands the gate to multi-OS / multi-Python / mypy / gitleaks.

@timon0305 timon0305 closed this May 7, 2026
wpak-ai pushed a commit that referenced this pull request May 8, 2026
…loses #13) (#19)

* ci: add GitHub Actions workflow that runs the unittest suite (closes #13)

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.

* ci: pin action versions to immutable commit SHAs (CodeRabbit on PR #14)

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.

* ci: expand to multi-OS + multi-Python matrix, add mypy + gitleaks (closes #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).

* ci: explicit least-privilege GITHUB_TOKEN permissions (CodeRabbit on PR #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.

* fix: remove other OS other than ubuntu

---------

Co-authored-by: Monkey Dev <headit74@hotmail.com>
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

1 participant