tools/bazel/ci_analytics_extract.py turns a lane's BEP file, compact
execution log and JSON profile into a redacted ci-analytics-summary
(timing, per-mnemonic cache classes, cold actions, test results,
repo-fetch time): only validated labels, mnemonics, enums and numbers
leave the runner, never an endpoint, cert/key path, env value, token
or hostname. Every lane's "CI analytics summary" step runs the
extractor and uploads its output as ci-analytics-<lane>-<run_attempt>
(7-day retention); CHECK_RUN_ID uses the real job.check_run_id
context (requires actionlint >= 1.7.8), and both the summary and
upload steps are continue-on-error, the summary capped at
timeout-minutes: 3, and both gated on !cancelled() (not always(),
which also runs after a workflow cancellation).
The extractor, its 62-case unittest file, and testdata/ci_analytics/
(the real/* Bazel 9.2.0 fixtures, poisoned-bep.json, mismatch.bep.jsonl
and regen.sh) are vendored byte-identical from gascity's
ci/analytics-extractor slice (final squashed commit
00161373bc7bbfcef8d6a05ac5ce70409fc7f2ac), which is canonical for this
pair the same way tools/rbe/cache-zstd-probe.sh is a byte copy.
Fixtures are regenerated under env -i with every BEP field stripped
unless it's on an explicit allowlist, and the compact exec log is
committed decompressed (*.binpb) rather than as a zstd frame, so
nothing opaque reaches version control.
scripts/ci_analytics_extract_test.go is the thin Go wrapper:
TestCIAnalyticsExtractorIsPinnedToGascity pins both vendored files'
sha256 so local drift is caught, and TestCIAnalyticsExtractUnitTests
runs gascity's unittest file in place. scripts/ci_analytics_workflow_test.go's
TestCIAnalyticsStepsAreSafeAndBounded mirrors gascity's pin test,
adapted to beads' 8 separately-named lane jobs: continue-on-error,
timeout-minutes bounds, no raw ${{ }} expression in run:, !cancelled()
required in if:, correct per-lane upload artifact name/path, and
CHECK_RUN_ID == ${{ job.check_run_id }}, for every lane.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
179 lines
5.9 KiB
Python
179 lines
5.9 KiB
Python
load("@rules_go//go:def.bzl", "go_test")
|
|
|
|
# CI and repo-policy tests: they parse the workflows, run the CI shell scripts
|
|
# against fixtures, and check repository-wide rules (BUILD tag taxonomy, skip
|
|
# allowlist, managed BUILD blocks, shard manifests, tracked-file scans) over
|
|
# //:repo_files, the checkout as Bazel sees it.
|
|
#
|
|
# No tags: they run remotely like any other target. The scripts and fixtures
|
|
# run bash, git, python3, jq, yq, curl, openssl, unzip and coreutils from the
|
|
# executor (the rbe-west worker image, or the runner in fork-cache mode); a
|
|
# missing tool fails the test under Bazel instead of skipping it
|
|
# (host_tools_test.go), so a cached pass never stands for an executor that
|
|
# could not run it. Go and the release formula come in hermetically.
|
|
go_test(
|
|
name = "scripts_test",
|
|
srcs = [
|
|
"bazel_autofix_push_test.go",
|
|
"bazel_cache_mode_test.go",
|
|
"bazel_farm_workflow_test.go",
|
|
"bazel_fork_mode_test.go",
|
|
"bazel_hermetic_cc_test.go",
|
|
"bazel_policy_test.go",
|
|
"bazel_rbe_prewarm_test.go",
|
|
"bazel_skip_allowlist_test.go",
|
|
"check_build_tags_test.go",
|
|
"check_doc_freshness_test.go",
|
|
"check_release_cross_compile_test.go",
|
|
"check_testing_short_test.go",
|
|
"check_winget_portable_alias_test.go",
|
|
"ci_actions_policy_test.go",
|
|
"ci_analytics_extract_test.go",
|
|
"ci_analytics_workflow_test.go",
|
|
"ci_blacksmith_runner_test.go",
|
|
"ci_capability_selector_test.go",
|
|
"ci_f7b_review_test.go",
|
|
"ci_f7c_advisory_test.go",
|
|
"ci_merge_queue_test.go",
|
|
"ci_workflow_apt_get_timeout_test.go",
|
|
"ci_workflow_test.go",
|
|
"complexity_script_test.go",
|
|
"conformance_script_test.go",
|
|
"embedded_shard_count_test.go",
|
|
"host_tools_test.go",
|
|
"install_dolt_test.go",
|
|
"makefile_bazel_primary_test.go",
|
|
"managed_local_lane_test.go",
|
|
"migration_corpus_bazel_test.go",
|
|
"nogo_lint_policy_test.go",
|
|
"pr_lanes_bazel_coverage_test.go",
|
|
"pr_preflight_test.go",
|
|
"pr_risk_bazel_coverage_test.go",
|
|
"pre_push_suite_test.go",
|
|
"pull_dolt_image_test.go",
|
|
"rbe_worker_env_test.go",
|
|
"release_script_test.go",
|
|
"repo_helpers_test.go",
|
|
"required_suite_test.go",
|
|
"test_script_test.go",
|
|
"upgrade_smoke_loop_test.go",
|
|
"windows_test_binaries_manifest_test.go",
|
|
],
|
|
data = [
|
|
"//:repo_files",
|
|
"@beads_formulas//:beads-release.formula.toml",
|
|
"@go_sdk//:bin/go",
|
|
"@go_sdk//:files",
|
|
],
|
|
# The release formula lives in .beads/ (in .bazelignore: it also holds
|
|
# live bd data), so it comes in through its own local repository. The Go
|
|
# SDK is go.mod's toolchain, whatever go the executor has on PATH.
|
|
env = {
|
|
"BEADS_TEST_GO": "$(rlocationpath @go_sdk//:bin/go)",
|
|
"BEADS_TEST_RELEASE_FORMULA": "$(rlocationpath @beads_formulas//:beads-release.formula.toml)",
|
|
},
|
|
deps = [
|
|
"//internal/formula",
|
|
"//internal/testutil/bazeltest",
|
|
"//scripts/internal/testbash",
|
|
"@in_gopkg_yaml_v3//:yaml_v3",
|
|
],
|
|
)
|
|
|
|
# pr.yml's check-doc-freshness-platforms Linux leg: `go test
|
|
# -tags integration ./scripts -count=1 -run '^(TestDocFreshness.*|
|
|
# TestRequiredSuiteContract)$' -args -required-suite=doc-freshness`, whose
|
|
# TestMain fails unless exactly the doc-freshness inventory is compiled and
|
|
# selected. scripts_test runs those tests too (in the integration lane); this
|
|
# target adds the inventory and selection contract, over only the files the
|
|
# suite reads (its fixtures copy check-doc-freshness.sh). The macOS and
|
|
# Windows legs stay in pr.yml.
|
|
# Tags:
|
|
# integration-only: every TestDocFreshness test is //go:build integration,
|
|
# so --config=integration's lane runs it.
|
|
go_test(
|
|
name = "doc_freshness_required_test",
|
|
srcs = [
|
|
"check_doc_freshness_test.go",
|
|
"repo_helpers_test.go",
|
|
"required_suite_test.go",
|
|
],
|
|
args = [
|
|
"-test.count=1",
|
|
"-test.run=^(TestDocFreshness.*|TestRequiredSuiteContract)$$",
|
|
"-required-suite=doc-freshness",
|
|
],
|
|
data = ["check-doc-freshness.sh"],
|
|
tags = ["integration-only"],
|
|
deps = [
|
|
"//internal/testutil/bazeltest",
|
|
"//scripts/internal/testbash",
|
|
],
|
|
)
|
|
|
|
exports_files(
|
|
["migration-test/release-catalog.json"],
|
|
visibility = ["//scripts/migration-test/catalog:__pkg__"],
|
|
)
|
|
|
|
# The historical-upgrade harness (scripts/migration-test) and the public
|
|
# SQLite bridge it drives, for //tests/migration's per-release targets.
|
|
filegroup(
|
|
name = "migration_harness",
|
|
srcs = [
|
|
"migrate-legacy-to-current.sh",
|
|
"migration-test/historical-dolt-upgrade-test.sh",
|
|
"migration-test/legacy-bridge-test.sh",
|
|
"migration-test/lib/binary.sh",
|
|
"migration-test/lib/versions.sh",
|
|
],
|
|
visibility = ["//tests/migration:__pkg__"],
|
|
)
|
|
|
|
exports_files(
|
|
["upgrade-smoke-test.sh"],
|
|
visibility = ["//tests/upgrade_smoke:__pkg__"],
|
|
)
|
|
|
|
exports_files(
|
|
[
|
|
"ci/fmt-check.sh",
|
|
"ci/lib/timing.sh",
|
|
"ci/pr-lint.sh",
|
|
],
|
|
visibility = ["//scripts/prlintmake:__pkg__"],
|
|
)
|
|
|
|
exports_files(
|
|
["ci/gofmt-bin.sh"],
|
|
visibility = ["//scripts/prlintmake:__pkg__"],
|
|
)
|
|
|
|
# The compatibility entrypoint whose exit-status contract
|
|
# //scripts/check-versions:check-versions_test drives.
|
|
exports_files(
|
|
["check-versions.sh"],
|
|
visibility = ["//scripts/check-versions:__pkg__"],
|
|
)
|
|
|
|
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
|
|
|
|
filegroup(
|
|
name = "repo_files",
|
|
srcs = glob(
|
|
["**"],
|
|
exclude = [
|
|
"**/*.db",
|
|
"**/*.exe",
|
|
"**/*.out",
|
|
"**/*.prof",
|
|
"**/*.pyc",
|
|
"**/*.test",
|
|
"**/__pycache__/**",
|
|
"**/node_modules/**",
|
|
],
|
|
),
|
|
visibility = ["//:__pkg__"],
|
|
)
|
|
|
|
# --- end repo_files ---
|