Skip to content

Conversation

@ShaharNaveh
Copy link
Collaborator

@ShaharNaveh ShaharNaveh commented Jan 9, 2026

Closes: #6676

Summary by CodeRabbit

  • Chores
    • Enhanced CI/CD pipelines with automated validation to ensure opcode metadata remains up-to-date during development and pull request processing, improving code quality and consistency through continuous integration checks.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Two GitHub Actions workflows are updated to include automatic opcode metadata generation: the CI linting phase now validates metadata is current, while the auto-format PR workflow executes the metadata generation script.

Changes

Cohort / File(s) Summary
Opcode Metadata Generation Workflow Integration
.github/workflows/ci.yaml, .github/workflows/pr-auto-commit.yaml
Adds opcode metadata generation to CI workflows. The ci.yaml introduces a validation step that ensures Lib/_opcode_metadata is updated and fails the build if changes are detected. The pr-auto-commit.yaml adds execution of scripts/generate_opcode_metadata.py in the auto-format pipeline.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Hoppy scripts now synchronize the bytes,
Metadata stays fresh through workflow nights,
CI checks and auto-format align,
Opcodes march in perfect design! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Ci gen opcode metadata' is vague and uses abbreviated terms ('Ci gen') that don't clearly convey the specific change, making it unclear to someone scanning PR history. Use a more descriptive title like 'Add opcode metadata generation to CI workflows' to clearly indicate the main change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR addresses the linked issue #6676 by adding the opcode metadata generation step to the auto-format workflow, and additionally adds the step to the lint CI workflow for enforcing up-to-date metadata.
Out of Scope Changes check ✅ Passed The changes are focused on CI workflow updates and opcode metadata generation as specified in the linked issue; no unrelated out-of-scope changes are present.
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.


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.

Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/pr-auto-commit.yaml (1)

66-71: Update commit message to reflect all automated changes.

The commit message mentions only cargo fmt --all, but the workflow now also runs ruff formatting and opcode metadata generation. The message should accurately describe all changes being committed.

📝 Update commit message
       - name: Commit and push formatting changes
         if: steps.check-changes.outputs.has_changes == 'true'
         run: |
           git add -u
-          git commit -m "Auto-format: cargo fmt --all"
+          git commit -m "Auto-format: cargo fmt, ruff, and opcode metadata"
           git push origin HEAD:${{ github.event.pull_request.head.ref }}
🤖 Fix all issues with AI agents
In @.github/workflows/ci.yaml:
- Around line 334-339: The CI step "Ensure Lib/_opcode_metadata is updated" has
inverted logic: it currently fails when the working tree is clean because it
uses if [ -z "$(git status --porcelain)" ] then exit 1; fix it by inverting the
test to if [ -n "$(git status --porcelain)" ] then echo a helpful message (e.g.
"Lib/_opcode_metadata out of date") and exit 1; keep running python
scripts/generate_opcode_metadata.py and use the git status --porcelain output to
decide failure so the job only fails when changes are present.
🧹 Nitpick comments (2)
.github/workflows/pr-auto-commit.yaml (1)

50-50: Add explicit Python setup step before running the script.

The workflow runs a Python script but doesn't explicitly set up Python. While ubuntu-latest includes Python by default, declaring it as a dependency makes the workflow more maintainable and self-documenting.

🐍 Add setup-python step

Add this step before line 50:

      - name: Setup Python
        uses: actions/setup-python@v6.1.0
        with:
          python-version: "3.13.1"
.github/workflows/ci.yaml (1)

334-336: Add explicit Python setup step for the lint job.

The lint job runs a Python script but doesn't set up Python. While ubuntu-latest includes Python, explicitly declaring the dependency improves workflow clarity and ensures the expected Python version is available.

🐍 Add setup-python step to lint job

Add this step before line 334:

      - name: Setup Python
        uses: actions/setup-python@v6.1.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}

