mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
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
This commit is contained in:
commit
fcaf5964d7
@ -19,4 +19,7 @@ head_sha=$(git rev-parse "${HEAD_SHA:-HEAD}")
|
|||||||
echo "Base revision is $base_sha"
|
echo "Base revision is $base_sha"
|
||||||
echo "Head revision is $head_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"
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
//! but forgot to bump its version.
|
//! but forgot to bump its version.
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
#![allow(clippy::print_stdout)] // Fine for build utilities
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::fs;
|
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("locked", "Require Cargo.lock to be up-to-date").global(true))
|
||||||
.arg(flag("offline", "Run without accessing the network").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(multi_opt("config", "KEY=VALUE", "Override a configuration value").global(true))
|
||||||
|
.arg(flag("github", "Group output using GitHub's syntax"))
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("unstable-features")
|
Arg::new("unstable-features")
|
||||||
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")
|
.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
|
|||||||
let base_commit = get_base_commit(gctx, args, &repo)?;
|
let base_commit = get_base_commit(gctx, args, &repo)?;
|
||||||
let head_commit = get_head_commit(args, &repo)?;
|
let head_commit = get_head_commit(args, &repo)?;
|
||||||
let referenced_commit = get_referenced_commit(&repo, &base_commit)?;
|
let referenced_commit = get_referenced_commit(&repo, &base_commit)?;
|
||||||
let changed_members = changed(&ws, &repo, &base_commit, &head_commit)?;
|
let github = args.get_flag("github");
|
||||||
let status = |msg: &str| gctx.shell().status(STATUS, msg);
|
let status = |msg: &str| gctx.shell().status(STATUS, msg);
|
||||||
|
|
||||||
let crates_not_check_against_channels = [
|
let crates_not_check_against_channels = [
|
||||||
@ -135,9 +138,11 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
|
|||||||
status(&format!("head commit `{}`", head_commit.id()))?;
|
status(&format!("head commit `{}`", head_commit.id()))?;
|
||||||
|
|
||||||
let mut needs_bump = Vec::new();
|
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)?;
|
check_crates_io(&ws, &changed_members, &mut needs_bump)?;
|
||||||
|
|
||||||
if let Some(referenced_commit) = referenced_commit.as_ref() {
|
if let Some(referenced_commit) = referenced_commit.as_ref() {
|
||||||
status(&format!("compare against `{}`", referenced_commit.id()))?;
|
status(&format!("compare against `{}`", referenced_commit.id()))?;
|
||||||
for referenced_member in checkout_ws(&ws, &repo, referenced_commit)?.members() {
|
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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !needs_bump.is_empty() {
|
if !needs_bump.is_empty() {
|
||||||
needs_bump.sort();
|
needs_bump.sort();
|
||||||
needs_bump.dedup();
|
needs_bump.dedup();
|
||||||
@ -169,18 +173,14 @@ 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.");
|
msg.push_str("\nPlease bump at least one patch version in each corresponding Cargo.toml.");
|
||||||
anyhow::bail!(msg)
|
anyhow::bail!(msg)
|
||||||
}
|
}
|
||||||
|
if github {
|
||||||
// Even when we test against baseline-rev, we still need to make sure a
|
println!("::endgroup::");
|
||||||
// change doesn't violate SemVer rules against crates.io releases. The
|
}
|
||||||
// possibility of this happening is nearly zero but no harm to check twice.
|
|
||||||
let mut cmd = ProcessBuilder::new("cargo");
|
|
||||||
cmd.arg("semver-checks")
|
|
||||||
.arg("check-release")
|
|
||||||
.arg("--workspace");
|
|
||||||
gctx.shell().status("Running", &cmd)?;
|
|
||||||
cmd.exec()?;
|
|
||||||
|
|
||||||
if let Some(referenced_commit) = referenced_commit.as_ref() {
|
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");
|
let mut cmd = ProcessBuilder::new("cargo");
|
||||||
cmd.arg("semver-checks")
|
cmd.arg("semver-checks")
|
||||||
.arg("--workspace")
|
.arg("--workspace")
|
||||||
@ -192,6 +192,25 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
|
|||||||
}
|
}
|
||||||
gctx.shell().status("Running", &cmd)?;
|
gctx.shell().status("Running", &cmd)?;
|
||||||
cmd.exec()?;
|
cmd.exec()?;
|
||||||
|
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::");
|
||||||
}
|
}
|
||||||
|
|
||||||
status("no version bump needed for member crates.")?;
|
status("no version bump needed for member crates.")?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user