Skip to content
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

ci: warn on outdated top level dependencies #757

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
# https://github.com/rust-lang/rust/pull/124129
# https://github.com/dtolnay/linkme/pull/88
rustflags = ["-Z", "linker-features=-lld"]

[alias]
xtask = ["run", "--package=xtask", "--"]
2 changes: 1 addition & 1 deletion .github/workflows/jerigon-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
sudo apt install kurtosis-cli=1.3.1

#It is much easier to use cast tool in scripts so install foundry
- name: Install Foundry
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jerigon-zero.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
sudo apt install kurtosis-cli=1.3.1

#It is much easier to use cast tool in scripts so install foundry
- name: Install Foundry
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ jobs:
with:
tool: taplo-cli
- run: taplo fmt --check
outdated:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: you could probably use @v4 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's update all of these at once: #759

- uses: ./.github/actions/rust
- uses: taiki-e/install-action@v2
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I am starting to feel just slightly uncomfortable about number of external GithubAction dependencies we are including in our CI.

with:
tool: cargo-outdated
- run: cargo xtask outdated
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"evm_arithmetization",
"mpt_trie",
"proc_macro",
"scripts",
"smt_trie",
"trace_decoder",
"zero",
Expand Down
23 changes: 23 additions & 0 deletions scripts/Cargo.toml
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"
69 changes: 69 additions & 0 deletions scripts/xtask.rs
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(())
}
Loading