Skip to content

ci: add Python CI (compile + test gate) - #3

Merged
Masoud-Masoori merged 1 commit into
mainfrom
ci/add-python-ci
Jun 4, 2026
Merged

ci: add Python CI (compile + test gate)#3
Masoud-Masoori merged 1 commit into
mainfrom
ci/add-python-ci

Conversation

@Masoud-Masoori

@Masoud-Masoori Masoud-Masoori commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Applies the org python-ci workflow template (from Mas-AI-Official/.github/workflow-templates) to this repo.

What it does on every push/PR to main:

  • Installs requirements.txt on Python 3.11 (pip-cached)
  • python -m compileall . — catches syntax errors across the repo
  • Runs pytest if a tests/ dir exists; otherwise passes with a compile check

Why python-ci, not node-ci: package.json still has the default "test": "... exit 1" script, which would make node-ci fail red. Python CI is green-safe today and gives an immediate regression gate. Add a real test script later and we can layer node-ci on top.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added continuous integration workflow to automate Python testing and code quality checks.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new GitHub Actions workflow named "Python CI" was added to automate testing on the main and master branches. The workflow sets up Python 3.11, installs dependencies, compiles Python source, and conditionally runs pytest when tests are present.

Changes

Python CI Workflow

Layer / File(s) Summary
Workflow trigger and concurrency configuration
.github/workflows/python-ci.yml
Workflow runs on push and pull_request events targeting main and master, with read-only permissions and concurrency keyed by Git ref to cancel in-progress runs.
Environment and dependency installation
.github/workflows/python-ci.yml
Job runs on ubuntu-latest with Python 3.11 and pip caching; a shell script conditionally installs dependencies from requirements.txt or pyproject.toml with editable dev extras, and optionally installs pytest if a tests directory exists.
Compilation and conditional test execution
.github/workflows/python-ci.yml
Python files are compiled with compileall for syntax checking, and pytest runs only when a tests directory is detected, otherwise a compile-check success message is printed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A workflow so tidy, so clean and so bright,
With Python 3.11 running tests through the night,
Dependencies flow like a rabbit's swift hop,
Compiling and testing—the checks never stop!

🚥 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 Python CI workflow with compile and test gates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/add-python-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/python-ci.yml:
- Line 33: The CI step is swallowing editable-install failures because the shell
line ends with "|| true"; update the command that runs pip editable installs
(the line containing pip install -e ".[dev]" || pip install -e . || true) to
remove the final "|| true" so the job fails if both editable installs fail,
ensuring installation errors are surfaced in CI.
- Around line 22-24: The workflow uses movable tags for actions/checkout@v6 and
actions/setup-python@v6; replace those tags with their corresponding immutable
commit SHAs (the full 40-character git commit for each action) to satisfy the
pinned-action policy. Update the uses lines for actions/checkout and
actions/setup-python to reference the exact commit SHA strings for the versions
you intend to use, confirming the SHAs on the official GitHub repositories for
those actions before committing.
- Line 22: Update the GitHub Actions checkout step to disable credential
persistence: locate the actions/checkout@v6 step and add the
persist-credentials: false input so the runner does not leave the GITHUB_TOKEN
in local git config for later steps; ensure the option name is spelled exactly
as persist-credentials and placed under the same step where uses:
actions/checkout@v6 is declared.
🪄 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: 7748f31a-4eff-47de-b7df-8aec914330e5

📥 Commits

Reviewing files that changed from the base of the PR and between 6d90d84 and 2a6fb88.

📒 Files selected for processing (1)
  • .github/workflows/python-ci.yml

timeout-minutes: 25

steps:
- uses: actions/checkout@v6

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 | 🟠 Major | ⚡ Quick win

Disable credential persistence in checkout step.

Line 22 currently leaves the Git auth token in local git config for later steps. Set persist-credentials: false to reduce token exposure during PR execution.

Suggested change
-      - uses: actions/checkout@v6
+      - uses: actions/checkout@v6
+        with:
+          persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
persist-credentials: false
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 22-22: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 22-22: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 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/python-ci.yml at line 22, Update the GitHub Actions
checkout step to disable credential persistence: locate the actions/checkout@v6
step and add the persist-credentials: false input so the runner does not leave
the GITHUB_TOKEN in local git config for later steps; ensure the option name is
spelled exactly as persist-credentials and placed under the same step where
uses: actions/checkout@v6 is declared.

Comment on lines +22 to +24
- uses: actions/checkout@v6

- uses: actions/setup-python@v6

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 | 🟠 Major | ⚡ Quick win

Pin GitHub Actions to immutable commit SHAs.

Line 22 and Line 24 use movable tags (@v6), which violates pinned-action policy and weakens supply-chain integrity. Pin both actions to full commit SHAs.

Suggested change
-      - uses: actions/checkout@v6
+      - uses: actions/checkout@<full_commit_sha>

-      - uses: actions/setup-python@v6
+      - uses: actions/setup-python@<full_commit_sha>
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 22-22: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 22-22: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 24-24: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 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/python-ci.yml around lines 22 - 24, The workflow uses
movable tags for actions/checkout@v6 and actions/setup-python@v6; replace those
tags with their corresponding immutable commit SHAs (the full 40-character git
commit for each action) to satisfy the pinned-action policy. Update the uses
lines for actions/checkout and actions/setup-python to reference the exact
commit SHA strings for the versions you intend to use, confirming the SHAs on
the official GitHub repositories for those actions before committing.

run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then pip install -e ".[dev]" || pip install -e . || true; fi

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 | 🟠 Major | ⚡ Quick win

Do not swallow editable-install failures.

Line 33 ends with || true, so packaging/dependency failures can be ignored and CI can pass incorrectly. Let this step fail when both editable installs fail.

Suggested change
-          if [ -f pyproject.toml ]; then pip install -e ".[dev]" || pip install -e . || true; fi
+          if [ -f pyproject.toml ]; then pip install -e ".[dev]" || pip install -e .; fi
🤖 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/python-ci.yml at line 33, The CI step is swallowing
editable-install failures because the shell line ends with "|| true"; update the
command that runs pip editable installs (the line containing pip install -e
".[dev]" || pip install -e . || true) to remove the final "|| true" so the job
fails if both editable installs fail, ensuring installation errors are surfaced
in CI.

@Masoud-Masoori
Masoud-Masoori merged commit c8ac4e0 into main Jun 4, 2026
2 checks passed
@Masoud-Masoori
Masoud-Masoori deleted the ci/add-python-ci branch June 4, 2026 17:12
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.

1 participant