Skip to content
Open
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: 1 addition & 1 deletion docs/design/test-guards.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The guards check the rules of `docs/design/tests.md`.
## In-graph prebuilt guard

- `//cli/prebuilt:guard_view` is a bool flag. When rules_dx is the root module and the flag is set, `@dx_prebuilt`, `@dx_gazelle`, `@php_launcher` and `@qt_launcher` serve `//cli/prebuilt:guard_stub` for every tool they build from source. Its `universal` scope keeps it in the exec configuration. `//cli/prebuilt:guard_view_test` checks that exec-configured hub tools resolve to the stub.
- `tools/testing/consumer/fixtures.bzl` splits `CONSUMER_FIXTURES` into `GO_GUARD_LANGS` and `JAVA_GUARD_LANGS`, held by the nested `go_prebuilt_guard_test` and `java_prebuilt_guard_test`, `IN_GRAPH_GUARD_LANGS`, `MACOS_IN_GRAPH_GUARD_LANGS`, `WINDOWS_IN_GRAPH_GUARD_LANGS` and `GUARD_PENDING`. `//tools/testing/consumer:in_graph_prebuilt_guard_test` fails unless each fixture is in exactly one list.
- `tools/testing/consumer/fixtures.bzl` splits `CONSUMER_FIXTURES` into `GO_GUARD_LANGS` and `JAVA_GUARD_LANGS`, held by the go and java guard cases of the nested, sharded `network_test`, `IN_GRAPH_GUARD_LANGS`, `MACOS_IN_GRAPH_GUARD_LANGS`, `WINDOWS_IN_GRAPH_GUARD_LANGS` and `GUARD_PENDING`. `//tools/testing/consumer:in_graph_prebuilt_guard_test` fails unless each fixture is in exactly one list.
- The nested guards pin every registry key of each `//cli/prebuilt:target_tools` tool and write `dx_target_guard`, whose `targets` depend on the hub target of each such tool through a split transition over `@rules_dx//tools/platforms:<key>` for each of its keys. They fail when a target tool does not select its download for each key.
- `//tools/testing/consumer:in_graph_prebuilt_guard` writes, per `IN_GRAPH_GUARD_LANGS` language or per language of its space-separated `--langs` list, `check` and `docs` targets whose `deps` carry the `dx check` and `dx docs` aspects over the non-manual rules of `@dx_api_fixtures//<lang>/tests/consumer`, injects them with `--inject_repository`, and runs `bazel cquery 'deps(...)'` with the flag and `--lockfile_mode=error`.
- Each label is mapped to the form a consumer sees: the fixtures repo is the main repo, `@@//` is `@@rules_dx+//` and `@@+` is `@@rules_dx++`. The compiled binaries are checked against `tools/testing/consumer/prebuilt_guard_allowlist.txt` by the rules of `//tools/testing/consumer:prebuilt_guard`.
Expand Down
1 change: 0 additions & 1 deletion tools/ci/test_budget_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//deploy/private/release/tests:release_consumer_smoke_test nested-cold-over-60 300
//examples/adopt-polyglot:consumer_test nested-cold-over-60 147
//tools/testing/consumer:cold_start_test nested-cold-over-60 140
//tools/testing/hermetic:cpp_rust nested-cold-over-60 417
android/tests/fixtures/adopt_android/app/BUILD.bazel no-size 3
android/tests/fixtures/adopt_android/native/BUILD.bazel no-size 2
Expand Down
141 changes: 62 additions & 79 deletions tools/testing/consumer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,6 @@ rust_test(
],
)

