Skip to content

Commit

Permalink
Test for no non-dev dependencies (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Dec 9, 2023
1 parent 7612b55 commit c54ebeb
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
tests
tests/bcr
2 changes: 1 addition & 1 deletion .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bcr_test_module:
module_path: tests
module_path: tests/bcr
matrix:
platform:
- debian10
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 //...
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/bazel-*
/tests/bazel-*
/tests/bcr/bazel-*
MODULE.bazel.lock
8 changes: 6 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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__"],
)
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ buildozer_binary.buildozer(
},
)
use_repo(buildozer_binary, "buildozer_binary")

bazel_dep(name = "platforms", version = "0.0.7", dev_dependency = True)
17 changes: 13 additions & 4 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
}),
)
File renamed without changes.
7 changes: 7 additions & 0 deletions tests/bcr/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sh_binary(
name = "run_buildozer",
env = {
"MSYS2_ARG_CONV_EXCL": "*",
},
srcs = ["run_buildozer.sh"],
)
2 changes: 1 addition & 1 deletion tests/MODULE.bazel → tests/bcr/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions tests/no_deps_test.sh
Original file line number Diff line number Diff line change
@@ -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$'

0 comments on commit c54ebeb

Please sign in to comment.