-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: warn on outdated top level dependencies (#757)
* mark: 0xaatif/outdated * run: cargo init scripts * feat: cargo xtask outdated * ci: lint outdated * chore: update description * fix(ci): pin kurtosis version
- Loading branch information
Showing
8 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "xtask" | ||
version = "0.0.0" | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
homepage.workspace = true | ||
keywords.workspace = true | ||
categories.workspace = true | ||
publish = false | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
clap = { workspace = true, features = ["derive"] } | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_json.workspace = true | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[[bin]] | ||
name = "xtask" | ||
path = "xtask.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//! General purpose scripts for development | ||
|
||
use std::process::{Command, Stdio}; | ||
|
||
use anyhow::{ensure, Context as _}; | ||
use clap::Parser; | ||
use serde::Deserialize; | ||
|
||
#[derive(Parser)] | ||
enum Args { | ||
/// Run `cargo-outdated`, printing warnings compatible with GitHub's CI. | ||
/// | ||
/// If a direct dependency listed in our Cargo.lock is behind the latest | ||
/// available on crates-io, a warning will be emitted. | ||
/// | ||
/// Note that we only warn on our _direct_ dependencies, | ||
/// not the entire supply chain. | ||
Outdated, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
struct Outdated<'a> { | ||
crate_name: &'a str, | ||
dependencies: Vec<Dependency<'a>>, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
struct Dependency<'a> { | ||
name: &'a str, | ||
project: &'a str, | ||
latest: &'a str, | ||
} | ||
|
||
fn main() -> anyhow::Result<()> { | ||
match Args::parse() { | ||
Args::Outdated => { | ||
let output = Command::new("cargo") | ||
.args(["outdated", "--root-deps-only", "--format=json"]) | ||
.stderr(Stdio::inherit()) | ||
.stdout(Stdio::piped()) | ||
.output() | ||
.context("couldn't exec `cargo`")?; | ||
ensure!( | ||
output.status.success(), | ||
"command failed with {}", | ||
output.status | ||
); | ||
for Outdated { | ||
crate_name, | ||
dependencies, | ||
} in serde_json::Deserializer::from_slice(&output.stdout) | ||
.into_iter::<Outdated<'_>>() | ||
.collect::<Result<Vec<_>, _>>() | ||
.context("failed to parse output from `cargo outdated`")? | ||
{ | ||
for Dependency { | ||
name, | ||
project, | ||
latest, | ||
} in dependencies | ||
{ | ||
// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message | ||
println!("::warning title=outdated-dependency::dependency {name} of crate {crate_name} is at version {project}, but the latest is {latest}") | ||
} | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} |