# A nested Bazel consumer build and test per language, each case in a fresh workspace with an empty
# output base. Fails when the repositories a one-language consumer fetches differ from
# cold_start/<lang>.txt or include another language's repositories.
nested_bazel_test(
name = "cold_start_test",
size = "small",
srcs = ["cold_start_test.rs"],
caches = "private",
crate_name = "cold_start_test",
crate_root = "cold_start_test.rs",
# //:module_srcs leaves out //patches/rules_py, which write_rules_py_patches copies.
data = [
"cold_start/go.txt",
"cold_start/java.txt",
"cold_start/rust.txt",
"//:module_srcs",
"//cli/prebuilt:registry",
"//patches/rules_py:patches",
"@dx_test_tags_sources//:consumer.json",
],
env = {
"DX_COLD_START_LISTS": "$(rlocationpath cold_start/go.txt) $(rlocationpath cold_start/java.txt) $(rlocationpath cold_start/rust.txt)",
"DX_CONSUMER_JSON": "$(rlocationpath @dx_test_tags_sources//:consumer.json)",
"DX_PREBUILT_REGISTRY": "$(rlocationpath //cli/prebuilt:registry)",
},
network = True,
deps = [
":prebuilt_guard",
"//cli/adopt:dx_adopt",
"//tools/testing:dx_testing",
"//tools/testing/nested:dx_nested",
],
)

