Skip to content

Commit fcaf596

Browse files
authored
chore(ci): Visually group output in Github (#15218)
### What does this PR try to resolve? In a recent bump-check failure, it was hard to see how the change was relevant. The hope is that [grouping the lines](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#grouping-log-lines) will filter the data down and provide enough context to make this easier ### How should we test and review this PR? ### Additional information
2 parents 0b020a6 + 05228f7 commit fcaf596

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

ci/validate-version-bump.sh

+4-1
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

+33-14
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,7 +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)?;
117-
let changed_members = changed(&ws, &repo, &base_commit, &head_commit)?;
120+
let github = args.get_flag("github");
118121
let status = |msg: &str| gctx.shell().status(STATUS, msg);
119122

120123
let crates_not_check_against_channels = [
@@ -135,9 +138,11 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
135138
status(&format!("head commit `{}`", head_commit.id()))?;
136139

137140
let mut needs_bump = Vec::new();
138-
141+
if github {
142+
println!("::group::Checking for bumps of changed packages");
143+
}
144+
let changed_members = changed(&ws, &repo, &base_commit, &head_commit)?;
139145
check_crates_io(&ws, &changed_members, &mut needs_bump)?;
140-
141146
if let Some(referenced_commit) = referenced_commit.as_ref() {
142147
status(&format!("compare against `{}`", referenced_commit.id()))?;
143148
for referenced_member in checkout_ws(&ws, &repo, referenced_commit)?.members() {
@@ -157,7 +162,6 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
157162
}
158163
}
159164
}
160-
161165
if !needs_bump.is_empty() {
162166
needs_bump.sort();
163167
needs_bump.dedup();
@@ -169,18 +173,14 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
169173
msg.push_str("\nPlease bump at least one patch version in each corresponding Cargo.toml.");
170174
anyhow::bail!(msg)
171175
}
172-
173-
// Even when we test against baseline-rev, we still need to make sure a
174-
// change doesn't violate SemVer rules against crates.io releases. The
175-
// possibility of this happening is nearly zero but no harm to check twice.
176-
let mut cmd = ProcessBuilder::new("cargo");
177-
cmd.arg("semver-checks")
178-
.arg("check-release")
179-
.arg("--workspace");
180-
gctx.shell().status("Running", &cmd)?;
181-
cmd.exec()?;
176+
if github {
177+
println!("::endgroup::");
178+
}
182179

183180
if let Some(referenced_commit) = referenced_commit.as_ref() {
181+
if github {
182+
println!("::group::SemVer Checks against {}", referenced_commit.id());
183+
}
184184
let mut cmd = ProcessBuilder::new("cargo");
185185
cmd.arg("semver-checks")
186186
.arg("--workspace")
@@ -192,6 +192,25 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
192192
}
193193
gctx.shell().status("Running", &cmd)?;
194194
cmd.exec()?;
195+
if github {
196+
println!("::endgroup::");
197+
}
198+
}
199+
200+
// Even when we test against baseline-rev, we still need to make sure a
201+
// change doesn't violate SemVer rules against crates.io releases. The
202+
// possibility of this happening is nearly zero but no harm to check twice.
203+
if github {
204+
println!("::group::SemVer Checks against crates.io");
205+
}
206+
let mut cmd = ProcessBuilder::new("cargo");
207+
cmd.arg("semver-checks")
208+
.arg("check-release")
209+
.arg("--workspace");
210+
gctx.shell().status("Running", &cmd)?;
211+
cmd.exec()?;
212+
if github {
213+
println!("::endgroup::");
195214
}
196215

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

0 commit comments

Comments
 (0)