Skip to content

fix: resolve tox failures for missing Python interpreters - #84

Open
mkanoor wants to merge 1 commit into
ansible:mainfrom
mkanoor:fix-tox-missing-interpreters
Open

fix: resolve tox failures for missing Python interpreters#84
mkanoor wants to merge 1 commit into
ansible:mainfrom
mkanoor:fix-tox-missing-interpreters

Conversation

@mkanoor

@mkanoor mkanoor commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

This fixes the issue where tox would fail when it couldn't find all Python interpreters in the CI environment. The problem occurred because tox was configured to test against py39, py310, py311, and py312, but each CI matrix job only has one Python version installed.

Changes:

  • Add tox-gh-actions package to workflow dependencies to enable environment mapping based on the current Python version
  • Add skip_missing_interpreters=true to tox config as a safety net to skip rather than fail on missing interpreters

With tox-gh-actions, the [gh-actions] configuration in pyproject.toml will be respected, ensuring only the matching tox environment runs in each matrix job (e.g., py310 runs only in Python 3.10 job).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated the Python CI workflow to use the latest Python setup action.
    • Streamlined the CI pip/build upgrade step into a single consolidated command.
    • Pinned build tooling and updated version constraints for local and test/development extras.
    • Adjusted tox to skip creating environments for missing Python interpreters.
    • Updated software composition analysis (SCA) settings for the project.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes pin Python build, runtime, and optional dependencies; update CI tool versions; configure tox to skip unavailable interpreters; and modify Sonar SCA settings.

Changes

Python tooling configuration

Layer / File(s) Summary
Dependency and extras pinning
pyproject.toml
Build, runtime, local, test, and development dependencies are pinned, with Python-version-specific test dependency sets.
CI and tox execution
.github/workflows/python_package.yml, pyproject.toml
The workflow uses actions/setup-python@v7, pins pip==26.0 and build==1.2.2, and tox skips missing interpreters.
Sonar SCA settings
sonar-project.properties
Sonar enables local Python dependency resolution and disables SCA globally.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 matches the main change: fixing tox failures by skipping missing Python interpreters in CI.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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: 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/python_package.yml:
- Around line 36-38: Pin the pip, build, and tox-gh-actions dependencies in the
workflow’s installation steps, preferably by referencing a reviewed constraints
or lock file with hashes; otherwise specify reviewed exact versions. Update the
three install commands while preserving the existing upgrade/install behavior.
🪄 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: b7ec9afd-1f1f-4862-af6c-7f18ee31e8b7

📥 Commits

Reviewing files that changed from the base of the PR and between 2012229 and d40abd5.

📒 Files selected for processing (2)
  • .github/workflows/python_package.yml
  • pyproject.toml

Comment thread .github/workflows/python_package.yml Outdated
@mkanoor
mkanoor force-pushed the fix-tox-missing-interpreters branch 4 times, most recently from c53adce to 847a61e Compare July 20, 2026 20:08

@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.

🧹 Nitpick comments (1)
pyproject.toml (1)

2-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove build from the backend requirements. setuptools.build_meta doesn't need the build frontend in the isolated env, and CI already installs build==1.2.2 separately. Keep the pin outside pyproject.toml to avoid version drift.

🤖 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 `@pyproject.toml` at line 2, Remove the build==1.2.1 entry from the requires
list in pyproject.toml, leaving setuptools and jpy unchanged; retain the build
tool installation and pin in the existing CI configuration.
🤖 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.

Nitpick comments:
In `@pyproject.toml`:
- Line 2: Remove the build==1.2.1 entry from the requires list in
pyproject.toml, leaving setuptools and jpy unchanged; retain the build tool
installation and pin in the existing CI configuration.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 930c4001-2095-4ddd-9755-11c52f5ee9bd

📥 Commits

Reviewing files that changed from the base of the PR and between d40abd5 and 847a61e.

📒 Files selected for processing (2)
  • .github/workflows/python_package.yml
  • pyproject.toml

@mkanoor
mkanoor force-pushed the fix-tox-missing-interpreters branch 8 times, most recently from 32879a6 to e21ab72 Compare July 20, 2026 20:56
This fixes the issue where tox would fail when it couldn't find all
Python interpreters in the CI environment. The problem occurred because
tox was configured to test against py39, py310, py311, and py312, but
each CI matrix job only has one Python version installed.

Changes:
- Add tox-gh-actions package to workflow dependencies to enable
  environment mapping based on the current Python version
- Add skip_missing_interpreters=true to tox config as a safety net
  to skip rather than fail on missing interpreters

