From 9919d1df7cca38c5224aa4ec1e2e1ec10709b105 Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 11 Sep 2024 15:16:19 +0100 Subject: [PATCH] Allow build/test on the entire repo (#341) Clean up constraints and CI to allow running all targets without the need to exclude subtrees based on platform. --- README.md | 8 ++++---- docker/sysbox/README.md | 6 +++--- docker/sysbox/dind_test/BUILD | 3 ++- infra/test-all.py | 16 ++-------------- platform/linux_x64/BUILD | 3 +++ platform/windows_x64/BUILD | 3 +++ 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 75121f28..44799218 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ locally before attempting remote execution. Build them all with: ```sh - bazel build -- //... -//platform/... + bazel build //... ``` - `swift`: @@ -78,7 +78,7 @@ locally before attempting remote execution. Test them all with: ```sh - bazel test -- //... -//platform/... + bazel test //... ``` - `swift`: @@ -130,7 +130,7 @@ build --config=engflow Build them all with: ```sh - bazel build -- //... -//platform/... + bazel build //... ``` - `swift`: @@ -150,7 +150,7 @@ build --config=engflow Test them all with: ```sh - bazel test -- //... -//platform/... + bazel test //... ``` - `swift`: diff --git a/docker/sysbox/README.md b/docker/sysbox/README.md index 98ee88f9..2b9fc4bb 100644 --- a/docker/sysbox/README.md +++ b/docker/sysbox/README.md @@ -11,14 +11,14 @@ Usage: a container tha uses `sysbox` to run nested docker containers. - Modify the `dind_test/BUILD`. Change the `container-image` attribute of the `sh_test` -rule to point the container you produced in the previous step. +rule to point the container you produced in the previous step. -- Modify the `.bazelrc` file at the top level of the repo to use your own endpoint. +- Modify the `.bazelrc` file at the top level of the repo to use your own endpoint. - Run the following command: ```sh -bazel test --config= --test_output=all //docker/sysbox/dind_test/... +bazel test --config= --test_output=all //docker/sysbox/dind_test:check_docker ``` # How does it work? diff --git a/docker/sysbox/dind_test/BUILD b/docker/sysbox/dind_test/BUILD index 90b40b97..be94eb9b 100644 --- a/docker/sysbox/dind_test/BUILD +++ b/docker/sysbox/dind_test/BUILD @@ -28,4 +28,5 @@ sh_test( # DO NOT ENABLE!!! "dockerPrivileged": "True", # sysbox containers will refuse to start }, -) \ No newline at end of file + tags = ["manual"] +) diff --git a/infra/test-all.py b/infra/test-all.py index a7c04654..bc3c3ef2 100644 --- a/infra/test-all.py +++ b/infra/test-all.py @@ -7,19 +7,7 @@ def main(): # All targets that can run in any environment. targets = [ - "//cpp/...", - "//docker/network/...", - "//docker/sandbox/...", - "//genrules/...", - "//go/...", - "//java/...", - "//kotlin/...", - "//scala/...", - "//typescript/...", - "//csharp/...", - "//perl/...", - "//python/...", - "//swift/...", + "//...", ] for key in ("ARCH", "OPAL_RPC_CREDENTIALS", "OS", "REMOTE_EXECUTION"): @@ -42,7 +30,7 @@ def main(): ] # The //docker/sysbox/... targets should only run in linux + remote if os.getenv("REMOTE_EXECUTION") == "true" and os.getenv("OS") == "linux": - targets += ["//docker/sysbox/...",] + targets += ["//docker/sysbox/dind_test:check_docker",] args = ["bazel", "test"] + flags + ["--"] + targets result = subprocess.run(args) diff --git a/platform/linux_x64/BUILD b/platform/linux_x64/BUILD index 72237f89..d8805818 100644 --- a/platform/linux_x64/BUILD +++ b/platform/linux_x64/BUILD @@ -37,6 +37,9 @@ cc_toolchain_suite( "k8|clang": ":cc-compiler-k8", "k8": ":cc-compiler-k8", }, + target_compatible_with = [ + "@platforms//os:linux", + ], ) cc_toolchain( diff --git a/platform/windows_x64/BUILD b/platform/windows_x64/BUILD index dced707a..d52c1a56 100644 --- a/platform/windows_x64/BUILD +++ b/platform/windows_x64/BUILD @@ -39,6 +39,9 @@ cc_toolchain_suite( "x64_windows|msvc": ":msvc_cc_toolchain", "x64_windows": ":msvc_cc_toolchain", }, + target_compatible_with = [ + "@platforms//os:windows", + ], ) cc_toolchain(