Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CI without building runfiles links #3057

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
---
minimum_bazel_version: &minimum_bazel_version "7.4.1"
minimum_bazel_shell_commands: &minimum_bazel_shell_commands
- echo "build --build_runfile_links" >> user.bazelrc
no_bzlmod_bazel_version: &no_bzlmod_bazel_version "7.4.1"
no_bzlmod_shell_commands: &no_bzlmod_shell_commands
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
- echo "build --build_runfile_links" >> user.bazelrc
- echo "7.4.1" > .bazelversion
no_bzlmod_rbe_shell_commands: &no_bzlmod_rbe_shell_commands
- sed -i 's/^# load("@bazel_ci_rules/load("@bazel_ci_rules/' WORKSPACE.bazel
- sed -i 's/^# rbe_preconfig/rbe_preconfig/' WORKSPACE.bazel
- echo "common --noenable_bzlmod --enable_workspace" >> user.bazelrc
- echo "build --build_runfile_links" >> user.bazelrc
- echo "7.4.1" > .bazelversion
aspects_flags: &aspects_flags
- "--config=rustfmt"
Expand Down Expand Up @@ -340,6 +344,7 @@ tasks:
# If updating the minimum bazel version, please also update /docs/index.md
bazel: *minimum_bazel_version
platform: ubuntu1804
shell_commands: *minimum_bazel_shell_commands
build_targets: *default_linux_targets
test_targets: *default_linux_targets
coverage_targets: *default_linux_targets
Expand All @@ -348,6 +353,7 @@ tasks:
name: "Min Bazel Version With Aspects"
bazel: *minimum_bazel_version
platform: ubuntu1804
shell_commands: *minimum_bazel_shell_commands
build_targets: *default_linux_targets
test_targets: *default_linux_targets
build_flags: *aspects_flags
Expand Down
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
## https://bazel.build/docs/best-practices#bazelrc-file
###############################################################################

# Skip building runfiles links for faster builds.
build --nobuild_runfile_links

# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
common --enable_platform_specific_config

Expand Down
22 changes: 11 additions & 11 deletions util/collect_coverage/collect_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::path::Path;
use std::path::PathBuf;
use std::process;

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

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

log!(
debug_log!(
"TEST_BINARY is not found in runfiles. Falling back to: {}",
test_binary.display()
);
Expand All @@ -94,8 +94,8 @@ fn main() {
runfiles_dir = execroot.join(runfiles_dir);
}

log!("ROOT: {}", execroot.display());
log!("RUNFILES_DIR: {}", runfiles_dir.display());
debug_log!("ROOT: {}", execroot.display());
debug_log!("RUNFILES_DIR: {}", runfiles_dir.display());

let coverage_output_file = coverage_dir.join("coverage.dat");
let profdata_file = coverage_dir.join("coverage.profdata");
Expand Down Expand Up @@ -132,7 +132,7 @@ fn main() {
.arg("--output")
.arg(&profdata_file);

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

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

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

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

log!("Writing output to {}", coverage_output_file.display());
debug_log!("Writing output to {}", coverage_output_file.display());
fs::write(
coverage_output_file,
report_str
Expand All @@ -174,8 +174,8 @@ fn main() {
.unwrap();

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

log!("Success!");
debug_log!("Success!");
}
4 changes: 2 additions & 2 deletions util/process_wrapper/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl fmt::Display for ProcessWrapperError {

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

macro_rules! log {
macro_rules! debug_log {
($($arg:tt)*) => {
if std::env::var_os("RULES_RUST_PROCESS_WRAPPER_DEBUG").is_some() {
eprintln!($($arg)*);
Expand Down Expand Up @@ -135,7 +135,7 @@ fn main() -> Result<(), ProcessWrapperError> {
Stdio::inherit()
})
.stderr(Stdio::piped());
log!("{:#?}", command);
debug_log!("{:#?}", command);
let mut child = command
.spawn()
.map_err(|e| ProcessWrapperError(format!("failed to spawn child process: {}", e)))?;
Expand Down