Skip to content

chore: avoid multiple rustup installation#1571

Merged
colinaaa merged 2 commits intolynx-family:mainfrom
colinaaa:colin/0820/cargo-version
Aug 20, 2025
Merged

chore: avoid multiple rustup installation#1571
colinaaa merged 2 commits intolynx-family:mainfrom
colinaaa:colin/0820/cargo-version

Conversation

@colinaaa
Copy link
Copy Markdown
Collaborator

@colinaaa colinaaa commented Aug 20, 2025

Summary by CodeRabbit

  • Chores
    • Updated build configuration to account for Rust/Cargo toolchain changes, ensuring WASM-related builds automatically re-run when the toolchain updates.
    • Standardized repository configuration to the latest schema for improved compatibility.
    • Added an internal script to surface the Rust/Cargo version for build orchestration.

No user-facing behavior changes; these updates improve build reliability and consistency across environments.

This is used to avoid downloading Rust toolchain in parallel, which could cause error.

See: https://github.com/lynx-family/lynx-stack/actions/runs/17091970609/job/48467545202?pr=1569

Note

We would run turbo build first on CI. And if no cache hit for cargo build tasks, we would setup Rust toolchain and re-run build again.

But this is a little different with the Windows runner. Since there are cargo and rustup on the Windows runner, we would start downloading Rust toolchain in parallel in the first turbo build.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Aug 20, 2025

⚠️ No Changeset found

Latest commit: 2885958

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 20, 2025

📝 Walkthrough

Walkthrough

Introduces an internal Cargo version task to the Turborepo config and wires it as a dependency for wasm-related build tasks in package subprojects. Also adds an npm script to print Cargo’s version and updates the top-level Turbo schema reference.

Changes

Cohort / File(s) Summary of edits
Root Turbo config
turbo.json
Updated $schema URL; added task //#_internal:cargo:version with env GITHUB_SHA, inputs rust-toolchain*, no deps/outputs.
Package Turbo dependsOn updates
packages/react/transform/turbo.json, packages/web-platform/web-style-transformer/turbo.json
Added dependsOn entry //#_internal:cargo:version to gate wasm/build tasks on Cargo version.
NPM script addition
package.json
Added script _internal:cargo:version: cargo --version.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

platform:Web, framework:React

Suggested reviewers

  • PupilTong

Poem

I tapped my paw, checked Cargo’s tune,
A version hop beneath the moon.
Turbo hums, the wasm wakes,
Dependencies aligned like cakes.
I thump—approved!—with gentle might,
Build hops clean into the night. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@relativeci
Copy link
Copy Markdown

relativeci bot commented Aug 20, 2025

React Example

#4416 Bundle Size — 237.07KiB (0%).

2885958(current) vs cf46821 main#4413(baseline)

Bundle metrics  no changes
                 Current
#4416
     Baseline
#4413
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 158 158
No change  Duplicate Modules 64 64
No change  Duplicate Code 45.86% 45.86%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#4416
     Baseline
#4413
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.31KiB 91.31KiB

Bundle analysis reportBranch colinaaa:colin/0820/cargo-versio...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Aug 20, 2025

Web Explorer

#4409 Bundle Size — 366.68KiB (0%).

2885958(current) vs cf46821 main#4406(baseline)

Bundle metrics  Change 1 change
                 Current
#4409
     Baseline
#4406
No change  Initial JS 143.49KiB 143.49KiB
No change  Initial CSS 31.84KiB 31.84KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 7 7
No change  Assets 7 7
Change  Modules 211(-0.47%) 212
No change  Duplicate Modules 17 17
No change  Duplicate Code 3.89% 3.89%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#4409
     Baseline
#4406
No change  JS 234.68KiB 234.68KiB
No change  Other 100.16KiB 100.16KiB
No change  CSS 31.84KiB 31.84KiB

Bundle analysis reportBranch colinaaa:colin/0820/cargo-versio...Project dashboard


Generated by RelativeCIDocumentationReport issue

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Aug 20, 2025

CodSpeed Performance Report

Merging #1571 will not alter performance

Comparing colinaaa:colin/0820/cargo-version (2885958) with main (f66e319)

Summary

✅ 10 untouched benchmarks

@colinaaa colinaaa marked this pull request as ready for review August 20, 2025 09:18
@colinaaa colinaaa requested a review from PupilTong as a code owner August 20, 2025 09:18
Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (3)
package.json (1)

