Repository navigation
ci: run clippy for Windows and macOS too, and fix what it finds #46696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dylan-conway
wants to merge
7
commits into
main
Choose a base branch
from
claude/affectionate-einstein-lgagvb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,177
−801
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
00ff809
ci: run clippy for Windows and macOS too, and fix what it finds
claude 8152c71
Read the spawn cwd opt-out live again, and lint the standalone shim
claude ca28e7f
Clear the cwd opt-out before the spawn test's first run
claude d06cec9
test(ws-proxy): renegotiate only after the "renegotiating" frame is w…
claude 7c303e2
Merge branch 'main' into claude/affectionate-einstein-lgagvb
claude 2fa39ca
Fix the Windows and macOS clippy violations that main gained
claude 15b3fb4
Merge branch 'main' into claude/affectionate-einstein-lgagvb
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #!/usr/bin/env bun | ||
| /** | ||
| * `cargo clippy` over the workspace for every target in `rustLintTargets`: what | ||
| * the `cargo clippy` job runs. Code under `cfg(windows)` or | ||
| * `cfg(target_os = "macos")` is only linted when its target is. Clippy never | ||
| * links, so any host can lint every target once its std is installed. | ||
| * | ||
| * Usage: | ||
| * bun run rust:clippy # every target | ||
| * bun run rust:clippy --target x86_64-pc-windows-msvc # only the ones named | ||
| * bun run rust:clippy --message-format=short # other args go to `cargo clippy` | ||
| * | ||
| * With one target named, cargo's "unused dependency" warnings include crates | ||
| * that only another target uses. Trust them from a run over every target, | ||
| * which is also the only one that lints the standalone `bun_shim_impl` binary. | ||
| * | ||
| * Read what `--fix` did before keeping it. Clippy sees the code after `cfg` | ||
| * stripping, so a fix for one target can delete what another target needs: an | ||
| * arm that is `cfg!(unix)`, a `#[cfg(not(windows))]` block, a clamp that is a | ||
| * no-op for this target's integer type. | ||
| */ | ||
|
|
||
| import { spawnSync } from "node:child_process"; | ||
| import { resolve } from "node:path"; | ||
| import { rustLintTargets } from "./build/rust.ts"; | ||
|
|
||
| const repo = resolve(import.meta.dirname, ".."); | ||
| const args = process.argv.slice(2); | ||
| const targets = args.some(arg => arg === "--target" || arg.startsWith("--target=")) ? [] : rustLintTargets; | ||
|
|
||
| function run(cmd: string, args: string[]) { | ||
| console.log(`\x1b[36m[clippy]\x1b[0m ${cmd} ${args.join(" ")}`); | ||
| return spawnSync(cmd, args, { stdio: "inherit", cwd: repo }); | ||
| } | ||
|
|
||
| if (targets.length > 0) { | ||
| // Idempotent, and a fraction of a second once they are there. No rustup | ||
| // (a distro's cargo): the targets' std is the user's to provide. | ||
| const added = run("rustup", ["target", "add", ...targets]); | ||
| if (added.error === undefined && added.status !== 0) process.exit(added.status ?? 1); | ||
| } | ||
|
|
||
| const workspace = run("cargo", [ | ||
| "clippy", | ||
| "--workspace", | ||
| "--no-deps", | ||
| "--keep-going", | ||
| ...targets.flatMap(target => ["--target", target]), | ||
| ...args, | ||
| ]).status; | ||
|
|
||
| // `bun_shim_impl.exe` is a `[[bin]]` behind a feature, so `--workspace` skips it | ||
| // and only sees that file as a module of `bun_install`. | ||
| let shim: number | null = 0; | ||
| if (targets.length > 0) { | ||
| const windows = targets.filter(target => target.includes("windows")).flatMap(target => ["--target", target]); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| shim = run("cargo", [ | ||
| "clippy", | ||
| "-p", | ||
| "bun_shim_impl", | ||
| "--features", | ||
| "shim_standalone", | ||
| "--no-deps", | ||
| ...windows, | ||
| ...args, | ||
| ]).status; | ||
| } | ||
|
|
||
| process.exit(workspace !== 0 ? (workspace ?? 1) : (shim ?? 1)); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.