Skip to content

Simple solution to validate toml in issue #106104 #106559

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5605,8 +5605,10 @@ dependencies = [
"lazy_static",
"miropt-test-tools",
"regex",
"serde",
"semver",
"termcolor",
"toml",
"walkdir",
]

Expand Down Expand Up @@ -5690,9 +5692,9 @@ dependencies = [

[[package]]
name = "toml"
version = "0.5.7"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645"
checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
dependencies = [
"serde",
]
Expand Down
2 changes: 2 additions & 0 deletions src/tools/tidy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ walkdir = "2"
ignore = "0.4.18"
semver = "1.0.14"
termcolor = "1.1.3"
toml = "0.5.10"
serde = { version = "1.0", features = ["derive"] }

[[bin]]
name = "rust-tidy"
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub mod pal;
pub mod primitive_docs;
pub mod style;
pub mod target_specific_tests;
pub mod triagebot;
pub mod ui_tests;
pub mod unit_tests;
pub mod unstable_book;
Expand Down
24 changes: 24 additions & 0 deletions src/tools/tidy/src/triagebot.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::walk::{filter_dirs, walk};
use serde::Deserialize;
use std::path::Path;
use toml::Value;

#[derive(Deserialize)]
struct Config {}

pub fn check(path: &Path, bad: &mut bool) {
walk(path, &mut |path| filter_dirs(path), &mut |entry, contents| {
let file = entry.path();
let filename = file.file_name().unwrap();
if filename != "triagebot.toml" {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe only check the top-level triagebot.toml instead of trying to find it in all subdirectories?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, I'll fix it. I had searched the repo for the triagebot.toml files and saw multiple, hence I thought maybe I should do a walk. Is there a reason we don't check those toml files?

Copy link
Member

Choose a reason for hiding this comment

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

Only the top-level one is actually used by triagebot afaik. Several subdirectories of src/tools are submodules or subtrees. Their copy is only used for the separate repo from which they are pulled in. For example src/tools/miri is a subtree pulled from https://github.com/rust-lang/miri/, so the https://github.com/rust-lang/miri/ repo has a triagebot.toml file which is used when interacting with this repo, but it is also copied into src/tools/miri/triagebot.toml as part of git subtree syncs, as everything is copied.

return;
}
let conf = contents.parse::<Value>();
match conf {
Ok(_) => {}
Err(_err) => {
tidy_error!(bad, "{} is an invalid toml file", file.display())
}
}
});
}