Skip to content

Commit cc62e36

Browse files
authored
Run CI without building runfiles links (#3057)
Round two of #2340
1 parent c2d74a2 commit cc62e36

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

.bazelci/presubmit.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
---
22
minimum_bazel_version: &minimum_bazel_version "7.4.1"
3+
minimum_bazel_shell_commands: &minimum_bazel_shell_commands
4+
- echo "build --build_runfile_links" >> user.bazelrc
35
no_bzlmod_bazel_version: &no_bzlmod_bazel_version "7.4.1"
46
no_bzlmod_shell_commands: &no_bzlmod_shell_commands
57
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
8+
- echo "build --build_runfile_links" >> user.bazelrc
69
- echo "7.4.1" > .bazelversion
710
no_bzlmod_rbe_shell_commands: &no_bzlmod_rbe_shell_commands
811
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
912
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
1013
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
14+
- echo "build --build_runfile_links" >> user.bazelrc
1115
- echo "7.4.1" > .bazelversion
1216
aspects_flags: &aspects_flags
1317
- "--config=rustfmt"
@@ -340,6 +344,7 @@ tasks:
340344
# If updating the minimum bazel version, please also update /docs/index.md
341345
bazel: *minimum_bazel_version
342346
platform: ubuntu1804
347+
shell_commands: *minimum_bazel_shell_commands
343348
build_targets: *default_linux_targets
344349
test_targets: *default_linux_targets
345350
coverage_targets: *default_linux_targets
@@ -348,6 +353,7 @@ tasks:
348353
name: "Min Bazel Version With Aspects"
349354
bazel: *minimum_bazel_version
350355
platform: ubuntu1804
356+
shell_commands: *minimum_bazel_shell_commands
351357
build_targets: *default_linux_targets
352358
test_targets: *default_linux_targets
353359
build_flags: *aspects_flags

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
## https://bazel.build/docs/best-practices#bazelrc-file
66
###############################################################################
77

8+
# Skip building runfiles links for faster builds.
9+
build --nobuild_runfile_links
10+
811
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
912
common --enable_platform_specific_config
1013

util/collect_coverage/collect_coverage.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::path::Path;
2525
use std::path::PathBuf;
2626
use std::process;
2727

28-
macro_rules! log {
28+
macro_rules! debug_log {
2929
($($arg:tt)*) => {
3030
if env::var("VERBOSE_COVERAGE").is_ok() {
3131
eprintln!($($arg)*);
@@ -38,7 +38,7 @@ fn find_metadata_file(execroot: &Path, runfiles_dir: &Path, path: &str) -> PathB
3838
return execroot.join(path);
3939
}
4040

41-
log!(
41+
debug_log!(
4242
"File does not exist in execroot, falling back to runfiles: {}",
4343
path
4444
);
@@ -74,7 +74,7 @@ fn find_test_binary(execroot: &Path, runfiles_dir: &Path) -> PathBuf {
7474
.join(configuration)
7575
.join(env::var("TEST_BINARY").unwrap());
7676

77-
log!(
77+
debug_log!(
7878
"TEST_BINARY is not found in runfiles. Falling back to: {}",
7979
test_binary.display()
8080
);
@@ -94,8 +94,8 @@ fn main() {
9494
runfiles_dir = execroot.join(runfiles_dir);
9595
}
9696

97-
log!("ROOT: {}", execroot.display());
98-
log!("RUNFILES_DIR: {}", runfiles_dir.display());
97+
debug_log!("ROOT: {}", execroot.display());
98+
debug_log!("RUNFILES_DIR: {}", runfiles_dir.display());
9999

100100
let coverage_output_file = coverage_dir.join("coverage.dat");
101101
let profdata_file = coverage_dir.join("coverage.profdata");
@@ -132,7 +132,7 @@ fn main() {
132132
.arg("--output")
133133
.arg(&profdata_file);
134134

135-
log!("Spawning {:#?}", llvm_profdata_cmd);
135+
debug_log!("Spawning {:#?}", llvm_profdata_cmd);
136136
let status = llvm_profdata_cmd
137137
.status()
138138
.expect("Failed to spawn llvm-profdata process");
@@ -153,18 +153,18 @@ fn main() {
153153
.arg(test_binary)
154154
.stdout(process::Stdio::piped());
155155

156-
log!("Spawning {:#?}", llvm_cov_cmd);
156+
debug_log!("Spawning {:#?}", llvm_cov_cmd);
157157
let child = llvm_cov_cmd
158158
.spawn()
159159
.expect("Failed to spawn llvm-cov process");
160160

161161
let output = child.wait_with_output().expect("llvm-cov process failed");
162162

163163
// Parse the child process's stdout to a string now that it's complete.
164-
log!("Parsing llvm-cov output");
164+
debug_log!("Parsing llvm-cov output");
165165
let report_str = std::str::from_utf8(&output.stdout).expect("Failed to parse llvm-cov output");
166166

167-
log!("Writing output to {}", coverage_output_file.display());
167+
debug_log!("Writing output to {}", coverage_output_file.display());
168168
fs::write(
169169
coverage_output_file,
170170
report_str
@@ -174,8 +174,8 @@ fn main() {
174174
.unwrap();
175175

176176
// Destroy the intermediate binary file so lcov_merger doesn't parse it twice.
177-
log!("Cleaning up {}", profdata_file.display());
177+
debug_log!("Cleaning up {}", profdata_file.display());
178178
fs::remove_file(profdata_file).unwrap();
179179

180-
log!("Success!");
180+
debug_log!("Success!");
181181
}

util/process_wrapper/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl fmt::Display for ProcessWrapperError {
6565

6666
impl std::error::Error for ProcessWrapperError {}
6767

68-
macro_rules! log {
68+
macro_rules! debug_log {
6969
($($arg:tt)*) => {
7070
if std::env::var_os("RULES_RUST_PROCESS_WRAPPER_DEBUG").is_some() {
7171
eprintln!($($arg)*);
@@ -135,7 +135,7 @@ fn main() -> Result<(), ProcessWrapperError> {
135135
Stdio::inherit()
136136
})
137137
.stderr(Stdio::piped());
138-
log!("{:#?}", command);
138+
debug_log!("{:#?}", command);
139139
let mut child = command
140140
.spawn()
141141
.map_err(|e| ProcessWrapperError(format!("failed to spawn child process: {}", e)))?;

0 commit comments

Comments
 (0)