Skip to content

Commit d3cdf27

Browse files
committed
Add even more GHA log groups
This also adds a dynamic check that we don't emit nested groups, since GHA currently doesn't support them.
1 parent 3b55d23 commit d3cdf27

File tree

5 files changed

+67
-18
lines changed

5 files changed

+67
-18
lines changed

src/bootstrap/doc.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,16 @@ impl Step for RustcBook {
10601060
// config.toml), then this needs to explicitly update the dylib search
10611061
// path.
10621062
builder.add_rustc_lib_path(self.compiler, &mut cmd);
1063+
let doc_generator_guard = builder.msg(
1064+
Kind::Run,
1065+
self.compiler.stage,
1066+
"lint-docs",
1067+
self.compiler.host,
1068+
self.target,
1069+
);
10631070
builder.run(&mut cmd);
1071+
drop(doc_generator_guard);
1072+
10641073
// Run rustbook/mdbook to generate the HTML pages.
10651074
builder.ensure(RustbookSrc {
10661075
target: self.target,

src/bootstrap/test.rs

+36-15
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,7 @@ impl Step for CrateBootstrap {
117117
SourceType::InTree,
118118
&[],
119119
);
120-
builder.info(&format!(
121-
"{} {} stage0 ({})",
122-
builder.kind.description(),
123-
path,
124-
bootstrap_host,
125-
));
120+
let _group = builder.msg(Kind::Test, compiler.stage, path, compiler.host, bootstrap_host);
126121
let crate_name = path.rsplit_once('/').unwrap().1;
127122
run_cargo_test(cargo, &[], &[], crate_name, compiler, bootstrap_host, builder);
128123
}
@@ -163,6 +158,15 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
163158
// Test the linkchecker itself.
164159
let bootstrap_host = builder.config.build;
165160
let compiler = builder.compiler(0, bootstrap_host);
161+
162+
let self_test_group = builder.msg(
163+
Kind::Test,
164+
compiler.stage,
165+
"linkchecker self tests",
166+
bootstrap_host,
167+
bootstrap_host,
168+
);
169+
166170
let cargo = tool::prepare_tool_cargo(
167171
builder,
168172
compiler,
@@ -174,6 +178,7 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
174178
&[],
175179
);
176180
run_cargo_test(cargo, &[], &[], "linkchecker", compiler, bootstrap_host, builder);
181+
drop(self_test_group);
177182

178183
if builder.doc_tests == DocTests::No {
179184
return;
@@ -182,12 +187,14 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
182187
// Build all the default documentation.
183188
builder.default_doc(&[]);
184189

190+
// Build the linkchecker before calling `msg`, since GHA doesn't support nested groups.
191+
let mut linkchecker = builder.tool_cmd(Tool::Linkchecker);
192+
185193
// Run the linkchecker.
194+
let _guard =
195+
builder.msg(Kind::Test, compiler.stage, "Linkcheck", bootstrap_host, bootstrap_host);
186196
let _time = util::timeit(&builder);
187-
try_run(
188-
builder,
189-
builder.tool_cmd(Tool::Linkchecker).arg(builder.out.join(host.triple).join("doc")),
190-
);
197+
try_run(builder, linkchecker.arg(builder.out.join(host.triple).join("doc")));
191198
}
192199

193200
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -2669,6 +2676,10 @@ impl Step for Bootstrap {
26692676

26702677
/// Tests the build system itself.
26712678
fn run(self, builder: &Builder<'_>) {
2679+
let host = builder.config.build;
2680+
let compiler = builder.compiler(0, host);
2681+
let _guard = builder.msg(Kind::Test, 0, "bootstrap", host, host);
2682+
26722683
let mut check_bootstrap = Command::new(&builder.python());
26732684
check_bootstrap
26742685
.args(["-m", "unittest", "bootstrap_test.py"])
@@ -2679,8 +2690,6 @@ impl Step for Bootstrap {
26792690
// Use `python -m unittest` manually if you want to pass arguments.
26802691
try_run(builder, &mut check_bootstrap);
26812692

2682-
let host = builder.config.build;
2683-
let compiler = builder.compiler(0, host);
26842693
let mut cmd = Command::new(&builder.initial_cargo);
26852694
cmd.arg("test")
26862695
.current_dir(builder.src.join("src/bootstrap"))
@@ -2748,7 +2757,13 @@ impl Step for TierCheck {
27482757
cargo.arg("--verbose");
27492758
}
27502759

2751-
builder.info("platform support check");
2760+
let _guard = builder.msg(
2761+
Kind::Test,
2762+
self.compiler.stage,
2763+
"platform support check",
2764+
self.compiler.host,
2765+
self.compiler.host,
2766+
);
27522767
try_run(builder, &mut cargo.into());
27532768
}
27542769
}
@@ -2796,8 +2811,6 @@ impl Step for RustInstaller {
27962811

27972812
/// Ensure the version placeholder replacement tool builds
27982813
fn run(self, builder: &Builder<'_>) {
2799-
builder.info("test rust-installer");
2800-
28012814
let bootstrap_host = builder.config.build;
28022815
let compiler = builder.compiler(0, bootstrap_host);
28032816
let cargo = tool::prepare_tool_cargo(
@@ -2810,6 +2823,14 @@ impl Step for RustInstaller {
28102823
SourceType::InTree,
28112824
&[],
28122825
);
2826+
2827+
let _guard = builder.msg(
2828+
Kind::Test,
2829+
compiler.stage,
2830+
"rust-installer",
2831+
bootstrap_host,
2832+
bootstrap_host,
2833+
);
28132834
run_cargo_test(cargo, &[], &[], "installer", compiler, bootstrap_host, builder);
28142835

28152836
// We currently don't support running the test.sh script outside linux(?) environments.

src/ci/docker/run.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
7979
loaded_images=$(/usr/bin/timeout -k 720 600 docker load -i /tmp/rustci_docker_cache \
8080
| sed 's/.* sha/sha/')
8181
set -e
82-
echo "Downloaded containers:\n$loaded_images"
82+
printf "Downloaded containers:\n$loaded_images\n"
8383
fi
8484

8585
dockerfile="$docker_dir/$image/Dockerfile"
@@ -89,12 +89,14 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
8989
else
9090
context="$script_dir"
9191
fi
92+
echo "::group::Building docker image for $image"
9293
retry docker \
9394
build \
9495
--rm \
9596
-t rust-ci \
9697
-f "$dockerfile" \
9798
"$context"
99+
echo "::endgroup::"
98100

99101
if [ "$CI" != "" ]; then
100102
s3url="s3://$SCCACHE_BUCKET/docker/$cksum"

src/ci/run.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,13 @@ fi
154154
# check for clock drifts. An HTTP URL is used instead of HTTPS since on Azure
155155
# Pipelines it happened that the certificates were marked as expired.
156156
datecheck() {
157-
echo "== clock drift check =="
157+
echo "::group::Clock drift check"
158158
echo -n " local time: "
159159
date
160160
echo -n " network time: "
161161
curl -fs --head http://ci-caches.rust-lang.org | grep ^Date: \
162162
| sed 's/Date: //g' || true
163-
echo "== end clock drift check =="
163+
echo "::endgroup::"
164164
}
165165
datecheck
166166
trap datecheck EXIT
@@ -177,6 +177,7 @@ retry make prepare
177177

178178
# Display the CPU and memory information. This helps us know why the CI timing
179179
# is fluctuating.
180+
echo "::group::Display CPU and Memory information"
180181
if isMacOS; then
181182
system_profiler SPHardwareDataType || true
182183
sysctl hw || true
@@ -186,6 +187,7 @@ else
186187
cat /proc/meminfo || true
187188
ncpus=$(grep processor /proc/cpuinfo | wc -l)
188189
fi
190+
echo "::endgroup::"
189191

190192
if [ ! -z "$SCRIPT" ]; then
191193
echo "Executing ${SCRIPT}"
@@ -218,4 +220,6 @@ if [ "$RUN_CHECK_WITH_PARALLEL_QUERIES" != "" ]; then
218220
CARGO_INCREMENTAL=0 ../x check
219221
fi
220222

223+
echo "::group::sccache stats"
221224
sccache --show-stats || true
225+
echo "::endgroup::"

src/tools/build_helper/src/ci.rs

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ impl CiEnv {
3636
}
3737

3838
pub mod gha {
39+
use std::sync::atomic::{AtomicBool, Ordering};
40+
41+
static GROUP_ACTIVE: AtomicBool = AtomicBool::new(false);
42+
3943
/// All github actions log messages from this call to the Drop of the return value
4044
/// will be grouped and hidden by default in logs. Note that nesting these does
4145
/// not really work.
@@ -45,6 +49,11 @@ pub mod gha {
4549
} else {
4650
eprintln!("{name}")
4751
}
52+
// https://github.com/actions/toolkit/issues/1001
53+
assert!(
54+
!GROUP_ACTIVE.swap(true, Ordering::Relaxed),
55+
"nested groups are not supported by GHA!"
56+
);
4857
Group(())
4958
}
5059

@@ -57,6 +66,10 @@ pub mod gha {
5766
if std::env::var_os("GITHUB_ACTIONS").is_some() {
5867
eprintln!("::endgroup::");
5968
}
69+
assert!(
70+
GROUP_ACTIVE.swap(false, Ordering::Relaxed),
71+
"group dropped but no group active!"
72+
);
6073
}
6174
}
6275
}

0 commit comments

Comments
 (0)