From 393dbf7e743fe2f963174ee6bff73ef8cf7b2966 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Tue, 30 Jan 2024 08:14:29 -0700 Subject: [PATCH] fix: BCR presubmit (#38) - Add a child workspace to use as the BCR presubmit test. - Update BCR presubmit config to run tests in the new workspace. Related to https://github.com/bazelbuild/bazel-central-registry/pull/1390. --- .bazelignore | 1 + .bcr/presubmit.yml | 9 +++++---- .github/workflows/ci.yaml | 21 ++++++++++++++++++++- test/bcr_test/.bazelrc | 1 + test/bcr_test/.bazelversion | 1 + test/bcr_test/BUILD.bazel | 3 +++ test/bcr_test/MODULE.bazel | 6 ++++++ test/bcr_test/test.bzl | 19 +++++++++++++++++++ 8 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 .bazelignore create mode 100644 test/bcr_test/.bazelrc create mode 100644 test/bcr_test/.bazelversion create mode 100644 test/bcr_test/BUILD.bazel create mode 100644 test/bcr_test/MODULE.bazel create mode 100644 test/bcr_test/test.bzl diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 0000000..6f71408 --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +test/bcr_test diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index ca68e81..d40de73 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -1,3 +1,4 @@ +module_path: test/bcr_test matrix: platform: - centos7 @@ -6,8 +7,8 @@ matrix: - macos - windows tasks: - verify_targets: - name: Verify build targets + run_test_module: + name: Run test module platform: ${{ platform }} - build_targets: - - "@bazel_features//test:tests" + test_targets: + - "//..." diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b542376..dfeae7a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,7 +16,26 @@ concurrency: cancel-in-progress: true jobs: - test: + unit_tests: uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v5 with: folders: '["."]' + bcr_test: + uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v5 + with: + folders: '["test/bcr_test"]' + exclude: | + [ + {"bzlmodEnabled": false}, + {"bazelversion": "5.4.0"} + ] + test: + runs-on: ubuntu-latest + needs: + - unit_tests + - bcr_test + if: ${{ always() }} + steps: + - uses: cgrindel/gha_join_jobs@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/bcr_test/.bazelrc b/test/bcr_test/.bazelrc new file mode 100644 index 0000000..c347c53 --- /dev/null +++ b/test/bcr_test/.bazelrc @@ -0,0 +1 @@ +try-import %workspace%/.bazelrc.user diff --git a/test/bcr_test/.bazelversion b/test/bcr_test/.bazelversion new file mode 100644 index 0000000..a8907c0 --- /dev/null +++ b/test/bcr_test/.bazelversion @@ -0,0 +1 @@ +7.0.2 diff --git a/test/bcr_test/BUILD.bazel b/test/bcr_test/BUILD.bazel new file mode 100644 index 0000000..a30d004 --- /dev/null +++ b/test/bcr_test/BUILD.bazel @@ -0,0 +1,3 @@ +load(":test.bzl", "bazel_features_test_suite") + +bazel_features_test_suite(name = "bazel_features_test") diff --git a/test/bcr_test/MODULE.bazel b/test/bcr_test/MODULE.bazel new file mode 100644 index 0000000..56a2cfb --- /dev/null +++ b/test/bcr_test/MODULE.bazel @@ -0,0 +1,6 @@ +bazel_dep(name = "bazel_skylib", version = "1.4.2") +bazel_dep(name = "bazel_features") +local_path_override( + module_name = "bazel_features", + path = "../..", +) diff --git a/test/bcr_test/test.bzl b/test/bcr_test/test.bzl new file mode 100644 index 0000000..131d520 --- /dev/null +++ b/test/bcr_test/test.bzl @@ -0,0 +1,19 @@ +load("@bazel_features//:features.bzl", "bazel_features") +load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") + +"""Tests for `bazel_features` module.""" + +def _is_bzlmod_enabled_test(ctx): + env = unittest.begin(ctx) + + asserts.true(env, bazel_features.external_deps.is_bzlmod_enabled) + + return unittest.end(env) + +is_bzlmod_enabled_test = unittest.make(_is_bzlmod_enabled_test) + +def bazel_features_test_suite(name): + return unittest.suite( + name, + is_bzlmod_enabled_test, + )