Skip to content

Conversation

@LinZhihao-723
Copy link
Member

@LinZhihao-723 LinZhihao-723 commented Oct 22, 2025

  • Rename internal rust-workspace-{fmt,clippy} tasks to cargo-workspace-{fmt,clippy}.
  • Rename RUST_{FMT,CLIPPY} parameters to CARGO_{FMT,CLIPPY}.
  • Reorder task attributes to align with the guideline.
  • Only include the toolchain task file when used.

Description

  • As the title and description (multiline) suggest.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Ensure all workflows pass.
  • Ensure lint:fix-rust and lint:check-rust both worked locally.

Summary by CodeRabbit

  • Chores

    • Removed the global toolchain include; toolchain references are now included locally and use workspace-style paths.
    • Redirected Rust compiler output to a dedicated build target directory.
  • New Features

    • Added workspace-level formatting and linting tasks to replace prior rust-specific tasks.
    • Standardized flag names for formatting and linting (RUST* → CARGO_*).
  • Tests

    • Test task now runs full workspace tests with all features in release mode.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

Removed top-level toolchains include from taskfile.yaml; added toolchains includes to taskfiles/lint.yaml and taskfiles/tests/main.yaml; replaced rust-workspace-* tasks with cargo-workspace-*; renamed lint variables from RUST_* to CARGO_*; updated task deps and cargo commands; added target-dir = "build/rust-targets" to .cargo/config.toml.

Changes

Cohort / File(s) Summary
Top-level taskfile config
taskfile.yaml
Removed the includes entry that referenced taskfiles/toolchains.yaml.
Lint taskfile and new cargo tasks
taskfiles/lint.yaml
Added toolchains include (toolchains.yaml); introduced cargo-workspace-fmt and cargo-workspace-clippy replacing rust-workspace-*; changed deps to include toolchains:rust and rust-lint-configs as applicable; renamed RUSTFMT_FLAGSCARGO_FMT_FLAGS and RUST_CLIPPY_FLAGSCARGO_CLIPPY_FLAGS; updated commands to use cargo workspace wrappers.
Tests taskfile adjustments
taskfiles/tests/main.yaml
Added ../toolchains.yaml include; changed dependency syntax from :toolchains:rusttoolchains:rust; updated test task command to run cargo test --all --all-features --release.
Cargo config
.cargo/config.toml
Added target-dir = "build/rust-targets" under the [build] section to set a custom Rust build output directory.
Public task & variable references
taskfiles/lint.yaml, taskfiles/tests/main.yaml
Updated public task references: check-rust-format/fix-rust-formatcargo-workspace-fmt; check-rust-static/fix-rust-staticcargo-workspace-clippy; updated related variable names to CARGO_*.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant TaskRunner as Task runner
  participant CargoFmt as cargo-workspace-fmt
  participant CargoClippy as cargo-workspace-clippy
  participant Toolchains as toolchains:rust

  Note over TaskRunner,CargoFmt: Formatting flow (taskfiles/lint.yaml)
  User->>TaskRunner: run check-rust-format / fix-rust-format
  TaskRunner->>CargoFmt: invoke cargo-workspace-fmt (uses CARGO_FMT_FLAGS)
  CargoFmt->>Toolchains: ensure toolchain (toolchains:rust, rust-lint-configs)
  CargoFmt->>CargoFmt: run `cargo ... fmt` with {{.CARGO_FMT_FLAGS}}
  CargoFmt-->>TaskRunner: exit status
  TaskRunner-->>User: report result

  Note over TaskRunner,CargoClippy: Linting flow (taskfiles/lint.yaml)
  User->>TaskRunner: run check-rust-static / fix-rust-static
  TaskRunner->>CargoClippy: invoke cargo-workspace-clippy (uses CARGO_CLIPPY_FLAGS)
  CargoClippy->>Toolchains: ensure toolchain (toolchains:rust)
  CargoClippy->>CargoClippy: run `cargo ... clippy` with {{.CARGO_CLIPPY_FLAGS}}
  CargoClippy-->>TaskRunner: exit status
  TaskRunner-->>User: report result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check for any remaining RUST_* variable usages across taskfiles.
  • Verify include path correctness and dependency syntax (toolchains:rust) in changed taskfiles.
  • Confirm cargo invocations and that adding target-dir in .cargo/config.toml doesn't conflict with CI or other tooling.

Possibly related issues

Pre-merge checks and finishing touches

