chore(ci): Visually group output in Github

This commit is contained in:
Ed Page 2025-02-21 09:13:36 -06:00
parent 88f858a5b5
commit f035814fe2
2 changed files with 26 additions and 1 deletions

View File

@ -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"

View File

@ -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.")?;