With tox-gh-actions, the [gh-actions] configuration in pyproject.toml
will be respected, ensuring only the matching tox environment runs in
each matrix job (e.g., py310 runs only in Python 3.10 job).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mkanoor
mkanoor force-pushed the fix-tox-missing-interpreters branch from e21ab72 to 9fe5184 Compare July 20, 2026 21:09
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

@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: 2

🤖 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_package.yml:
- Line 37: Update the dependency installation step in the workflow around the
extras passed to pip so the complete tests and dev dependency graph is resolved
through the repository’s reviewed, hash-verified constraints or lock file.
Preserve installation of both .[tests] and .[dev], and ensure every transitive
dependency is constrained rather than only pinning pip and build.

In `@pyproject.toml`:
- Around line 51-52: Remove the == 0.4.1 version pins from the self-referential
drools_jpy[local] and drools_jpy[tests] dev dependencies in pyproject.toml,
preserving their extras so local development resolves the current project
source.
🪄 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 50af5cf0-9233-4260-87a6-74f319f0baef

📥 Commits

Reviewing files that changed from the base of the PR and between 847a61e and 9fe5184.

📒 Files selected for processing (3)
  • .github/workflows/python_package.yml
  • pyproject.toml
  • sonar-project.properties

python3 -m pip install --upgrade build
python3 -m pip install .[tests] .[dev]
python3 -m pip install --upgrade pip==26.0 build==1.2.2
python3 -m pip install .[tests] .[dev] # NOSONAR - dynamic local package extras

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Lock dependencies installed through the test and development extras.

Although pip and build are pinned, pip install .[tests] .[dev] can still resolve transitive dependencies to changing index versions. Install these extras through a reviewed constraints/lock file with hashes, or otherwise lock the complete dependency graph.

As per path instructions, focus on major issues impacting performance, readability, maintainability and security.
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 37-37: Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=ansible_drools_jpy&issues=AZ-A7oHwp3bAlirjeNb2&open=AZ-A7oHwp3bAlirjeNb2&pullRequest=84

🤖 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_package.yml at line 37, Update the dependency
installation step in the workflow around the extras passed to pip so the
complete tests and dev dependency graph is resolved through the repository’s
reviewed, hash-verified constraints or lock file. Preserve installation of both
.[tests] and .[dev], and ensure every transitive dependency is constrained
rather than only pinning pip and build.

Sources: Path instructions, Linters/SAST tools

Comment thread pyproject.toml
Comment on lines +51 to +52
"drools_jpy[local] == 0.4.1",
"drools_jpy[tests] == 0.4.1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove version pins for self-referential dev dependencies.

Hardcoding the project's own version (0.4.1) here will cause dependency conflicts during local development. When the project's version is bumped in the future, running pip install -e .[dev] will either fail to resolve or incorrectly fetch the outdated 0.4.1 package from PyPI instead of using your local source code.

🐛 Proposed fix
-  "drools_jpy[local] == 0.4.1",
-  "drools_jpy[tests] == 0.4.1"
+  "drools_jpy[local]",
+  "drools_jpy[tests]"
📝 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
"drools_jpy[local] == 0.4.1",
"drools_jpy[tests] == 0.4.1"
"drools_jpy[local]",
"drools_jpy[tests]"
🤖 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 `@pyproject.toml` around lines 51 - 52, Remove the == 0.4.1 version pins from
the self-referential drools_jpy[local] and drools_jpy[tests] dev dependencies in
pyproject.toml, preserving their extras so local development resolves the
current project source.

@ptoscano

Copy link
Copy Markdown
Contributor

Hm please remove the pinning of all the requirements, otherwise it'll be a massive headache.

@mkanoor

mkanoor commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Hm please remove the pinning of all the requirements, otherwise it'll be a massive headache.

@ptoscano That'e exactly what SonarQube is asking for otherwise it drops the rating on the code.

Using dependencies without locking resolved versions is security-sensitive.
Python dependencies should be locked to verified versions [githubactions:S8544](https://sonarcloud.io/organizations/ansible/rules?open=githubactions%3AS8544&rule_key=githubactions%3AS8544)

@ptoscano

Copy link
Copy Markdown
Contributor

Hm please remove the pinning of all the requirements, otherwise it'll be a massive headache.

@ptoscano That'e exactly what SonarQube is asking for otherwise it drops the rating on the code.

Yes, I know about that: there was a similar attempt in ansible-rulebook few weeks ago. The problem is that it becomes a maintenance burden that way: you'll need to ensure that e.g. dependabot can update all of these pins, and the updates will be a lot. Especially for a repository like this one that does not get changes very often, this would create a lot of busy work. Please let's discuss this kind of change separately, as it affects also other repositories.

Also, this PR is supposed to fix the CI failure with tox, so please let's keep this focused on that only, to unblock the CI and further changes.

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.

2 participants