From 88f858a5b5bb7b8ca7ba2daa22037e2cf9907de6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 21 Feb 2025 09:11:33 -0600 Subject: [PATCH 1/3] refactor(bump): Visual group related operations --- crates/xtask-bump-check/src/xtask.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/xtask-bump-check/src/xtask.rs b/crates/xtask-bump-check/src/xtask.rs index 60dbc7538..d83e0db63 100644 --- a/crates/xtask-bump-check/src/xtask.rs +++ b/crates/xtask-bump-check/src/xtask.rs @@ -114,7 +114,6 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car let base_commit = get_base_commit(gctx, args, &repo)?; let head_commit = get_head_commit(args, &repo)?; let referenced_commit = get_referenced_commit(&repo, &base_commit)?; - let changed_members = changed(&ws, &repo, &base_commit, &head_commit)?; let status = |msg: &str| gctx.shell().status(STATUS, msg); let crates_not_check_against_channels = [ @@ -135,9 +134,8 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car status(&format!("head commit `{}`", head_commit.id()))?; let mut needs_bump = Vec::new(); - + let changed_members = changed(&ws, &repo, &base_commit, &head_commit)?; check_crates_io(&ws, &changed_members, &mut needs_bump)?; - if let Some(referenced_commit) = referenced_commit.as_ref() { status(&format!("compare against `{}`", referenced_commit.id()))?; for referenced_member in checkout_ws(&ws, &repo, referenced_commit)?.members() { @@ -157,7 +155,6 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car } } } - if !needs_bump.is_empty() { needs_bump.sort(); needs_bump.dedup(); From f035814fe2a87823c5ac05fc3d036bb1ed9edd49 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 21 Feb 2025 09:13:36 -0600 Subject: [PATCH 2/3] chore(ci): Visually group output in Github --- ci/validate-version-bump.sh | 5 ++++- crates/xtask-bump-check/src/xtask.rs | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ci/validate-version-bump.sh b/ci/validate-version-bump.sh index 94896711f..5436c3f78 100755 --- a/ci/validate-version-bump.sh +++ b/ci/validate-version-bump.sh @@ -19,4 +19,7 @@ head_sha=$(git rev-parse "${HEAD_SHA:-HEAD}") echo "Base revision is $base_sha" echo "Head revision is $head_sha" -cargo bump-check --base-rev "$base_sha" --head-rev "$head_sha" +echo "::group::Building xtask" +cargo bump-check --help +echo "::endgroup::" +cargo bump-check --github --base-rev "$base_sha" --head-rev "$head_sha" diff --git a/crates/xtask-bump-check/src/xtask.rs b/crates/xtask-bump-check/src/xtask.rs index d83e0db63..a35a3f449 100644 --- a/crates/xtask-bump-check/src/xtask.rs +++ b/crates/xtask-bump-check/src/xtask.rs @@ -10,6 +10,8 @@ //! but forgot to bump its version. //! ``` +#![allow(clippy::print_stdout)] // Fine for build utilities + use std::collections::HashMap; use std::fmt::Write; use std::fs; @@ -56,6 +58,7 @@ pub fn cli() -> clap::Command { .arg(flag("locked", "Require Cargo.lock to be up-to-date").global(true)) .arg(flag("offline", "Run without accessing the network").global(true)) .arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true)) + .arg(flag("github", "Group output using GitHub's syntax")) .arg( Arg::new("unstable-features") .help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details") @@ -114,6 +117,7 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car let base_commit = get_base_commit(gctx, args, &repo)?; let head_commit = get_head_commit(args, &repo)?; let referenced_commit = get_referenced_commit(&repo, &base_commit)?; + let github = args.get_flag("github"); let status = |msg: &str| gctx.shell().status(STATUS, msg); let crates_not_check_against_channels = [ @@ -134,6 +138,9 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car status(&format!("head commit `{}`", head_commit.id()))?; let mut needs_bump = Vec::new(); + if github { + println!("::group::Checking for bumps of changed packages"); + } let changed_members = changed(&ws, &repo, &base_commit, &head_commit)?; check_crates_io(&ws, &changed_members, &mut needs_bump)?; if let Some(referenced_commit) = referenced_commit.as_ref() { @@ -166,18 +173,30 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car msg.push_str("\nPlease bump at least one patch version in each corresponding Cargo.toml."); anyhow::bail!(msg) } + if github { + println!("::endgroup::"); + } // Even when we test against baseline-rev, we still need to make sure a // change doesn't violate SemVer rules against crates.io releases. The // possibility of this happening is nearly zero but no harm to check twice. + if github { + println!("::group::SemVer Checks against crates.io"); + } let mut cmd = ProcessBuilder::new("cargo"); cmd.arg("semver-checks") .arg("check-release") .arg("--workspace"); gctx.shell().status("Running", &cmd)?; cmd.exec()?; + if github { + println!("::endgroup::"); + } if let Some(referenced_commit) = referenced_commit.as_ref() { + if github { + println!("::group::SemVer Checks against {}", referenced_commit.id()); + } let mut cmd = ProcessBuilder::new("cargo"); cmd.arg("semver-checks") .arg("--workspace") @@ -189,6 +208,9 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car } gctx.shell().status("Running", &cmd)?; cmd.exec()?; + if github { + println!("::endgroup::"); + } } status("no version bump needed for member crates.")?; From 05228f76f46c8c8e810d195aa25e0ab48fb3b04a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 21 Feb 2025 09:50:36 -0600 Subject: [PATCH 3/3] chore(ci): Check against beta first Most breaking changes should be against beta and it would be good to have the context of whether we deviated from beta before checking against stable. --- crates/xtask-bump-check/src/xtask.rs | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/xtask-bump-check/src/xtask.rs b/crates/xtask-bump-check/src/xtask.rs index a35a3f449..18b9baa3c 100644 --- a/crates/xtask-bump-check/src/xtask.rs +++ b/crates/xtask-bump-check/src/xtask.rs @@ -177,22 +177,6 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car println!("::endgroup::"); } - // Even when we test against baseline-rev, we still need to make sure a - // change doesn't violate SemVer rules against crates.io releases. The - // possibility of this happening is nearly zero but no harm to check twice. - if github { - println!("::group::SemVer Checks against crates.io"); - } - let mut cmd = ProcessBuilder::new("cargo"); - cmd.arg("semver-checks") - .arg("check-release") - .arg("--workspace"); - gctx.shell().status("Running", &cmd)?; - cmd.exec()?; - if github { - println!("::endgroup::"); - } - if let Some(referenced_commit) = referenced_commit.as_ref() { if github { println!("::group::SemVer Checks against {}", referenced_commit.id()); @@ -213,6 +197,22 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car } } + // Even when we test against baseline-rev, we still need to make sure a + // change doesn't violate SemVer rules against crates.io releases. The + // possibility of this happening is nearly zero but no harm to check twice. + if github { + println!("::group::SemVer Checks against crates.io"); + } + let mut cmd = ProcessBuilder::new("cargo"); + cmd.arg("semver-checks") + .arg("check-release") + .arg("--workspace"); + gctx.shell().status("Running", &cmd)?; + cmd.exec()?; + if github { + println!("::endgroup::"); + } + status("no version bump needed for member crates.")?; Ok(())