This reuses the PYTHON_VERSION environment variable already defined at line 109.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c2bfdf3 and 7654bc1.

⛔ Files ignored due to path filters (1)
  • Lib/_opcode_metadata.py is excluded by !Lib/**
📒 Files selected for processing (2)
  • .github/workflows/ci.yaml
  • .github/workflows/pr-auto-commit.yaml
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-12-27T14:03:49.034Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-27T14:03:49.034Z
Learning: Applies to **/*.py : Use ruff for linting Python code

Applied to files:

  • .github/workflows/pr-auto-commit.yaml
  • .github/workflows/ci.yaml
📚 Learning: 2025-12-27T14:03:49.034Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-27T14:03:49.034Z
Learning: Applies to **/*.rs : Always run clippy to lint code (`cargo clippy`) before completing tasks and fix any warnings or lints introduced by changes

Applied to files:

  • .github/workflows/ci.yaml
📚 Learning: 2025-12-27T14:03:49.034Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-27T14:03:49.034Z
Learning: When modifying bytecode instructions, perform a full clean build by running `rm -r target/debug/build/rustpython-* && find . | grep -E '\.pyc$' | xargs rm -r`

Applied to files:

  • .github/workflows/ci.yaml
📚 Learning: 2025-12-27T14:03:49.034Z
Learnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-27T14:03:49.034Z
Learning: Applies to **/*.rs : Follow the default rustfmt code style by running `cargo fmt` to format Rust code

Applied to files:

  • .github/workflows/ci.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (windows-2025)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (windows-2025)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Check Rust code with clippy
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run tests under miri

Comment on lines +334 to +339
- name: Ensure Lib/_opcode_metadata is updated
run: |
python scripts/generate_opcode_metadata.py
if [ -z "$(git status --porcelain)" ]; then
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix inverted validation logic - critical correctness issue.

The condition checks if the working tree is clean (no changes) and exits with failure in that case. This is backwards: the check should fail when changes are detected (metadata is stale) and pass when no changes are detected (metadata is current).

Currently:

  • Metadata up-to-date (no changes) → Fails ❌
  • Metadata stale (changes detected) → Passes ❌

Expected:

  • Metadata up-to-date (no changes) → Passes ✅
  • Metadata stale (changes detected) → Fails ✅
🐛 Fix to invert the logic
       - name: Ensure Lib/_opcode_metadata is updated
         run: |
           python scripts/generate_opcode_metadata.py
-          if [ -z "$(git status --porcelain)" ]; then
+          if [ -n "$(git status --porcelain)" ]; then
+            echo "Error: Lib/_opcode_metadata is out of date. Run 'python scripts/generate_opcode_metadata.py' locally and commit the changes."
             exit 1
           fi

The fix changes -z (zero length/empty) to -n (non-zero length/not empty) and adds a helpful error message.

🤖 Prompt for AI Agents
In @.github/workflows/ci.yaml around lines 334 - 339, The CI step "Ensure
Lib/_opcode_metadata is updated" has inverted logic: it currently fails when the
working tree is clean because it uses if [ -z "$(git status --porcelain)" ] then
exit 1; fix it by inverting the test to if [ -n "$(git status --porcelain)" ]
then echo a helpful message (e.g. "Lib/_opcode_metadata out of date") and exit
1; keep running python scripts/generate_opcode_metadata.py and use the git
status --porcelain output to decide failure so the job only fails when changes
are present.

@ShaharNaveh
Copy link
Collaborator Author

It seems like I can't test it unless it's merged to main:/

@youknowone youknowone merged commit 9291178 into RustPython:main Jan 10, 2026
12 of 13 checks passed
@youknowone
Copy link
Member

Thank you so much! lets try!

terryluan12 pushed a commit to terryluan12/RustPython that referenced this pull request Jan 15, 2026
* Autogen opcode metadata

* Manually modify opcode metadata
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.

Add a step to the auto-format PR to generate the opcode metadata

2 participants