10-10: Make the cargo gate tolerant when Cargo isn’t installed (first pass on Linux/macOS).

On runners where Rust isn’t preinstalled (your “first turbo build” before toolchain setup), cargo --version will exit with ENOENT and fail the dependency, potentially breaking the initial pass even when a remote cache would otherwise skip Rust builds. Consider either making the script a no-op when Cargo is absent, or ensuring Rust is installed before this task runs on non-Windows matrices.

Two options:

  • CI-side: install/setup Rust before the first Turborepo pass on non-Windows runners.
  • Script-side: make this resilient to missing Cargo.

Example (resilient script) — optional approach using Node to avoid shell portability issues on Windows:

-    "_internal:cargo:version": "cargo --version",
+    "_internal:cargo:version": "node -e \"const {spawn}=require('node:child_process'); const bin=process.platform==='win32'?'cargo.exe':'cargo'; const p=spawn(bin,['--version'],{stdio:'inherit'}); p.on('error',()=>process.exit(0)); p.on('exit',code=>process.exit(code));\"",

This still triggers a Rust toolchain install where present (due to rust-toolchain override), but won’t fail on hosts without Cargo.

Can you confirm whether your initial “turbo build” runs on Linux/macOS before Rust is installed? If yes, one of the above mitigations is recommended.

turbo.json (1)

2-2: Schema URL inconsistency across the repo.

Root uses https://turborepo.com/schema.json, while package turbo files still point to https://turbo.build/schema.json. Functionally they’re equivalent today, but it’s better to standardize to one URL across the repo to avoid confusion and IDE lint diffs.

packages/react/transform/turbo.json (1)

10-12: LGTM: wasm build depends on Cargo version gate; consider adding it to other Rust-heavy tasks too.

build:wasm is correctly gated. Given build:debug also references Rust inputs, consider making it depend on //#_internal:cargo:version to avoid any chance of parallel rustup when that task runs in CI.

Apply within this file if you want to gate build:debug as well:

   "build:debug": {
-    "inputs": ["src/**/*.rs", "build.rs", "Cargo.toml"],
+    "dependsOn": ["//#_internal:cargo:version"],
+    "inputs": ["src/**/*.rs", "build.rs", "Cargo.toml"],
     "outputs": ["index.d.ts", "index.cjs", "*.node"]
   },

Also confirm that all packages which run Cargo have been updated to depend on the internal gate.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f66e319 and 2885958.

📒 Files selected for processing (4)
  • package.json (1 hunks)
  • packages/react/transform/turbo.json (1 hunks)
  • packages/web-platform/web-style-transformer/turbo.json (1 hunks)
  • turbo.json (2 hunks)
🔇 Additional comments (2)
turbo.json (1)

28-36: Good approach to serialize Rust toolchain initialization; verify cache semantics with GITHUB_SHA.

  • Defining //#_internal:cargo:version with inputs on rust-toolchain* and wiring dependents to it should ensure a single, serialized toolchain install via cargo --version.
  • Including env: ["GITHUB_SHA"] forces this task to be a cache miss each commit, which is useful to trigger toolchain presence even when downstream tasks are fully cached. That said, it also means this task always executes locally on every commit.

Action items:

  • Confirm the always-execute behavior is intended. If it’s too chatty locally, you could scope this behavior to CI (e.g., set an env like CARGO_VERSION_GATE_NO_CACHE=1 in CI and list that env instead, or drop GITHUB_SHA and rely solely on rust-toolchain* inputs).
  • Ensure the corresponding root script exists (it does in package.json) and is resilient where Cargo isn’t present (see package.json comment).

No change required if the current behavior is desired; just verify the CI implications.

packages/web-platform/web-style-transformer/turbo.json (1)

7-9: No additional Rust-invoking tasks in web-style-transformer
I ran the audit across packages/web-platform/web-style-transformer/turbo.json and found only build:wasm-bindgen reads Rust inputs. The new dependency on //#_internal:cargo:version already covers all Rust usages here—no further changes needed.

@colinaaa colinaaa merged commit d4fd6cb into lynx-family:main Aug 20, 2025
94 of 98 checks passed
@colinaaa colinaaa deleted the colin/0820/cargo-version branch August 20, 2025 09:37
@coderabbitai coderabbitai bot mentioned this pull request Aug 27, 2025
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Sep 10, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants