1
Fork 0

Rollup merge of #137885 - klensy:tidy-triagebot, r=jieyouxu

tidy: add triagebot checks

Validates triagebot.toml to have existing paths:

`[mentions."*"]` sections, i.e.
```toml
[mentions."compiler/rustc_const_eval/src/"]
```
or
```toml
[assign.owners]
"/.github/workflows" = ["infra-ci"]
```
or

```toml
trigger_files = [
 "src/librustdoc/html/static/js/search.js",
 "tests/rustdoc-js",
 "tests/rustdoc-js-std",
 ]
```
Looked at #137876 and implemented check.
This commit is contained in:
Matthias Krüger 2025-03-09 10:34:48 +01:00 committed by GitHub
commit cdd97bae84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 103 additions and 11 deletions

View file

@ -5271,6 +5271,7 @@ dependencies = [
"serde", "serde",
"similar", "similar",
"termcolor", "termcolor",
"toml 0.7.8",
"walkdir", "walkdir",
] ]

View file

@ -17,6 +17,7 @@ termcolor = "1.1.3"
rustc-hash = "2.0.0" rustc-hash = "2.0.0"
fluent-syntax = "0.11.1" fluent-syntax = "0.11.1"
similar = "2.5.0" similar = "2.5.0"
toml = "0.7.8"
[features] [features]
build-metrics = ["dep:serde"] build-metrics = ["dep:serde"]

View file

@ -87,6 +87,7 @@ pub mod target_policy;
pub mod target_specific_tests; pub mod target_specific_tests;
pub mod tests_placement; pub mod tests_placement;
pub mod tests_revision_unpaired_stdout_stderr; pub mod tests_revision_unpaired_stdout_stderr;
pub mod triagebot;
pub mod ui_tests; pub mod ui_tests;
pub mod unit_tests; pub mod unit_tests;
pub mod unknown_revision; pub mod unknown_revision;

View file