✅ 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 clearly and concisely describes the main change: refactoring Rust lint tasks with a reference to the issue being fixed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between becbc71 and d532f48.

📒 Files selected for processing (3)
  • .cargo/config.toml (1 hunks)
  • taskfile.yaml (0 hunks)
  • taskfiles/lint.yaml (2 hunks)
💤 Files with no reviewable changes (1)
  • taskfile.yaml
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: junhaoliao
Repo: y-scope/clp PR: 0
File: :0-0
Timestamp: 2025-10-22T21:02:31.113Z
Learning: Repository y-scope/clp: Maintain deterministic CI/builds for Rust; add a check to verify Cargo.lock is in sync with Cargo.toml without updating dependencies (non-mutating verification in clp-rust-checks workflow).
Learnt from: junhaoliao
Repo: y-scope/clp PR: 0
File: :0-0
Timestamp: 2025-10-22T21:01:31.391Z
Learning: In y-scope/clp, for the clp-rust-checks workflow (GitHub Actions) and the Taskfile target deps:lock:check-rust, we should verify Rust Cargo.lock is in sync with Cargo.toml using a non-mutating method (e.g., cargo metadata --locked / cargo check --locked) to keep CI deterministic and avoid updating dependencies during validation.
Learnt from: junhaoliao
Repo: y-scope/clp PR: 1466
File: .github/workflows/clp-rust-checks.yaml:14-15
Timestamp: 2025-10-22T21:14:12.225Z
Learning: Repository y-scope/clp: In GitHub Actions workflows (e.g., .github/workflows/clp-rust-checks.yaml), YAML anchors/aliases are acceptable and preferred to avoid duplication; if actionlint flags an alias node (e.g., on push.paths) as an error, treat it as a tool limitation and do not require inlining unless the team asks to silence the warning.
Learnt from: Bill-hbrhbr
Repo: y-scope/clp PR: 1156
File: components/core/CMakeLists.txt:772-772
Timestamp: 2025-08-09T04:07:27.083Z
Learning: In the CLP project's CMakeLists.txt, when reviewing changes related to the ${zstd_TARGET} variable usage in test linking, the team is planning a refactoring PR to improve this mechanism. Guards for undefined target variables should be deferred to that separate PR rather than being added in focused dependency migration PRs.
Learnt from: Bill-hbrhbr
Repo: y-scope/clp PR: 1122
File: components/core/src/clp/clp/CMakeLists.txt:175-195
Timestamp: 2025-07-23T09:54:45.185Z
Learning: In the CLP project, when reviewing CMakeLists.txt changes that introduce new compression library dependencies (BZip2, LibLZMA, LZ4, ZLIB), the team prefers to address conditional linking improvements in separate PRs rather than expanding the scope of focused migration PRs like the LibArchive task-based installation migration.
Learnt from: LinZhihao-723
Repo: y-scope/clp PR: 549
File: components/core/tests/test-ir_encoding_methods.cpp:1180-1186
Timestamp: 2024-10-08T15:52:50.753Z
Learning: In the context of loop constructs, LinZhihao-723 prefers using `while (true)` loops and does not consider alternative loop constructs necessarily more readable.
Learnt from: LinZhihao-723
Repo: y-scope/clp PR: 549
File: components/core/tests/test-ir_encoding_methods.cpp:1180-1186
Timestamp: 2024-10-01T07:59:11.208Z
Learning: In the context of loop constructs, LinZhihao-723 prefers using `while (true)` loops and does not consider alternative loop constructs necessarily more readable.
📚 Learning: 2025-10-22T21:01:31.391Z
Learnt from: junhaoliao
Repo: y-scope/clp PR: 0
File: :0-0
Timestamp: 2025-10-22T21:01:31.391Z
Learning: In y-scope/clp, for the clp-rust-checks workflow (GitHub Actions) and the Taskfile target deps:lock:check-rust, we should verify Rust Cargo.lock is in sync with Cargo.toml using a non-mutating method (e.g., cargo metadata --locked / cargo check --locked) to keep CI deterministic and avoid updating dependencies during validation.

Applied to files:

  • taskfiles/lint.yaml
📚 Learning: 2025-10-22T21:02:31.113Z
Learnt from: junhaoliao
Repo: y-scope/clp PR: 0
File: :0-0
Timestamp: 2025-10-22T21:02:31.113Z
Learning: Repository y-scope/clp: Maintain deterministic CI/builds for Rust; add a check to verify Cargo.lock is in sync with Cargo.toml without updating dependencies (non-mutating verification in clp-rust-checks workflow).

