Skip to content

feat(rust): tool configuration and GitHub metadata select no tests in Rust-only repositories - #277

Open
FredApps wants to merge 3 commits into
DiffCI:mainfrom
FredApps:rust/131-non-code-paths
Open

FredApps wants to merge 3 commits into
DiffCI:mainfrom
FredApps:rust/131-non-code-paths

Conversation

@FredApps

@FredApps FredApps commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Part of #131 (non-code paths).

In a Rust repository, any changed file that isn't a Rust source, a modelled asset or documentation keeps the full suite ("Rust runtime inputs outside crate metadata…", or "Unknown changed file"). That includes files plain cargo test never reads, so a Renovate or deny.toml tweak ran everything. This PR lets those select no tests, only where that's safe:

  • Which files:
    • Tool configuration at the repository root or a crate root: rustfmt.toml, clippy.toml (with or without a dot), deny.toml, typos configs, committed.toml, release.toml, cliff.toml, taplo.toml, .pre-commit-config.yaml, codecov.yml, .editorconfig, markdownlint configs, CODEOWNERS and Renovate files.
    • GitHub metadata: issue, discussion and PR templates, .github/*.md, CODEOWNERS, FUNDING, dependabot, release, labeler, labels, stale, settings, codecov, config YAML, and Renovate.
  • Still the full suite: workflows, composite actions, other .github files (a workflow could run a script there), .cargo/config.toml, rust-toolchain(.toml), .gitattributes, test-tool configs (insta, nextest), and tool names outside a crate root, such as a UI-test fixture's clippy.toml.
  • Only when no Rust code may read them. The adapter adds rustMetadataReaders: every build script, every source that climbs out of its crate, and every source with a string literal naming a .github path, a TOML, YAML or JSON name or bare extension ("toml" in an extension check), or a dotfile. If there's any reader, these files keep the full suite. An older cached profile without the field also keeps it.
  • Only in a Rust-only repository, since another language's tools (Prettier, a JS runner) may read .editorconfig or .github files.

Test: "tool configuration and GitHub metadata select nothing unless Rust code may read them" in rust-integration.test.ts. It covers the accepted paths, the paths that must stay full, an older cached profile, five kinds of reader code and a build script. One docs sentence is added.

Locally, six Renovate- or deny.toml-only commits from anstyle's history now get a SELECTIVE plan with no tests.

Local checks: typecheck, npm test with DIFFCI_REQUIRE_CARGO=1 (1168 pass), build, audit:boundary, agent:check. Hosted CI passed on this head.

Merge order (#131 series: #232, #234, #248, #250, #252, #254, #256, #277, #258). These all edit the one-line Rust paragraph in docs/using-diffci.md, and some also touch rust.ts/types.ts, so they conflict textually with each other. #258 already includes #232, #248, #250 and #254 with those conflicts resolved. The simplest path: merge #258 (GitHub marks those four as merged), then #234, #252, #256 and #277. After each one lands I merge main into the next and resolve the docs line. Merging them one at a time in number order works too, with the same main merge after each.

… Rust-only repositories

Plain cargo test never reads rustfmt/clippy/deny/typos/release-tool configuration or GitHub's
templates, CODEOWNERS, FUNDING, Dependabot and Renovate files. At the repository root or a crate
root, such a change now selects nothing instead of the full suite, unless a build script or Rust
code that names such a file (or climbs out of its crate) may read it. Older cached profiles
without the new reader list keep the full suite.

Signed-off-by: FredApps <[email protected]>
@adityankale190895

Copy link
Copy Markdown
Member

#258 is merged (it brought in #232, #248, #250 and #254), along with #228-#231 and #233, so this branch now conflicts with main in docs/using-diffci.md, src/repo/adapters/rust.ts, src/repo/adapters/types.ts and tests/repo/rust-integration.test.ts, as you expected in #258.

Could you merge main into it? Once it's green I'll check it alongside the other Rust PRs and merge it. Thanks for keeping the Rust series moving.

@adityankale190895

Copy link
Copy Markdown
Member

Thanks! The Rust-only gating and failing closed on older cached profiles both look right. One case is unsafe, though: programs that read these config files aren't counted as readers.

  • A test that runs Command::new("cargo").args(["fmt", "--check"]) is classed as compiles but not as a metadata reader.
  • A test that runs rustfmt, cargo clippy, typos or pre-commit directly (or through xshell's cmd!) isn't one either.

A local probe gave rustMetadataReaders: [] in both cases, so a rustfmt.toml or clippy.toml change would select no tests even though the format or tidy test reads it.

Suggested fix: count scanned.compiles || scanned.runsPrograms as a metadata reader, next to if (scanned.metadata) in the source loop in rust.ts. A stricter alternative is to narrow metadata changes in impact.ts only when rustRunsPrograms === false and no source compiles.

The PR also needs main merged in. There are conflicts in rust.ts (the rustInputs return type and return statement), types.ts, the docs paragraph, and tests/repo/rust-integration.test.ts. In that test file, #250's new test shares the closing } finally … }); lines with yours, so check the braces after resolving.

…aths

Signed-off-by: FredApps <[email protected]>

# Conflicts:
#	docs/using-diffci.md
#	src/repo/adapters/rust.ts
#	src/repo/adapters/types.ts
#	tests/repo/rust-integration.test.ts
A test that runs `cargo fmt --check`, `cargo clippy`, rustfmt, typos or
pre-commit (through Command or xshell's cmd!) reads rustfmt.toml,
clippy.toml and the like without naming them, so rustMetadataReaders
stayed empty and a tool-config change selected no tests. Sources that
compile or run programs are now metadata readers, which keeps the full
suite for such changes.

Signed-off-by: FredApps <[email protected]>
@FredApps

Copy link
Copy Markdown
Contributor Author

Thanks, agreed. I merged main in (5d6fadc) and fixed it in 311f7b5.

Merge conflicts:

  • In rust.ts, the rustInputs return type and return statement now carry both metadata and runsPrograms.
  • In types.ts, both sets of fields are kept.
  • In docs/using-diffci.md, I kept main's paragraph and added this PR's sentence at the end.
  • In tests/repo/rust-integration.test.ts, the tool-configuration test now has its own } finally … });, and feat(rust): confine helper scripts and native sources to the crate that owns them #250's test is placed after it. I checked the braces.

The fix: I used your first suggestion. A source is a metadata reader if scanned.metadata || scanned.compiles || scanned.runsPrograms. A test that runs cargo fmt --check or cargo clippy, or runs rustfmt, typos or pre-commit directly or through xshell's cmd!, now keeps the full suite for a rustfmt.toml, clippy.toml or .github change. Without such code, those changes still narrow. The types.ts comment and the docs sentence now say this.

Tests: five bodies are added to the existing "tool configuration and GitHub metadata select nothing unless Rust code may read them" integration test:

  • Command::new("cargo").args(["fmt", "--check"])
  • Command::new("rustfmt")
  • Command::new("typos")
  • Command::new("pre-commit")
  • xshell::cmd!(sh, "cargo clippy -- -D warnings")

Each must give rustMetadataReaders: ["core/src/lib.rs"] and a full run for rustfmt.toml and .github/dependabot.yml. The test fails without the fix.

Locally, typecheck, npm test with DIFFCI_REQUIRE_CARGO=1 (1359 pass, 0 skipped), build, audit:boundary, agent:check and the CLI package tests all pass. Hosted CI is green on 311f7b5.

As I noted on #256, bridge packages aren't counted as metadata readers yet, because that code lives in #256. Whichever PR lands second, I'll merge main in and add them.

@adityankale190895

Copy link
Copy Markdown
Member

#256 is merged (d23a582), so this now conflicts with main in docs/using-diffci.md. Could you merge main in and, as you planned, count local packages' files that name metadata paths, compile, or run programs as rustMetadataReaders, with a test where a local package running cargo fmt --check keeps the full suite for a rustfmt.toml change? Once it's green I'll merge it.

This branch has not been deployed

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