Skip to content

Commit f035814

Browse files
committed
chore(ci): Visually group output in Github
1 parent 88f858a commit f035814

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ci/validate-version-bump.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ head_sha=$(git rev-parse "${HEAD_SHA:-HEAD}")
1919
echo "Base revision is $base_sha"
2020
echo "Head revision is $head_sha"
2121

22-
cargo bump-check --base-rev "$base_sha" --head-rev "$head_sha"
22+
echo "::group::Building xtask"
23+
cargo bump-check --help
24+
echo "::endgroup::"
25+
cargo bump-check --github --base-rev "$base_sha" --head-rev "$head_sha"

crates/xtask-bump-check/src/xtask.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//! but forgot to bump its version.
1111
//! ```
1212
13+
#![allow(clippy::print_stdout)] // Fine for build utilities
14+
1315
use std::collections::HashMap;
1416
use std::fmt::Write;
1517
use std::fs;
@@ -56,6 +58,7 @@ pub fn cli() -> clap::Command {
5658
.arg(flag("locked", "Require Cargo.lock to be up-to-date").global(true))
5759
.arg(flag("offline", "Run without accessing the network").global(true))
5860
.arg(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true))
61+
.arg(flag("github", "Group output using GitHub's syntax"))
5962
.arg(
6063
Arg::new("unstable-features")
6164
.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
114117
let base_commit = get_base_commit(gctx, args, &repo)?;
115118
let head_commit = get_head_commit(args, &repo)?;
116119
let referenced_commit = get_referenced_commit(&repo, &base_commit)?;
120+
let github = args.get_flag("github");
117121
let status = |msg: &str| gctx.shell().status(STATUS, msg);
118122

119123
let crates_not_check_against_channels = [
@@ -134,6 +138,9 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
134138
status(&format!("head commit `{}`", head_commit.id()))?;
135139

136140
let mut needs_bump = Vec::new();
141+
if github {
142+
println!("::group::Checking for bumps of changed packages");
143+
}
137144
let changed_members = changed(&ws, &repo, &base_commit, &head_commit)?;
138145
check_crates_io(&ws, &changed_members, &mut needs_bump)?;
139146
if let Some(referenced_commit) = referenced_commit.as_ref() {
@@ -166,18 +173,30 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
166173
msg.push_str("\nPlease bump at least one patch version in each corresponding Cargo.toml.");
167174
anyhow::bail!(msg)
168175
}
176+
if github {
177+
println!("::endgroup::");
178+
}
169179

170180
// Even when we test against baseline-rev, we still need to make sure a
171181
// change doesn't violate SemVer rules against crates.io releases. The
172182
// possibility of this happening is nearly zero but no harm to check twice.
183+
if github {
184+
println!("::group::SemVer Checks against crates.io");
185+
}
173186
let mut cmd = ProcessBuilder::new("cargo");
174187
cmd.arg("semver-checks")
175188
.arg("check-release")
176189
.arg("--workspace");
177190
gctx.shell().status("Running", &cmd)?;
178191
cmd.exec()?;
192+
if github {
193+
println!("::endgroup::");
194+
}
179195

180196
if let Some(referenced_commit) = referenced_commit.as_ref() {
197+
if github {
198+
println!("::group::SemVer Checks against {}", referenced_commit.id());
199+
}
181200
let mut cmd = ProcessBuilder::new("cargo");
182201
cmd.arg("semver-checks")
183202
.arg("--workspace")
@@ -189,6 +208,9 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
189208
}
190209
gctx.shell().status("Running", &cmd)?;
191210
cmd.exec()?;
211+
if github {
212+
println!("::endgroup::");
213+
}
192214
}
193215

194216
status("no version bump needed for member crates.")?;

0 commit comments

Comments
 (0)