From 9c2804b44052672a3014a722508e8de28ae2fd31 Mon Sep 17 00:00:00 2001 From: Manojseetaram Date: Sat, 29 Aug 2026 23:57:47 +0530 Subject: [PATCH 1/2] Set net.git-fetch-with-cli in .cargo/config.toml Fixes intermittend SSL error when fetching the iai-calllgrind fit dependcy in ci , caused by cargo's default libgit2-based git client. Shellling out to the system git binary avoids this , Fixes #5186 problem --- .cargo/config.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index e0b12c98bca..51f7f4316aa 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -19,3 +19,6 @@ linker = "lld-link" # Without this, the linker complains that libc functions are undefined - # it probably signals to rustc and lld-link that libucrt should be included. rustflags = ["-Ctarget-feature=+crt-static"] + +[net] +git-fetch-with-cli = true From f19f7346142716476a77c7404f63de9374c1a4e5 Mon Sep 17 00:00:00 2001 From: Manojseetaram Date: Sun, 30 Aug 2026 01:46:41 +0530 Subject: [PATCH 2/2] Add the cargo fmt subcommand to format Rust , c# and typescript --- .cargo/config.toml | 2 +- Cargo.lock | 10 +++ Cargo.toml | 2 + .../client-modules/inkeep-font-override.ts | 8 ++- tools/ci/commands/fmt/Cargo.toml | 12 ++++ tools/ci/commands/fmt/src/main.rs | 67 +++++++++++++++++++ tools/ci/src/main.rs | 4 ++ 7 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 tools/ci/commands/fmt/Cargo.toml create mode 100644 tools/ci/commands/fmt/src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 51f7f4316aa..1199676ba8b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,7 +9,7 @@ regen = "run -p regen --" smoketest = "ci smoketests --" smoketests = "smoketest" lint = "ci lint --" - +fmt = "ci fmt --" [target.x86_64-pc-windows-msvc] # Use a different linker. Otherwise, the build fails with some obscure linker error that # seems to be a result of us producing a massive PDB file. diff --git a/Cargo.lock b/Cargo.lock index 0543315066c..ba3634faef5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -919,6 +919,16 @@ dependencies = [ "clap 4.5.50", ] +[[package]] +name = "ci-fmt" +version = "0.1.0" +dependencies = [ + "anyhow", + "ci-common", + "clap 4.5.50", + "duct", +] + [[package]] name = "ci-global-json-policy" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index d98d2a8ecfb..6ecc6fa7e65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,8 @@ members = [ "tools/ci", "tools/ci/commands/test", "tools/ci/commands/lint", + "tools/ci/commands/lint", + "tools/ci/commands/fmt", "tools/ci/commands/module-latest-deps", "tools/ci/commands/smoketests", "tools/ci/commands/smoketest-checks", diff --git a/docs/src/client-modules/inkeep-font-override.ts b/docs/src/client-modules/inkeep-font-override.ts index 60e6e6544fb..175704c8c9c 100644 --- a/docs/src/client-modules/inkeep-font-override.ts +++ b/docs/src/client-modules/inkeep-font-override.ts @@ -3,9 +3,11 @@ function injectInkeepFontOverride() { // Find all Inkeep shadow DOM containers - const inkeepElements = document.querySelectorAll('[id^="inkeep-shadowradix"]'); + const inkeepElements = document.querySelectorAll( + '[id^="inkeep-shadowradix"]' + ); - inkeepElements.forEach((element) => { + inkeepElements.forEach(element => { const shadowRoot = element.shadowRoot; if (!shadowRoot) return; @@ -75,7 +77,7 @@ if (typeof window !== 'undefined') { } // Also observe for dynamically added Inkeep elements - const observer = new MutationObserver((mutations) => { + const observer = new MutationObserver(mutations => { for (const mutation of mutations) { if (mutation.type === 'childList') { injectInkeepFontOverride(); diff --git a/tools/ci/commands/fmt/Cargo.toml b/tools/ci/commands/fmt/Cargo.toml new file mode 100644 index 00000000000..1c390e43af2 --- /dev/null +++ b/tools/ci/commands/fmt/Cargo.toml @@ -0,0 +1,12 @@ + +[package] +name = "ci-fmt" +version = "0.1.0" +edition.workspace = true + +[dependencies] +anyhow.workspace = true +clap.workspace = true +duct.workspace = true +ci-common = { path = "../../common" } + diff --git a/tools/ci/commands/fmt/src/main.rs b/tools/ci/commands/fmt/src/main.rs new file mode 100644 index 00000000000..999d1e5f172 --- /dev/null +++ b/tools/ci/commands/fmt/src/main.rs @@ -0,0 +1,67 @@ +#![allow(clippy::disallowed_macros)] +use anyhow::{Context, Result}; +use ci_common::{ensure_repo_root, pnpm}; +use clap::Parser; +use duct::cmd; +use std::ffi::OsString; +use std::path::PathBuf; + +/// Formats the codebase +/// +/// Runs rustfmt, csharpier, and the TypeScript/JS formatter (`pnpm format`) in +/// write mode, so a single `cargo fmt` fixes formatting everywhere in the repo. +/// This mirrors `cargo ci lint`'s checks, but writes fixes instead of only +/// checking for them. +#[derive(Parser)] +struct Cli {} + +// NOTE: duplicated from `ci-lint`'s `tracked_rs_files_under`. `cargo fmt --all` +// only checks files that Cargo discovers through workspace/package targets, +// but we also keep Rust sources in locations that are tracked but not part of +// our workspace, so we enumerate tracked files directly instead, exactly like +// `ci-lint` does for its `--check` pass. If this feels worth deduplicating, +// it could move to `ci-common`. +fn tracked_rs_files_under(path: &str) -> Result> { + let output = cmd!("git", "ls-files", "--", path) + .read() + .with_context(|| format!("failed to list tracked files under {path}"))?; + Ok(output + .lines() + .filter(|line| line.ends_with(".rs")) + .map(PathBuf::from) + .collect()) +} + +fn main() -> Result<()> { + Cli::parse(); + ensure_repo_root()?; + + // Format Rust files. + let files = tracked_rs_files_under(".")?; + const RUSTFMT_BATCH_SIZE: usize = 200; + for batch in files.chunks(RUSTFMT_BATCH_SIZE) { + let mut args = Vec::::with_capacity(batch.len()); + args.extend(batch.iter().map(|path| path.as_os_str().to_os_string())); + cmd("rustfmt", args) + .run() + .context("failed to run rustfmt")?; + } + + // Format C# files. + cmd!("dotnet", "tool", "restore") + .dir("crates/bindings-csharp") + .run() + .context("failed to run `dotnet tool restore` in crates/bindings-csharp")?; + cmd!("dotnet", "csharpier", ".") + .dir("crates/bindings-csharp") + .run() + .context("failed to run `dotnet csharpier .` in crates/bindings-csharp")?; + + // Format TypeScript/JS files. This script already exists in package.json + // and is what `pnpm format` runs today. + pnpm(["format"]) + .run() + .context("failed to run `pnpm format`")?; + + Ok(()) +} diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 5562a8b8b12..21894fd1c0b 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -84,6 +84,10 @@ const COMMANDS: &[Command] = &[ path: &["other-workflows", "run-spacetime"], package: "ci-run-spacetime", }, + Command { + path: &["fmt"], + package: "ci-fmt", + }, ]; fn print_help() {