rust_library(
name = "prebuilt_guard",
testonly = True,
Expand Down Expand Up @@ -134,39 +100,22 @@ rust_test(
deps = ["//tools/ci/ci_workflow"],
)

# A nested consumer of the DX_PREBUILT_GUARD_LANGS fixtures that pins every registry tool of the
# host, and every registry key of each DX_PREBUILT_TARGET_TOOLS tool, with a stub. Fails when it
# still compiles a rules_dx binary that prebuilt_guard_allowlist.txt does not name, or when a
# target tool does not select its download on each of its release platforms.
PREBUILT_GUARD_DATA = [
"prebuilt_guard_allowlist.txt",
"//:module_srcs",
"//cli/prebuilt:go_hub_targets",
"//cli/prebuilt:python_hub_targets",
"//cli/prebuilt:registry",
"//cli/prebuilt:target_tools",
"//patches/rules_py:patches",
"@dx_test_tags_sources//:consumer.json",
]

PREBUILT_GUARD_ENV = {
"DX_CONSUMER_JSON": "$(rlocationpath @dx_test_tags_sources//:consumer.json)",
"DX_PREBUILT_GO_HUB_TARGETS": "$(rlocationpath //cli/prebuilt:go_hub_targets)",
"DX_PREBUILT_GUARD_ALLOWLIST": "$(rlocationpath prebuilt_guard_allowlist.txt)",
"DX_PREBUILT_PYTHON_HUB_TARGETS": "$(rlocationpath //cli/prebuilt:python_hub_targets)",
"DX_PREBUILT_REGISTRY": "$(rlocationpath //cli/prebuilt:registry)",
"DX_PREBUILT_TARGET_TOOLS": "$(rlocationpath //cli/prebuilt:target_tools)",
}

nested_bazel_test(
name = "go_prebuilt_guard_test",
size = "small",
srcs = ["prebuilt_guard_test.rs"],
crate_name = "prebuilt_guard_test",
crate_root = "prebuilt_guard_test.rs",
data = PREBUILT_GUARD_DATA,
env = PREBUILT_GUARD_ENV | {"DX_PREBUILT_GUARD_LANGS": " ".join(GO_GUARD_LANGS)},
network = True,
# One shard per case. A go, java or rust consumer fails when the repositories it fetches into an empty
# output base differ from cold_start/<lang>.txt or include another language's repositories. A consumer
# of the GO_GUARD_LANGS or JAVA_GUARD_LANGS fixtures pins every registry tool of the host, and every
# registry key of each DX_PREBUILT_TARGET_TOOLS tool, with a stub. It fails when it still compiles a
# rules_dx binary that prebuilt_guard_allowlist.txt does not name, or when a target tool does not
# select its download on each of its release platforms.
rust_library(
name = "consumer_network",
testonly = True,
srcs = [
"cold_start_test.rs",
"consumer_network.rs",
"prebuilt_guard_test.rs",
],
crate_name = "consumer_network",
crate_root = "consumer_network.rs",
deps = [
":prebuilt_guard",
"//cli/adopt:dx_adopt",
Expand All @@ -175,21 +124,55 @@ nested_bazel_test(
],
)

COLD_START_LISTS = [
"cold_start/go.txt",
"cold_start/java.txt",
"cold_start/rust.txt",
]

COLD_START_ENV = {
"DX_COLD_START_LISTS": "$(rlocationpath cold_start/go.txt) $(rlocationpath cold_start/java.txt) $(rlocationpath cold_start/rust.txt)",
}

rust_test(
name = "consumer_network_lib_test",
size = "small",
crate = ":consumer_network",
data = COLD_START_LISTS,
env = COLD_START_ENV,
)

nested_bazel_test(
name = "java_prebuilt_guard_test",
name = "network_test",
size = "small",
srcs = ["prebuilt_guard_test.rs"],
crate_name = "prebuilt_guard_test",
crate_root = "prebuilt_guard_test.rs",
data = PREBUILT_GUARD_DATA,
env = PREBUILT_GUARD_ENV | {"DX_PREBUILT_GUARD_LANGS": " ".join(JAVA_GUARD_LANGS)},
network = True,
deps = [
":prebuilt_guard",
"//cli/adopt:dx_adopt",
"//tools/testing:dx_testing",
"//tools/testing/nested:dx_nested",
srcs = ["network_test.rs"],
caches = "private",
crate_name = "network_test",
crate_root = "network_test.rs",
# //:module_srcs leaves out //patches/rules_py, which write_rules_py_patches copies.
data = COLD_START_LISTS + [
"prebuilt_guard_allowlist.txt",
"//:module_srcs",
"//cli/prebuilt:go_hub_targets",
"//cli/prebuilt:python_hub_targets",
"//cli/prebuilt:registry",
"//cli/prebuilt:target_tools",
"//patches/rules_py:patches",
"@dx_test_tags_sources//:consumer.json",
],
env = COLD_START_ENV | {
"DX_CONSUMER_JSON": "$(rlocationpath @dx_test_tags_sources//:consumer.json)",
"DX_GO_GUARD_LANGS": " ".join(GO_GUARD_LANGS),
"DX_JAVA_GUARD_LANGS": " ".join(JAVA_GUARD_LANGS),
"DX_PREBUILT_GO_HUB_TARGETS": "$(rlocationpath //cli/prebuilt:go_hub_targets)",
"DX_PREBUILT_GUARD_ALLOWLIST": "$(rlocationpath prebuilt_guard_allowlist.txt)",
"DX_PREBUILT_PYTHON_HUB_TARGETS": "$(rlocationpath //cli/prebuilt:python_hub_targets)",
"DX_PREBUILT_REGISTRY": "$(rlocationpath //cli/prebuilt:registry)",
"DX_PREBUILT_TARGET_TOOLS": "$(rlocationpath //cli/prebuilt:target_tools)",
},
network = True,
shard_count = 5,
deps = [":consumer_network"],
)

real_source_target(
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/consumer/cold_start/go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The repositories a fresh Go-only consumer fetches on its first `bazel build //...` and
# `bazel test //...`, one canonical name per line. //tools/testing/consumer:cold_start_test
# `bazel test //...`, one canonical name per line. //tools/testing/consumer:network_test
# fails when this list grows or shrinks; when it fails it prints the measured list to paste here.
_main
apple_support+
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/consumer/cold_start/java.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The repositories a fresh Java-only consumer fetches on its first `bazel build //...`, `bazel test //...`
# and `dx check` analysis, one canonical name per line. //tools/testing/consumer:cold_start_test
# and `dx check` analysis, one canonical name per line. //tools/testing/consumer:network_test
# fails when this list grows or shrinks; when it fails it prints the measured list to paste here.
_main
apple_support+
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/consumer/cold_start/rust.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The repositories a fresh Rust-only consumer fetches on its first `bazel build //...` and
# `bazel test //...`, one canonical name per line. //tools/testing/consumer:cold_start_test
# `bazel test //...`, one canonical name per line. //tools/testing/consumer:network_test
# fails when this list grows or shrinks; when it fails it prints the measured list to paste here.
_main
apple_support+
Expand Down
Loading
Loading