Run clippy for graphviz target in CI and add instructions on how to consume the output.

This commit is contained in:
Avi Weinstock 2021-06-08 15:08:14 -04:00
parent b5b7de9532
commit b5ae6227c0
2 changed files with 4 additions and 3 deletions

View File

@ -6,7 +6,7 @@ code-quality:
script: script:
- ln -s /dockercache/target target - ln -s /dockercache/target target
- rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly - rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly
- cargo clippy --all-targets --locked --features="bin_csv,bin_bot,asset_tweak" -- -D warnings - cargo clippy --all-targets --locked --features="bin_csv,bin_graphviz,bin_bot,asset_tweak" -- -D warnings
- cargo fmt --all -- --check - cargo fmt --all -- --check
security: security:

View File

@ -15,10 +15,9 @@ fn main() {
let mut graph = Graph::new(); let mut graph = Graph::new();
let mut nodes = HashMap::new(); let mut nodes = HashMap::new();
let mut add_node = |graph: &mut Graph<_, _>, node: &str| { let mut add_node = |graph: &mut Graph<_, _>, node: &str| {
nodes *nodes
.entry(node.to_owned()) .entry(node.to_owned())
.or_insert_with(|| graph.add_node(node.to_owned())) .or_insert_with(|| graph.add_node(node.to_owned()))
.clone()
}; };
for (_, recipe) in recipes.iter() { for (_, recipe) in recipes.iter() {
let output = recipe.output.0.item_definition_id(); let output = recipe.output.0.item_definition_id();
@ -40,6 +39,8 @@ fn main() {
graph.add_edge(in_node, out_node, ()); graph.add_edge(in_node, out_node, ());
} }
} }
// you can render the dot file as a png with `dot -Tpng recipe_graph.dot >
// recipe_graph.png` or interactively view it with `xdot recipe_graph.dot`
let mut f = File::create("recipe_graph.dot").unwrap(); let mut f = File::create("recipe_graph.dot").unwrap();
writeln!(f, "digraph {{").unwrap(); writeln!(f, "digraph {{").unwrap();
writeln!(f, "rankdir = \"LR\"").unwrap(); writeln!(f, "rankdir = \"LR\"").unwrap();