Applied to files:

  • taskfiles/lint.yaml
📚 Learning: 2025-08-25T00:45:05.464Z
Learnt from: junhaoliao
Repo: y-scope/clp PR: 1242
File: components/core/tools/scripts/lib_install/ubuntu-jammy/install-prebuilt-packages.sh:39-41
Timestamp: 2025-08-25T00:45:05.464Z
Learning: Task v3.44.1 has a regression that breaks shell command processing, particularly rsync commands with brace expansion (e.g., `file.{d.ts,js,wasm}`). This causes CI failures in clp-ffi-js project (issue #110), so CLP should avoid v3.44.1 and use v3.44.0 instead, which fixes the dynamic variable bug without the shell processing regression.

Applied to files:

  • taskfiles/lint.yaml
📚 Learning: 2025-10-22T21:14:12.225Z
Learnt from: junhaoliao
Repo: y-scope/clp PR: 1466
File: .github/workflows/clp-rust-checks.yaml:14-15
Timestamp: 2025-10-22T21:14:12.225Z
Learning: Repository y-scope/clp: In GitHub Actions workflows (e.g., .github/workflows/clp-rust-checks.yaml), YAML anchors/aliases are acceptable and preferred to avoid duplication; if actionlint flags an alias node (e.g., on push.paths) as an error, treat it as a tool limitation and do not require inlining unless the team asks to silence the warning.

Applied to files:

  • taskfiles/lint.yaml
📚 Learning: 2025-10-17T19:59:35.299Z
Learnt from: junhaoliao
Repo: y-scope/clp PR: 1178
File: components/clp-package-utils/clp_package_utils/controller.py:757-757
Timestamp: 2025-10-17T19:59:35.299Z
Learning: In the y-scope/clp repository, prefer long-form command-line flags (e.g., `--recursive`) over short-form flags (e.g., `-R`) for readability, even if the long form is GNU-specific.

Applied to files:

  • taskfiles/lint.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). (18)
  • GitHub Check: centos-stream-9-static-linked-bins
  • GitHub Check: centos-stream-9-dynamic-linked-bins
  • GitHub Check: manylinux_2_28-x86_64-dynamic-linked-bins
  • GitHub Check: manylinux_2_28-x86_64-static-linked-bins
  • GitHub Check: musllinux_1_2-x86_64-dynamic-linked-bins
  • GitHub Check: package-image
  • GitHub Check: musllinux_1_2-x86_64-static-linked-bins
  • GitHub Check: ubuntu-jammy-dynamic-linked-bins
  • GitHub Check: ubuntu-jammy-static-linked-bins
  • GitHub Check: ubuntu-jammy-lint
  • GitHub Check: build-macos (macos-15, false)
  • GitHub Check: build-macos (macos-14, true)
  • GitHub Check: build-macos (macos-14, false)
  • GitHub Check: rust-checks (ubuntu-22.04)
  • GitHub Check: rust-checks (ubuntu-24.04)
  • GitHub Check: rust-checks (macos-15)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)
🔇 Additional comments (3)
.cargo/config.toml (1)

7-7: LGTM. This configuration change aligns with the PR objectives and resolves the earlier discussion about centralizing build output.

taskfiles/lint.yaml (2)

3-4: ✅ Toolchains include now properly scoped. Adding the includes entry here resolves the prior critical issue where the toolchains namespace wasn't available in this file.


800-823: ✅ Task references and parameters renamed correctly. The refactoring from rust-workspace-* to cargo-workspace-* and from RUST_*_FLAGS to CARGO_*_FLAGS is applied consistently across all public lint tasks.


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.

@LinZhihao-723 LinZhihao-723 marked this pull request as ready for review October 22, 2025 21:40
@LinZhihao-723 LinZhihao-723 requested a review from a team as a code owner October 22, 2025 21:40
@LinZhihao-723 LinZhihao-723 changed the title refactor(taskfile): Refactor Rust lint tasks: refactor(taskfile): Refactor Rust lint tasks (fixes #1451): Oct 22, 2025
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: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b059fa0 and 47c4924.

📒 Files selected for processing (2)
  • taskfile.yaml (0 hunks)
  • taskfiles/lint.yaml (3 hunks)
💤 Files with no reviewable changes (1)
  • taskfile.yaml
🔇 Additional comments (4)
taskfiles/lint.yaml (4)

802-802: Rename looks good; flags variable updated.

Swapping to cargo-workspace-fmt and CARGO_FMT_FLAGS aligns with the refactor. No issues spotted in this call site.

Also applies to: 804-804


814-814: Clippy warnings gating is correct.

-- -D warnings is passed through properly. Consider adding --workspace (see below) to ensure full coverage.

Also applies to: 816-816


820-820: Fix task flags are cargo‑side; OK.

--fix --allow-dirty --allow-staged are correctly on the cargo side; no clippy args required.

Also applies to: 822-822


800-823: No remnants of old task names or vars; wrapper aliases are not needed.

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)
taskfiles/tests/main.yaml (1)

