Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- `pr-links.yml`: on pull requests, including body edits, runs `producers_bin --pr-links` on the body and commit messages. It also runs on `merge_group`, where it reads the body of the pull request named in the queue ref, and `.github/rulesets/main.json` requires it on main. It fails when the body has no `Closes #N`, `Part of #N` or `No issue: <reason>` line, or when the body or a commit names an issue with a work phrase ("fixes", "part of", "slice", "draft for", "implements", "fixed by this PR") that no `Closes` or `Part of` line links. Replay a body locally with `GITHUB_EVENT_PATH=event.json bazel-bin/tools/ci/producers/producers_bin --pr-links [COMMITS_FILE]`.
- `ci.yml`: this repository's own `ci` gate. A failed Windows preflight build uploads `rmeta-diagnostics-<platform>` (#4850).
- When the `gate` check or the `evidence.yml` test task fails, `producers_bin --test-log-tails` prints the last 80 lines of each failing test's `test.log` in its own `::group::` in the job log, for the first 20 failing tests.
- `ci.yml` jobs `preflight` and `quality-matrix` upload the compact execution log of their test step as `exec-log-<job>-<platform>` for 7 days. To see why spawns missed the cache, download the artifact from two runs and run `bazel run //tools/testing:determinism_check -- diff <first.log> <second.log>`. It prints the 20 slowest spawns that ran in the second run (`--top N` changes the count), each with the inputs, args and env that differ from the first run, or why it could not hit the cache.
- `ci.yml` job `determinism` builds `//appimage/...` and `//cli/archive/...` twice in fresh output bases with no cache and compares the execution logs against `tools/ci/determinism_allowlist.txt`.
- `issue-labels.yml`: daily warning for open issues older than one day, except pinned ones, that have no P0 to P3 label. Writes a job summary. Runs on `ubuntu-slim`.
A second job warns about labels named in `CONTRIBUTING.md` or issue template front matter that do not exist in the repository (#6643).
Expand Down
34 changes: 32 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,23 @@ jobs:
run: |
# shellcheck disable=SC2086
set -- $BAZEL_CONFIG $BB_ARGS
mkdir -p "$RUNNER_TEMP/exec-log"
# shellcheck disable=SC2086
bazel test --noshow_progress --nocache_test_results --flaky_test_attempts=2 --test_output=all "$@" //tools/testing:preflight_smoke_test //cli/env:bootstrap_test //cc/tests/fixtures/hello:hello_test //powershell/tests/fixtures/hello:hello_test //zig/tests/fixtures/zig_app/... //dart/tests/fixtures/dart_app/... //dart/tests/runtime:all //dart/private/tools:all //zig/tests/fixtures/hello:all //julia/tests/fixtures/hello:all //julia/tests/fixtures/julia_app/... //julia/private/tools/... 2>&1 | tee "$RUNNER_TEMP/launch-smoke.log"
bazel test --noshow_progress --nocache_test_results --flaky_test_attempts=2 --test_output=all "--execution_log_compact_file=$RUNNER_TEMP/exec-log/launch-smoke.log" "$@" //tools/testing:preflight_smoke_test //cli/env:bootstrap_test //cc/tests/fixtures/hello:hello_test //powershell/tests/fixtures/hello:hello_test //zig/tests/fixtures/zig_app/... //dart/tests/fixtures/dart_app/... //dart/tests/runtime:all //dart/private/tools:all //zig/tests/fixtures/hello:all //julia/tests/fixtures/hello:all //julia/tests/fixtures/julia_app/... //julia/private/tools/... 2>&1 | tee "$RUNNER_TEMP/launch-smoke.log"
- name: Check the upload holds no secret
id: scan-exec-log
if: always()
uses: ./.github/actions/assert-no-secret
with:
path: ${{ runner.temp }}/exec-log
- name: Upload the execution log
if: ${{ always() && steps.scan-exec-log.outcome == 'success' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: exec-log-preflight-${{ matrix.platform }}
path: ${{ runner.temp }}/exec-log
retention-days: 7
if-no-files-found: ignore
- name: Run the PyPI probe verification
run: |
# shellcheck disable=SC2086
Expand Down Expand Up @@ -1069,8 +1084,23 @@ jobs:
run: |
# shellcheck disable=SC2086
set -- $BAZEL_CONFIG $BB_ARGS
mkdir -p "$RUNNER_TEMP/exec-log"
# shellcheck disable=SC2086
bazel test --noshow_progress --nocache_test_results --flaky_test_attempts=2 --test_output=errors "$@" $QUALITY_TARGETS 2>&1 | tee "$RUNNER_TEMP/quality-matrix.log"
bazel test --noshow_progress --nocache_test_results --flaky_test_attempts=2 --test_output=errors "--execution_log_compact_file=$RUNNER_TEMP/exec-log/quality-matrix.log" "$@" $QUALITY_TARGETS 2>&1 | tee "$RUNNER_TEMP/quality-matrix.log"
- name: Check the upload holds no secret
id: scan-exec-log
if: always()
uses: ./.github/actions/assert-no-secret
with:
path: ${{ runner.temp }}/exec-log
- name: Upload the execution log
if: ${{ always() && steps.scan-exec-log.outcome == 'success' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: exec-log-quality-matrix-${{ matrix.platform }}
path: ${{ runner.temp }}/exec-log
retention-days: 7
if-no-files-found: ignore
- name: Write job summary
if: always()
env:
Expand Down
4 changes: 4 additions & 0 deletions tools/testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ rust_test(
normal_dev = True,
),
compile_data = [
"exec_log_fixtures/cache_first.log.zst",
"exec_log_fixtures/cache_second.log.zst",
"exec_log_fixtures/first.log.zst",
"exec_log_fixtures/second.log.zst",
],
Expand Down Expand Up @@ -355,6 +357,8 @@ rust_test(
name = "determinism_check_test",
size = "small",
compile_data = [
"exec_log_fixtures/cache_first.log.zst",
"exec_log_fixtures/cache_second.log.zst",
"exec_log_fixtures/first.log.zst",
"exec_log_fixtures/second.log.zst",
],
Expand Down
87 changes: 82 additions & 5 deletions tools/testing/determinism_check.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Builds the given patterns twice in fresh output bases and fails when the exec logs differ.
//! `diff <first> <second> [--top N]` instead names why the slowest spawns of the second log missed the cache.

use dx_testing::exec_log;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -48,7 +49,13 @@ fn run(argv: &[String], workspace: &Path) -> Result<(), String> {
}
}

fn build(bazel: &str, out: &Path, name: &str, patterns: &[String], workspace: &Path) -> Result<(), String> {
fn build(
bazel: &str,
out: &Path,
name: &str,
patterns: &[String],
workspace: &Path,
) -> Result<(), String> {
let start = Instant::now();
run(&build_argv(bazel, out, name, patterns), workspace)?;
println!("{name}: {}s", start.elapsed().as_secs());
Expand All @@ -62,11 +69,47 @@ fn build(bazel: &str, out: &Path, name: &str, patterns: &[String], workspace: &P
)
}

/// Spawns `diff` reports when `--top` is not given.
const TOP: usize = 20;

fn diff_mode(args: &[String], cwd: &Path) -> Result<Vec<String>, String> {
let mut logs = Vec::new();
let mut top = TOP;
let mut args = args.iter();
while let Some(arg) = args.next() {
if arg == "--top" {
let value = args.next().ok_or("--top needs a number")?;
top = value.parse().map_err(|e| format!("--top {value}: {e}"))?;
} else {
logs.push(cwd.join(arg));
}
}
let [first, second] = logs.as_slice() else {
return Err("diff takes two execution logs".to_owned());
};
let parse = |path: &PathBuf| {
let bytes = std::fs::read(path).map_err(|e| format!("{}: {e}", path.display()))?;
exec_log::ExecLog::parse(&bytes).map_err(|e| format!("{}: {e}", path.display()))
};
exec_log::diff(&parse(first)?, &parse(second)?, top)
}

fn main() -> Result<(), String> {
let argv: Vec<String> = std::env::args().skip(1).collect();
if let Some(("diff", rest)) = argv.split_first().map(|(mode, rest)| (mode.as_str(), rest)) {
let cwd = std::env::var_os("BUILD_WORKING_DIRECTORY").map_or_else(
|| std::env::current_dir().map_err(|e| e.to_string()),
|dir| Ok(PathBuf::from(dir)),
)?;
for line in diff_mode(rest, &cwd)? {
println!("{line}");
}
return Ok(());
}
let mut bazel = None;
let mut out = None;
let mut patterns = Vec::new();
let mut args = std::env::args().skip(1);
let mut args = argv.into_iter();
while let Some(arg) = args.next() {
match arg.as_str() {
"--bazel" => bazel = args.next(),
Expand All @@ -90,8 +133,8 @@ fn main() -> Result<(), String> {
std::fs::read(&path).map_err(|e| format!("{}: {e}", path.display()))
};
let allowlist = workspace.join(ALLOWLIST);
let allowlist = std::fs::read_to_string(&allowlist)
.map_err(|e| format!("{}: {e}", allowlist.display()))?;
let allowlist =
std::fs::read_to_string(&allowlist).map_err(|e| format!("{}: {e}", allowlist.display()))?;
let found = compare(&read("first")?, &read("second")?, &allowlist)?;
for line in &found {
eprintln!("{line}");
Expand All @@ -109,11 +152,18 @@ mod tests {

const FIRST: &[u8] = include_bytes!("exec_log_fixtures/first.log.zst");
const SECOND: &[u8] = include_bytes!("exec_log_fixtures/second.log.zst");
const CACHE_FIRST: &[u8] = include_bytes!("exec_log_fixtures/cache_first.log.zst");
const CACHE_SECOND: &[u8] = include_bytes!("exec_log_fixtures/cache_second.log.zst");
const STAMPED: &str = "//:stamped Genrule bazel-out/k8-fastbuild/bin/stamped.txt";

#[test]
fn the_build_argv_is_exact() {
let argv = build_argv("/b/bazel", Path::new("/o"), "first", &["//a/...".to_owned()]);
let argv = build_argv(
"/b/bazel",
Path::new("/o"),
"first",
&["//a/...".to_owned()],
);
assert_eq!(
argv,
[
Expand All @@ -139,6 +189,33 @@ mod tests {
assert!(found[0].contains("//:stamped"));
}

#[test]
fn diff_mode_reads_two_logs() {
let dir = PathBuf::from(std::env::var("TEST_TMPDIR").unwrap());
std::fs::write(dir.join("cache_first.log.zst"), CACHE_FIRST).unwrap();
std::fs::write(dir.join("cache_second.log.zst"), CACHE_SECOND).unwrap();
let args =
|list: &[&str]| -> Vec<String> { list.iter().map(|a| (*a).to_owned()).collect() };
let lines = diff_mode(
&args(&["cache_first.log.zst", "cache_second.log.zst"]),
&dir,
)
.unwrap();
assert!(
lines.iter().any(|l| l.starts_with(" input changed.txt: ")),
"{lines:?}"
);
let lines = diff_mode(
&args(&["--top", "1", "cache_first.log.zst", "cache_second.log.zst"]),
&dir,
)
.unwrap();
assert_eq!(lines.len(), 2, "{lines:?}");
assert!(diff_mode(&args(&["cache_first.log.zst"]), &dir).is_err());
assert!(diff_mode(&args(&["--top", "x", "a", "b"]), &dir).is_err());
assert!(diff_mode(&args(&["missing", "cache_second.log.zst"]), &dir).is_err());
}

#[test]
fn the_stamped_line_clears_the_report() {
assert_eq!(
Expand Down
Binary file added tools/testing/exec_log_fixtures/cache_first.log.zst
Binary file not shown.
Binary file added tools/testing/exec_log_fixtures/cache_second.log.zst
Binary file not shown.
Loading
Loading