Skip to content

Use matrix for cargo check#7388

Merged
youknowone merged 4 commits intoRustPython:mainfrom
ShaharNaveh:ci-matrix-cargo-check
Mar 11, 2026
Merged

Use matrix for cargo check#7388
youknowone merged 4 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 install footprint by using non-recommending package installs to avoid extra packages.
    • Added additional ARM64 cross-compilation runtime/dev packages when cross-targeting AArch64.
    • Consolidated CI into a matrix-driven compilation check across platforms, centralizing tool/setup steps and per-target build checks to remove duplication.

@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 run apt-get install with --no-install-recommends and add arm64 cross-tool packages when the gcc-aarch64-linux-gnu input is enabled.

Changes

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

Sequence Diagram(s)

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

    Runner->>Action: invoke with inputs (e.g., gcc-aarch64-linux-gnu)
    Action->>Apt: apt-get install --no-install-recommends (add arm64 cross pkgs if input=true)
    Runner->>Toolchain: setup Rust 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: return check results
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

"🐰 I hopped through YAML, trimmed installs light,

Packed arm64 tools for a cross-compile night.
One matrix to check them, targets all in a row,
I nibbled the excess and watched the checks go. 🥕"

🚥 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: refactoring the CI workflow to use a matrix-driven approach for cargo check instead of discrete per-target invocations.
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

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/[email protected]
- 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/[email protected]
- 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
Member

Choose a reason for hiding this comment

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

redox is(was?) actually using rustpython for their python. This build was guaranteeing it is working.
I forgot when this is commented out and not fixed back, (probably redoxer action is broken) but we at least need to keep the comment to revive it later.

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

Schema violation: with: requires a mapping, not a scalar expression.

The syntax with: ${{ matrix.dependencies || fromJSON('{}') }} is invalid. GitHub Actions expects with: to contain an explicit mapping of input names to values. Additionally, this step will run on macOS where install-linux-deps is not applicable.

The fix proposed in the previous review remains valid—flatten the dependency flags to top-level matrix properties and bind them explicitly with an OS condition.

🤖 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 CI step "Install
dependencies" uses an invalid scalar for with: and is not guarded by OS; change
the step to pass a mapping (e.g. with: dependencies: ${{ matrix.dependencies }}
) and add an OS guard (if: runner.os == 'Linux') so the local action
./.github/actions/install-linux-deps only runs on Linux; also ensure your matrix
defines the top-level property matrix.dependencies (use fromJSON default when
building the matrix if needed) so the referenced matrix key exists.
🤖 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 CI step "Install dependencies" uses an invalid scalar
for with: and is not guarded by OS; change the step to pass a mapping (e.g.
with: dependencies: ${{ matrix.dependencies }} ) and add an OS guard (if:
runner.os == 'Linux') so the local action ./.github/actions/install-linux-deps
only runs on Linux; also ensure your matrix defines the top-level property
matrix.dependencies (use fromJSON default when building the matrix if needed) so
the referenced matrix key exists.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 2aaff4f0-652d-4034-a957-2a97a27a6ca8

📥 Commits

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

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

@youknowone youknowone merged commit 7e47270 into RustPython:main Mar 11, 2026
27 of 28 checks passed
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