diff --git a/.bazelignore b/.bazelignore index 2b29f27..23758d5 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1 +1 @@ -tests +tests/bcr diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index bc6b157..2261133 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -1,5 +1,5 @@ bcr_test_module: - module_path: tests + module_path: tests/bcr matrix: platform: - debian10 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60e24eb..17eb3d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,16 @@ on: - cron: '0 0 * * *' jobs: + root_module: + name: Root module + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Test + run: bazel test //... + test_module: name: BCR test module runs-on: ${{ matrix.os }} @@ -22,7 +32,7 @@ jobs: - name: Test env: USE_BAZEL_VERSION: ${{ matrix.bazel }} - working-directory: tests + working-directory: tests/bcr run: | bazel run //:run_buildozer bazel test //... diff --git a/.gitignore b/.gitignore index 239b061..e97e787 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ /bazel-* -/tests/bazel-* +/tests/bcr/bazel-* MODULE.bazel.lock diff --git a/BUILD.bazel b/BUILD.bazel index 3bfa071..0c25f2d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -7,10 +7,14 @@ sh_binary( env = { "BUILDOZER_RLOCATIONPATH": "$(rlocationpath @buildozer_binary//:buildozer.exe)", }, - visibility = ["//visibility:public"], deps = [ "@bazel_tools//tools/bash/runfiles", ], ) -exports_files(["buildozer_binary.bzl"]) +exports_files(["buildozer.bzl"]) + +exports_files( + ["MODULE.bazel"], + visibility = ["//tests:__subpackages__"], +) diff --git a/MODULE.bazel b/MODULE.bazel index 0a4e272..e62b577 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -15,3 +15,5 @@ buildozer_binary.buildozer( }, ) use_repo(buildozer_binary, "buildozer_binary") + +bazel_dep(name = "platforms", version = "0.0.7", dev_dependency = True) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index cd46c4f..be7f994 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -1,7 +1,16 @@ -sh_binary( - name = "run_buildozer", +sh_test( + name = "no_deps_test", + srcs = ["no_deps_test.sh"], + data = [ + "//:MODULE.bazel", + "@buildozer_binary//:buildozer.exe", + ], env = { - "MSYS2_ARG_CONV_EXCL": "*", + "BUILDOZER": "$(rootpath @buildozer_binary//:buildozer.exe)", }, - srcs = ["run_buildozer.sh"], + target_compatible_with = select({ + "@platforms//os:linux": [], + "@platforms//os:macos": [], + "//conditions:default": ["@platforms//:incompatible"], + }), ) diff --git a/tests/.bazelrc b/tests/bcr/.bazelrc similarity index 100% rename from tests/.bazelrc rename to tests/bcr/.bazelrc diff --git a/tests/bcr/BUILD.bazel b/tests/bcr/BUILD.bazel new file mode 100644 index 0000000..cd46c4f --- /dev/null +++ b/tests/bcr/BUILD.bazel @@ -0,0 +1,7 @@ +sh_binary( + name = "run_buildozer", + env = { + "MSYS2_ARG_CONV_EXCL": "*", + }, + srcs = ["run_buildozer.sh"], +) diff --git a/tests/MODULE.bazel b/tests/bcr/MODULE.bazel similarity index 94% rename from tests/MODULE.bazel rename to tests/bcr/MODULE.bazel index 0ab8b33..302df8b 100644 --- a/tests/MODULE.bazel +++ b/tests/bcr/MODULE.bazel @@ -1,7 +1,7 @@ bazel_dep(name = "buildozer", version = "") local_path_override( module_name = "buildozer", - path = "..", + path = "../..", ) repo_ext = use_extension("//:deps.bzl", "repo_ext") diff --git a/tests/WORKSPACE b/tests/bcr/WORKSPACE similarity index 100% rename from tests/WORKSPACE rename to tests/bcr/WORKSPACE diff --git a/tests/WORKSPACE.bzlmod b/tests/bcr/WORKSPACE.bzlmod similarity index 100% rename from tests/WORKSPACE.bzlmod rename to tests/bcr/WORKSPACE.bzlmod diff --git a/tests/bazel_run_test/BUILD.bazel b/tests/bcr/bazel_run_test/BUILD.bazel similarity index 100% rename from tests/bazel_run_test/BUILD.bazel rename to tests/bcr/bazel_run_test/BUILD.bazel diff --git a/tests/bazel_run_test/bazel_run_test.sh b/tests/bcr/bazel_run_test/bazel_run_test.sh similarity index 100% rename from tests/bazel_run_test/bazel_run_test.sh rename to tests/bcr/bazel_run_test/bazel_run_test.sh diff --git a/tests/deps.bzl b/tests/bcr/deps.bzl similarity index 100% rename from tests/deps.bzl rename to tests/bcr/deps.bzl diff --git a/tests/repo_rule_test/BUILD.bazel b/tests/bcr/repo_rule_test/BUILD.bazel similarity index 100% rename from tests/repo_rule_test/BUILD.bazel rename to tests/bcr/repo_rule_test/BUILD.bazel diff --git a/tests/run_buildozer.sh b/tests/bcr/run_buildozer.sh similarity index 100% rename from tests/run_buildozer.sh rename to tests/bcr/run_buildozer.sh diff --git a/tests/no_deps_test.sh b/tests/no_deps_test.sh new file mode 100755 index 0000000..7e01562 --- /dev/null +++ b/tests/no_deps_test.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Verify that the buildozer module has no non-dev dependencies. + +set -euo pipefail + +# Fail on lines that don't end with " True". +! $BUILDOZER 'print name dev_dependency' //MODULE.bazel:%bazel_dep \ + | grep -v ' True$'