X Tutup
Skip to content

Use matrix for cargo check#7388

Open
ShaharNaveh wants to merge 3 commits intoRustPython:mainfrom
ShaharNaveh:ci-matrix-cargo-check
Open

Use matrix for cargo check#7388
ShaharNaveh wants to merge 3 commits intoRustPython:mainfrom
ShaharNaveh:ci-matrix-cargo-check

Conversation

@ShaharNaveh
Copy link
Contributor

@ShaharNaveh ShaharNaveh commented Mar 9, 2026

Summary by CodeRabbit

  • Chores
    • Reduced Linux dependency footprint by installing only essential packages (avoids recommending extras).
    • Added additional cross-compilation runtime/dev packages for ARM64 targets when needed.
    • Restructured CI to use a unified, matrix-driven compilation check across platforms, reducing duplication and improving consistency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

Replaced per-target CI steps with a matrix-driven cargo_check workflow and updated the Linux dependency installer action to use --no-install-recommends and add arm64 cross-tool packages when cross-tool input is enabled.

Changes

Cohort / File(s) Summary
Linux Dependencies Installation Action
​.github/actions/install-linux-deps/action.yml
apt-get install now runs with --no-install-recommends; when gcc-aarch64-linux-gnu input is true, added linux-libc-dev-arm64-cross and libc6-dev-arm64-cross to the package list.
CI Workflow Restructuring
​.github/workflows/ci.yaml
Replaced many per-target prepare/check steps with a matrix-driven cargo_check job that iterates targets; consolidated checkout, toolchain, cache, conditional Android NDK setup, dynamic Linux deps install, and a single multi-target cargo check loop.

Sequence Diagram(s)

sequenceDiagram
    participant Runner as GitHub Runner
    participant Action as install-linux-deps Action
    participant Apt as apt-get
    participant Rust as rustup / toolchain
    participant Cache as action/cache
    participant Cargo as cargo check
    participant NDK as Android NDK (conditional)

    Runner->>Action: invoke with inputs (maybe gcc-aarch64-linux-gnu)
    Action->>Apt: apt-get install --no-install-recommends (add arm64 cross pkgs if input=true)
    Runner->>Rust: setup toolchain and add targets
    Runner->>Cache: restore/save cargo cache
    alt Android target present
        Runner->>NDK: setup Android NDK
    end
    Runner->>Cargo: loop over matrix targets -> cargo check (per-target env)
    Cargo-->>Runner: check results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

"🐰 Hopped into workflows, trimmed installs lean and neat,

Cross-tools in my satchel for an arm64 feat.
One matrix to check them, tidy targets align,
I nibble redundant steps — CI runs just fine! 🥕"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Use matrix for cargo check' directly and clearly summarizes the main change: replacing scattered per-target build steps with a unified matrix-driven cargo check workflow.
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
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yaml:
- Around line 197-229: The Install dependencies step uses a scalar expression
for with: (with: ${{ matrix.dependencies || fromJSON('{}') }}) which violates
GitHub Actions schema; change the with: to an explicit mapping of the action
inputs (the boolean flags) instead of a single scalar. Update the step that uses
./.github/actions/install-linux-deps so its with: lists each dependency key as a
mapping entry (e.g., gcc-multilib, musl-tools, gcc-aarch64-linux-gnu) and set
each value to a safe expression that reads the matrix entry with a default
(e.g., ${{ matrix.dependencies.gcc-multilib || false }}), ensuring every
possible dependency key in the matrix is represented as a boolean input.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 81db98f2-101c-44e3-9ba0-013dbad11b83

📥 Commits

Reviewing files that changed from the base of the PR and between 82e9b5d and 7501452.

📒 Files selected for processing (2)
  • .github/actions/install-linux-deps/action.yml
  • .github/workflows/ci.yaml

Comment on lines +197 to +229
include:
- os: ubuntu-latest
targets:
- aarch64-linux-android
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- wasm32-wasip2
- x86_64-unknown-freebsd
dependencies:
gcc-multilib: true
musl-tools: true
- os: ubuntu-latest
targets:
- aarch64-unknown-linux-gnu
dependencies:
gcc-aarch64-linux-gnu: true # conflict with `gcc-multilib`
- os: macos-latest
targets:
- aarch64-apple-ios
- x86_64-apple-darwin
fail-fast: false
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
target: i686-unknown-linux-gnu
persist-credentials: false

- name: Install gcc-multilib and musl-tools
uses: ./.github/actions/install-linux-deps
- uses: Swatinem/rust-cache@v2
with:
gcc-multilib: true
musl-tools: true
prefix-key: v0-rust-${{ join(matrix.targets, '-') }}

- name: Check compilation for x86 32bit
run: cargo check --target i686-unknown-linux-gnu ${{ env.CARGO_ARGS_NO_SSL }}
- name: Install dependencies
uses: ./.github/actions/install-linux-deps
with: ${{ matrix.dependencies || fromJSON('{}') }}
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

🧩 Analysis chain

🏁 Script executed:

# Find and examine the install-linux-deps action
fd -t f "install-linux-deps" --type d

Repository: RustPython/RustPython

Length of output: 47


🏁 Script executed:

# List the contents of the install-linux-deps action directory
git ls-files ".github/actions/install-linux-deps/"

Repository: RustPython/RustPython

Length of output: 110


🏁 Script executed:

# Read the install-linux-deps action.yml to see its inputs
cat ".github/actions/install-linux-deps/action.yml"

Repository: RustPython/RustPython

Length of output: 1730


🏁 Script executed:

# Also check the install-macos-deps for comparison (mentioned in the learning)
cat ".github/actions/install-macos-deps/action.yml"

Repository: RustPython/RustPython

Length of output: 1579


🏁 Script executed:

# Read the current ci.yaml workflow to see the exact line 229 context
sed -n '190,235p' ".github/workflows/ci.yaml"

Repository: RustPython/RustPython

Length of output: 1453


Fix the schema violation: with: must be a mapping, not a scalar expression.

Line 229 passes a scalar expression where GitHub Actions requires an explicit mapping. Flatten the matrix flags into individual booleans and bind each action input explicitly.

Proposed fix
       matrix:
         include:
         - os: ubuntu-latest
           targets:
             - aarch64-linux-android
             - i686-unknown-linux-gnu
             - i686-unknown-linux-musl
             - wasm32-wasip2
             - x86_64-unknown-freebsd
-          dependencies:
-            gcc-multilib: true
-            musl-tools: true
+          gcc_multilib: true
+          musl_tools: true
         - os: ubuntu-latest
           targets:
             - aarch64-unknown-linux-gnu
-          dependencies:
-            gcc-aarch64-linux-gnu: true # conflict with `gcc-multilib`
+          gcc_aarch64_linux_gnu: true # conflict with `gcc-multilib`
         - os: macos-latest
           targets:
             - aarch64-apple-ios
             - x86_64-apple-darwin
       fail-fast: false
...
       - name: Install dependencies
+        if: runner.os == 'Linux'
         uses: ./.github/actions/install-linux-deps