12-13: Guard sourcing $HOME/.cargo/env and verify --release usage
Use a file check to avoid failing when the env file is missing, and confirm that running tests with --release (which disables debug assertions) is intentional.

-      . "$HOME/.cargo/env"
+      [ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 47c4924 and 6b17825.

📒 Files selected for processing (1)
  • taskfiles/tests/main.yaml (1 hunks)
⏰ 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). (16)
  • GitHub Check: musllinux_1_2-x86_64-dynamic-linked-bins
  • GitHub Check: package-image
  • GitHub Check: ubuntu-jammy-lint
  • GitHub Check: musllinux_1_2-x86_64-static-linked-bins
  • GitHub Check: ubuntu-jammy-dynamic-linked-bins
  • GitHub Check: ubuntu-jammy-static-linked-bins
  • GitHub Check: manylinux_2_28-x86_64-dynamic-linked-bins
  • GitHub Check: manylinux_2_28-x86_64-static-linked-bins
  • GitHub Check: centos-stream-9-dynamic-linked-bins
  • GitHub Check: centos-stream-9-static-linked-bins
  • GitHub Check: build-macos (macos-15, true)
  • GitHub Check: build-macos (macos-14, true)
  • GitHub Check: build-macos (macos-15, false)
  • GitHub Check: rust-checks (macos-15)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)
🔇 Additional comments (1)
taskfiles/tests/main.yaml (1)

5-5: Verify include path and rust task definition

Confirm that the toolchains: "../toolchains.yaml" entry in taskfiles/tests/main.yaml correctly resolves to taskfiles/toolchains.yaml and that this file defines a rust task.

tasks:
rust-all:
deps: [":toolchains:rust"]
deps: ["toolchains:rust"]
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Good fix on namespaced dep; consider object form for clarity.

String form works; object form reads better and avoids quoting/linters nitpicks.

-    deps: ["toolchains:rust"]
+    deps:
+      - task: toolchains:rust
📝 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
deps: ["toolchains:rust"]
deps:
- task: toolchains:rust
🤖 Prompt for AI Agents
In taskfiles/tests/main.yaml around line 9, the dependency is declared as a
namespaced string deps: ["toolchains:rust"]; change it to the object form (e.g.,
deps: [{ name: "toolchains", tool: "rust" }] or whatever project convention
requires) to improve readability and avoid quoting/linter issues; update the
YAML to use the agreed object keys for namespaced deps and run the linter to
confirm formatting.

Copy link
Member

Choose a reason for hiding this comment

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

it seems a target directory is generated at the project root for build cache. shall we add the directory to .gitignore or set CARGO_TARGET_DIR to somewhere within build/?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure we can set it under build

Copy link
Member Author

Choose a reason for hiding this comment

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

Writing to build/rust-targets

Copy link
Contributor

@Bill-hbrhbr Bill-hbrhbr left a comment

Choose a reason for hiding this comment

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

nothing major

Comment on lines 842 to +843
. "$HOME/.cargo/env"
cargo +nightly fmt --all -- {{.RUSTFMT_FLAGS}}
cargo +nightly fmt --all -- {{.CARGO_FMT_FLAGS}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
. "$HOME/.cargo/env"
cargo +nightly fmt --all -- {{.RUSTFMT_FLAGS}}
cargo +nightly fmt --all -- {{.CARGO_FMT_FLAGS}}
"$HOME/.cargo/bin/cargo" +nightly fmt --all -- {{.CARGO_FMT_FLAGS}}

Not really important but does this work? If so and you'd like to update, there are plenty other similar cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

Prefer the current way as this is not just a binary call. It could set up some env variables that have side effects.

Copy link
Member

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

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

lgtm

shall we mention that the target-dir is now changed as "build/rust-targets" in the PR description / title?

"-Dclippy::nursery",
"-Dclippy::pedantic",
]
target-dir = "build/rust-targets"
Copy link
Member

Choose a reason for hiding this comment

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

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.

3 participants