From 6ed94123a2ed9c9e84e3b751827ea28001a846ea Mon Sep 17 00:00:00 2001 From: Ben Lee Date: Tue, 24 Oct 2023 19:33:25 -0700 Subject: [PATCH] Run Android Lint against the sources in rules_android_lint (#17) --- .bazelrc | 2 +- src/cli/BUILD | 8 ++++++++ src/worker/BUILD | 12 ++++++++++-- tests/src/cli/BUILD | 29 +++++++++++++++++++++++++++++ tests/src/worker/BUILD | 15 +++++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index dc47369..109fe53 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,4 +1,4 @@ -# Required until this is the default; expected in Bazel 7 common --enable_bzlmod +common --experimental_google_legacy_api try-import %workspace%/.bazelrc.user diff --git a/src/cli/BUILD b/src/cli/BUILD index 68c9b8a..3daaa2c 100644 --- a/src/cli/BUILD +++ b/src/cli/BUILD @@ -1,6 +1,7 @@ load("@rules_java//java:defs.bzl", "java_binary") load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test") +load("//rules:defs.bzl", "android_lint_test") java_binary( name = "cli", @@ -32,3 +33,10 @@ ktlint_fix( config = "//:editorconfig", visibility = ["//visibility:private"], ) + +android_lint_test( + name = "lint_lint_test", + srcs = glob(["*.kt"]), + lib = ":lint", + visibility = ["//visibility:private"], +) diff --git a/src/worker/BUILD b/src/worker/BUILD index 3c8aa3d..340bb2d 100644 --- a/src/worker/BUILD +++ b/src/worker/BUILD @@ -1,5 +1,6 @@ load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test") +load("//rules:defs.bzl", "android_lint_test") kt_jvm_library( name = "worker", @@ -15,15 +16,22 @@ kt_jvm_library( ) ktlint_test( - name = "lint_ktlint_test", + name = "worker_ktlint_test", srcs = glob(["*.kt"]), config = "//:editorconfig", visibility = ["//visibility:private"], ) ktlint_fix( - name = "lint_ktlint_fix", + name = "worker_ktlint_fix", srcs = glob(["*.kt"]), config = "//:editorconfig", visibility = ["//visibility:private"], ) + +android_lint_test( + name = "worker_lint_test", + srcs = glob(["*.kt"]), + lib = ":worker", + visibility = ["//visibility:private"], +) diff --git a/tests/src/cli/BUILD b/tests/src/cli/BUILD index 773f24e..786b311 100644 --- a/tests/src/cli/BUILD +++ b/tests/src/cli/BUILD @@ -1,5 +1,6 @@ load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test") load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test") +load("//rules:defs.bzl", "android_lint_test") kt_jvm_test( name = "AndroidLintActionArgsTest", @@ -12,6 +13,13 @@ kt_jvm_test( ], ) +android_lint_test( + name = "AndroidLintActionArgsTest_lint_test", + srcs = ["AndroidLintActionArgsTest.kt"], + lib = ":AndroidLintActionArgsTest", + visibility = ["//visibility:private"], +) + kt_jvm_test( name = "AndroidLintActionTest", srcs = ["AndroidLintActionTest.kt"], @@ -23,6 +31,13 @@ kt_jvm_test( ], ) +android_lint_test( + name = "AndroidLintActionTest_lint_test", + srcs = ["AndroidLintActionTest.kt"], + lib = ":AndroidLintActionTest", + visibility = ["//visibility:private"], +) + kt_jvm_test( name = "AndroidLintProjectTest", srcs = ["AndroidLintProjectTest.kt"], @@ -34,6 +49,13 @@ kt_jvm_test( ], ) +android_lint_test( + name = "AndroidLintProjectTest_lint_test", + srcs = ["AndroidLintProjectTest.kt"], + lib = ":AndroidLintProjectTest", + visibility = ["//visibility:private"], +) + kt_jvm_test( name = "AndroidLintBaselineSanitizerTest", srcs = ["AndroidLintBaselineSanitizerTest.kt"], @@ -45,6 +67,13 @@ kt_jvm_test( ], ) +android_lint_test( + name = "AndroidLintBaselineSanitizerTest_lint_test", + srcs = ["AndroidLintBaselineSanitizerTest.kt"], + lib = ":AndroidLintBaselineSanitizerTest", + visibility = ["//visibility:private"], +) + ktlint_test( name = "lint_ktlint_test", srcs = glob(["*.kt"]), diff --git a/tests/src/worker/BUILD b/tests/src/worker/BUILD index c8b1684..b280cb5 100644 --- a/tests/src/worker/BUILD +++ b/tests/src/worker/BUILD @@ -1,4 +1,5 @@ load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test") +load("//rules:defs.bzl", "android_lint_test") kt_jvm_test( name = "WorkerIOTest", @@ -22,6 +23,20 @@ kt_jvm_test( ], ) +android_lint_test( + name = "WorkerIOTest_lint_test", + srcs = ["WorkerIOTest.kt"], + lib = ":WorkerIOTest", + visibility = ["//visibility:private"], +) + +android_lint_test( + name = "WorkerJsonMessageProcessorTest_lint_test", + srcs = ["WorkerJsonMessageProcessorTest.kt"], + lib = ":WorkerJsonMessageProcessorTest", + visibility = ["//visibility:private"], +) + test_suite( name = "tests", tests = [