-        with: ${{ matrix.dependencies || fromJSON('{}') }}
+        with:
+          gcc-multilib: ${{ matrix.gcc_multilib || false }}
+          musl-tools: ${{ matrix.musl_tools || false }}
+          clang: ${{ matrix.clang || false }}
+          gcc-aarch64-linux-gnu: ${{ matrix.gcc_aarch64_linux_gnu || 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
include:
- os: ubuntu-latest
targets:
- aarch64-linux-android
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- wasm32-wasip2
- x86_64-unknown-freebsd
dependencies:
gcc-multilib: true
musl-tools: true
- os: ubuntu-latest
targets:
- aarch64-unknown-linux-gnu
dependencies:
gcc-aarch64-linux-gnu: true # conflict with `gcc-multilib`
- os: macos-latest
targets:
- aarch64-apple-ios
- x86_64-apple-darwin
fail-fast: false
steps:
- uses: actions/checkout@v6.0.2
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
target: i686-unknown-linux-gnu
persist-credentials: false
- name: Install gcc-multilib and musl-tools
uses: ./.github/actions/install-linux-deps
- uses: Swatinem/rust-cache@v2
with:
gcc-multilib: true
musl-tools: true
prefix-key: v0-rust-${{ join(matrix.targets, '-') }}
- name: Check compilation for x86 32bit
run: cargo check --target i686-unknown-linux-gnu ${{ env.CARGO_ARGS_NO_SSL }}
- name: Install dependencies
uses: ./.github/actions/install-linux-deps
with: ${{ matrix.dependencies || fromJSON('{}') }}
include:
- os: ubuntu-latest
targets:
- aarch64-linux-android
- i686-unknown-linux-gnu
- i686-unknown-linux-musl
- wasm32-wasip2
- x86_64-unknown-freebsd
gcc_multilib: true
musl_tools: true
- os: ubuntu-latest
targets:
- aarch64-unknown-linux-gnu
gcc_aarch64_linux_gnu: true # conflict with `gcc-multilib`
- os: macos-latest
targets:
- aarch64-apple-ios
- x86_64-apple-darwin
fail-fast: false
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0-rust-${{ join(matrix.targets, '-') }}
- name: Install dependencies
if: runner.os == 'Linux'
uses: ./.github/actions/install-linux-deps
with:
gcc-multilib: ${{ matrix.gcc_multilib || false }}
musl-tools: ${{ matrix.musl_tools || false }}
clang: ${{ matrix.clang || false }}
gcc-aarch64-linux-gnu: ${{ matrix.gcc_aarch64_linux_gnu || false }}
🧰 Tools
🪛 actionlint (1.7.11)

[error] 229-229: "with" section is scalar node but mapping node is expected

(syntax-check)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yaml around lines 197 - 229, The Install dependencies
step uses a scalar expression for with: (with: ${{ matrix.dependencies ||
fromJSON('{}') }}) which violates GitHub Actions schema; change the with: to an
explicit mapping of the action inputs (the boolean flags) instead of a single
scalar. Update the step that uses ./.github/actions/install-linux-deps so its
with: lists each dependency key as a mapping entry (e.g., gcc-multilib,
musl-tools, gcc-aarch64-linux-gnu) and set each value to a safe expression that
reads the matrix entry with a default (e.g., ${{
matrix.dependencies.gcc-multilib || false }}), ensuring every possible
dependency key in the matrix is represented as a boolean input.

- name: Check compilation for wasip2
run: cargo check --target wasm32-wasip2 ${{ env.CARGO_ARGS_NO_SSL }}

# - name: Prepare repository for redox compilation
Copy link
Member

Choose a reason for hiding this comment

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

where should redox to be put?

Copy link
Contributor Author

@ShaharNaveh ShaharNaveh Mar 9, 2026

Choose a reason for hiding this comment

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

In one of the target groups. I can try to do in a separate PR. this PR isn't meant to change existing behavior.

I assume we will have a special condition for it like we do in the setup-ndk step

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.

♻️ Duplicate comments (1)
.github/workflows/ci.yaml (1)

227-229: ⚠️ Potential issue | 🔴 Critical

Fix the Install dependencies step shape and scope.

Line 229 is invalid GitHub Actions syntax: with: must be a mapping, so this job will not pass workflow validation. Even after that is fixed, this step still runs for the macos-latest row even though it invokes the Linux-only install-linux-deps action.

One working shape
       matrix:
         include:
         - os: ubuntu-latest
           targets:
             - aarch64-linux-android
             - i686-unknown-linux-gnu
             - i686-unknown-linux-musl
             - wasm32-wasip2
             - x86_64-unknown-freebsd
-          dependencies:
-            gcc-multilib: true
-            musl-tools: true
+          gcc_multilib: true
+          musl_tools: true
         - os: ubuntu-latest
           targets:
             - aarch64-unknown-linux-gnu
-          dependencies:
-            gcc-aarch64-linux-gnu: true # conflict with `gcc-multilib`
+          gcc_aarch64_linux_gnu: true # conflict with `gcc-multilib`
         - os: macos-latest
           targets:
             - aarch64-apple-ios
             - x86_64-apple-darwin
...
       - name: Install dependencies
+        if: runner.os == 'Linux'
         uses: ./.github/actions/install-linux-deps
-        with: ${{ matrix.dependencies || fromJSON('{}') }}
+        with:
+          gcc-multilib: ${{ matrix.gcc_multilib || false }}
+          musl-tools: ${{ matrix.musl_tools || false }}
+          clang: ${{ matrix.clang || false }}
+          gcc-aarch64-linux-gnu: ${{ matrix.gcc_aarch64_linux_gnu || false }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yaml around lines 227 - 229, The "Install dependencies"
step uses invalid YAML for the with: field and also unconditionally invokes the
Linux-only action ./.github/actions/install-linux-deps for non-Linux matrix
rows; change the step to provide a proper mapping for the inputs (e.g., a key
like dependencies mapped to the expression using matrix.dependencies) and add a
conditional that restricts the step to Linux matrix entries (use matrix.os in
the if: expression) so the step only runs for Linux jobs and the with: block is
valid.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/ci.yaml:
- Around line 227-229: The "Install dependencies" step uses invalid YAML for the
with: field and also unconditionally invokes the Linux-only action
./.github/actions/install-linux-deps for non-Linux matrix rows; change the step
to provide a proper mapping for the inputs (e.g., a key like dependencies mapped
to the expression using matrix.dependencies) and add a conditional that
restricts the step to Linux matrix entries (use matrix.os in the if: expression)
so the step only runs for Linux jobs and the with: block is valid.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 68bac21c-80f5-4e72-a059-13705ac74f77

📥 Commits

Reviewing files that changed from the base of the PR and between 7501452 and 3eaa342.

📒 Files selected for processing (1)
  • .github/workflows/ci.yaml

@ShaharNaveh ShaharNaveh requested a review from youknowone March 10, 2026 08:22
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

X Tutup