@ -144,6 +144,8 @@ fn main() {
check!(x_version, &root_path, &cargo); check!(x_version, &root_path, &cargo);
check!(triagebot, &root_path);
let collected = { let collected = {
drain_handles(&mut handles); drain_handles(&mut handles);

View file

@ -0,0 +1,93 @@
//! Tidy check to ensure paths mentioned in triagebot.toml exist in the project.
use std::path::Path;
use toml::Value;
pub fn check(path: &Path, bad: &mut bool) {
let triagebot_path = path.join("triagebot.toml");
if !triagebot_path.exists() {
tidy_error!(bad, "triagebot.toml file not found");
return;
}
let contents = std::fs::read_to_string(&triagebot_path).unwrap();
let config: Value = toml::from_str(&contents).unwrap();
// Check [mentions."*"] sections, i.e. [mentions."compiler/rustc_const_eval/src/"]
if let Some(Value::Table(mentions)) = config.get("mentions") {
for path_str in mentions.keys() {
// Remove quotes from the path
let clean_path = path_str.trim_matches('"');
let full_path = path.join(clean_path);
if !full_path.exists() {
tidy_error!(
bad,
"triagebot.toml [mentions.*] contains path '{}' which doesn't exist",
clean_path
);
}
}
} else {
tidy_error!(
bad,
"triagebot.toml missing [mentions.*] section, this wrong for rust-lang/rust repo."
);
}
// Check [assign.owners] sections, i.e.
// [assign.owners]
// "/.github/workflows" = ["infra-ci"]
if let Some(Value::Table(assign)) = config.get("assign") {
if let Some(Value::Table(owners)) = assign.get("owners") {
for path_str in owners.keys() {
// Remove quotes and leading slash from the path
let clean_path = path_str.trim_matches('"').trim_start_matches('/');
let full_path = path.join(clean_path);
if !full_path.exists() {
tidy_error!(
bad,
"triagebot.toml [assign.owners] contains path '{}' which doesn't exist",
clean_path
);
}
}
} else {
tidy_error!(
bad,
"triagebot.toml missing [assign.owners] section, this wrong for rust-lang/rust repo."
);
}
}
// Verify that trigger_files in [autolabel."*"] exist in the project, i.e.
// [autolabel."A-rustdoc-search"]
// trigger_files = [
// "src/librustdoc/html/static/js/search.js",
// "tests/rustdoc-js",
// "tests/rustdoc-js-std",
// ]
if let Some(Value::Table(autolabels)) = config.get("autolabel") {
for (label, content) in autolabels {
if let Some(trigger_files) = content.get("trigger_files").and_then(|v| v.as_array()) {
for file in trigger_files {
if let Some(file_str) = file.as_str() {
let full_path = path.join(file_str);
// Handle both file and directory paths
if !full_path.exists() {
tidy_error!(
bad,
"triagebot.toml [autolabel.{}] contains trigger_files path '{}' which doesn't exist",
label,
file_str
);
}
}
}
}
}
}
}

View file

@ -253,7 +253,6 @@ trigger_files = [
"compiler/rustc_passes/src/check_attr.rs", "compiler/rustc_passes/src/check_attr.rs",
"compiler/rustc_attr_parsing", "compiler/rustc_attr_parsing",
"compiler/rustc_attr_data_structures", "compiler/rustc_attr_data_structures",
"compiler/rustc_attr_validation",
] ]
[autolabel."T-rustdoc-frontend"] [autolabel."T-rustdoc-frontend"]
@ -317,7 +316,6 @@ trigger_files = [
"library/panic_unwind", "library/panic_unwind",
"library/std", "library/std",
"library/stdarch", "library/stdarch",
"library/term",
"library/test", "library/test",
] ]
exclude_labels = [ exclude_labels = [
@ -332,7 +330,7 @@ trigger_files = [
[autolabel."O-apple"] [autolabel."O-apple"]
trigger_files = [ trigger_files = [
"library/std/src/os/darwin", "library/std/src/os/darwin",
"library/std/src/sys/pal/unix/thread_parking/darwin.rs", "library/std/src/sys/sync/thread_parking/darwin.rs",
"compiler/rustc_target/src/spec/base/apple", "compiler/rustc_target/src/spec/base/apple",
] ]
@ -409,7 +407,8 @@ trigger_files = [
[autolabel."O-wasm"] [autolabel."O-wasm"]
trigger_files = [ trigger_files = [
"library/std/src/sys/pal/wasm", "library/std/src/sys/pal/wasm",
"library/std/src/os/wasm" "library/std/src/os/wasi",
"library/std/src/os/wasip2"
] ]
[autolabel."O-windows"] [autolabel."O-windows"]
@ -500,7 +499,6 @@ trigger_files = [
"CONTRIBUTING.md", "CONTRIBUTING.md",
"INSTALL.md", "INSTALL.md",
"REUSE.toml", "REUSE.toml",
".reuse",
".mailmap", ".mailmap",
".git-blame-ignore-revs", ".git-blame-ignore-revs",
".editorconfig" ".editorconfig"
@ -525,7 +523,6 @@ exclude_labels = [
[autolabel."WG-trait-system-refactor"] [autolabel."WG-trait-system-refactor"]
trigger_files = [ trigger_files = [
"compiler/rustc_middle/src/traits/solve",
"compiler/rustc_next_trait_solver", "compiler/rustc_next_trait_solver",
"compiler/rustc_trait_selection/src/solve", "compiler/rustc_trait_selection/src/solve",
"compiler/rustc_type_ir/src/solve", "compiler/rustc_type_ir/src/solve",
@ -795,7 +792,7 @@ cc = ["@Nadrieril"]
message = "Some changes occurred in cfg and check-cfg configuration" message = "Some changes occurred in cfg and check-cfg configuration"
cc = ["@Urgau"] cc = ["@Urgau"]
[mentions."compiler/rustc_lint/src/context/diagnostics/check_cfg.rs"] [mentions."compiler/rustc_lint/src/early/diagnostics/check_cfg.rs"]
message = "Some changes occurred in check-cfg diagnostics" message = "Some changes occurred in check-cfg diagnostics"
cc = ["@Urgau"] cc = ["@Urgau"]
@ -961,7 +958,7 @@ If appropriate, please update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/util
[mentions."src/bootstrap/src/core/build_steps/llvm.rs"] [mentions."src/bootstrap/src/core/build_steps/llvm.rs"]
message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp." message = "This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp."
[mentions."test/crashes"] [mentions."tests/crashes"]
message = "This PR changes a file inside `tests/crashes`. If a crash was fixed, please move into the corresponding `ui` subdir and add 'Fixes #<issueNr>' to the PR description to autoclose the issue upon merge." message = "This PR changes a file inside `tests/crashes`. If a crash was fixed, please move into the corresponding `ui` subdir and add 'Fixes #<issueNr>' to the PR description to autoclose the issue upon merge."
[mentions."tests/rustdoc-json"] [mentions."tests/rustdoc-json"]
@ -1075,8 +1072,6 @@ cc = ["@jdonszelmann"]
cc = ["@jdonszelmann"] cc = ["@jdonszelmann"]
[mentions."compiler/rustc_attr_data_structures"] [mentions."compiler/rustc_attr_data_structures"]
cc = ["@jdonszelmann"] cc = ["@jdonszelmann"]
[mentions."compiler/rustc_attr_validation"]
cc = ["@jdonszelmann"]
[assign] [assign]
warn_non_default_branch.enable = true warn_non_default_branch.enable = true
@ -1265,7 +1260,6 @@ project-exploit-mitigations = [
"/compiler/rustc_middle/src/traits" = ["compiler", "types"] "/compiler/rustc_middle/src/traits" = ["compiler", "types"]
"/compiler/rustc_middle/src/ty" = ["compiler", "types"] "/compiler/rustc_middle/src/ty" = ["compiler", "types"]
"/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"] "/compiler/rustc_const_eval/src/interpret" = ["compiler", "mir"]
"/compiler/rustc_const_eval/src/transform" = ["compiler", "mir-opt"]
"/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"] "/compiler/rustc_mir_build/src/builder" = ["compiler", "mir"]
"/compiler/rustc_mir_transform" = ["compiler", "mir", "mir-opt"] "/compiler/rustc_mir_transform" = ["compiler", "mir", "mir-opt"]
"/compiler/rustc_smir" = ["project-stable-mir"] "/compiler/rustc_smir" = ["project-stable-mir"]