Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ common:bb --remote_cache=grpcs://remote.buildbuddy.io
common:bb --remote_cache_compression
common:bb --remote_timeout=10m
common:bb --credential_helper=remote.buildbuddy.io=%workspace%/tools/buildbuddy-credential-helper.sh
common:bb-ro --config=bb
common:bb-ro --noremote_upload_local_results
common:ci --remote_cache=grpcs://remote.buildbuddy.io
common:ci --experimental_remote_downloader=grpcs://remote.buildbuddy.io
common:ci --experimental_remote_downloader_local_fallback
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ tools/dx test --affected -- --config=bb

`--config=bb` reads the key from the environment through `tools/buildbuddy-credential-helper.sh` on Linux and macOS. Never put the key in `user.bazelrc` or any other rc file, and never pass `--announce_rc`.

A read-only key makes Bazel warn on every build that it cannot upload results. Use `--config=bb-ro` instead of `--config=bb`.

## Issues and labels

Use the bug template. Paste `dx status`.
Expand Down
3 changes: 2 additions & 1 deletion cli/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
)]

use std::io::{self, Write};
use std::io::{self, IsTerminal, Write};
use std::path::Path;

use dx_cli::bazel_restart::{RestartingQueryRunner, RestartingRunner};
Expand Down Expand Up @@ -248,6 +248,7 @@ fn run() -> i32 {
return usage_error(code, &error.to_string(), json, command);
}
};
invocation.piped = !io::stdout().is_terminal();
// LCOV_EXCL_STOP - reason: end thin run shim, issue: 1055, policy: docs/cli/commands/build-test-coverage.md
dx_adopt::refresh_stale_pins_from_env();
dx_cli::exec::set_usage_command(invocation.command);
Expand Down
20 changes: 17 additions & 3 deletions cli/plan/src/args/invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ pub struct Invocation {
pub bench_compare: Option<String>,
pub path_only: bool,
pub agent: bool,
/// Stdout is not a terminal.
pub piped: bool,
pub bazel_startup_options: Vec<String>,
}

Expand All @@ -352,9 +354,10 @@ impl Invocation {
self.command == Command::Update && self.targets.len() == 2 && is_version(&self.targets[1])
}

/// Bazel UI flags that silence progress output in agent JSON sessions.
/// Bazel UI flags that silence progress output in agent JSON sessions and piped runs; `-v` keeps Bazel output.
pub fn agent_quiet_flags(&self) -> Vec<String> {
if self.agent && self.output == OutputMode::Json {
let agent_json = self.agent && self.output == OutputMode::Json;
if (agent_json || self.piped) && !self.verbose {
AGENT_QUIET_FLAGS
.iter()
.map(|flag| (*flag).to_owned())
Expand All @@ -364,7 +367,7 @@ impl Invocation {
}
}

/// Bazel options for the run: agent JSON sessions get no progress output.
/// Bazel options for the run: agent JSON sessions and piped runs get no progress output.
pub fn quiet_bazel_options(&self) -> Vec<String> {
let mut options = self.agent_quiet_flags();
options.extend(self.bazel_options.iter().cloned());
Expand Down Expand Up @@ -743,6 +746,7 @@ mod tests {
bench_compare: None,
path_only: false,
agent: false,
piped: false,
bazel_startup_options: Vec::new(),
}
}
Expand Down Expand Up @@ -1117,6 +1121,16 @@ mod tests {
AGENT_QUIET_FLAGS.iter().map(ToString::to_string).collect()
}

#[test]
fn piped_runs_are_quiet_unless_verbose() {
let mut inv = parsed(&["build"]);
assert!(inv.quiet_bazel_options().is_empty());
inv.piped = true;
assert_eq!(inv.quiet_bazel_options(), quiet_flags());
inv.verbose = true;
assert!(inv.quiet_bazel_options().is_empty());
}

#[test]
fn raw_bazel_options_never_carry_agent_quiet_flags() {
let session = agent(&["build", "--output=json", "--", "--jobs=4"]);
Expand Down
1 change: 1 addition & 0 deletions cli/plan/src/args/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ fn parse_inner<S: AsRef<OsStr>>(
bench_compare: compare,
path_only,
agent,
piped: false,
bazel_startup_options,
})
}
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/commands/build-test-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ dx coverage [--here] [--affected] [--timings] [--min-coverage <percent>] [--min-

`--debug` and `--release` conflict. Both change compilation only.

When stdout is not a terminal, dx passes Bazel the quiet flags `--noshow_progress`, `--noshow_loading_progress`, `--noshow_timestamps`, `--curses=no`, `--ui_event_filters=-info,-debug` and `--test_summary=none`. `-v` keeps full Bazel output.

## Scopes

No scope means `//...`. Pass labels, patterns, files, or directories. A file runs its owning targets. For `test` and `coverage`, a file runs the tests that depend on its owners. A `manual` test runs only when it owns the file.
Expand Down
7 changes: 7 additions & 0 deletions docs/remote-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ Pass the config after `--`.
dx build //... -- --config=cache
```

A read-only key makes Bazel warn that the cache does not accept uploads. Add a config that turns uploads off and use it with that key.

```text
common:cache-ro --config=cache
common:cache-ro --noremote_upload_local_results
```

`dx` still adds its shared disk cache locally, so Bazel uses both caches. Under `CI=true`, `dx` adds no disk cache.

## Backends
Expand Down
Loading