1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load("@rules_python//python:defs.bzl", "py_library") 16load("//pw_build:python.bzl", "pw_py_test") 17 18package(default_visibility = ["//visibility:public"]) 19 20licenses(["notice"]) 21 22py_library( 23 name = "pw_presubmit", 24 srcs = [ 25 "pw_presubmit/__init__.py", 26 "pw_presubmit/bazel_checks.py", 27 "pw_presubmit/bazel_parser.py", 28 "pw_presubmit/build.py", 29 "pw_presubmit/cli.py", 30 "pw_presubmit/cpp_checks.py", 31 "pw_presubmit/format/__init__.py", 32 "pw_presubmit/format/bazel.py", 33 "pw_presubmit/format/core.py", 34 "pw_presubmit/format/cpp.py", 35 "pw_presubmit/format/gn.py", 36 "pw_presubmit/format/python.py", 37 "pw_presubmit/format/test_data/__init__.py", 38 "pw_presubmit/format_code.py", 39 "pw_presubmit/git_repo.py", 40 "pw_presubmit/gitmodules.py", 41 "pw_presubmit/inclusive_language.py", 42 "pw_presubmit/install_hook.py", 43 "pw_presubmit/javascript_checks.py", 44 "pw_presubmit/json_check.py", 45 "pw_presubmit/keep_sorted.py", 46 "pw_presubmit/module_owners.py", 47 "pw_presubmit/ninja_parser.py", 48 "pw_presubmit/npm_presubmit.py", 49 "pw_presubmit/owners_checks.py", 50 "pw_presubmit/pigweed_presubmit.py", 51 "pw_presubmit/presubmit.py", 52 "pw_presubmit/presubmit_context.py", 53 "pw_presubmit/python_checks.py", 54 "pw_presubmit/repo.py", 55 "pw_presubmit/rst_format.py", 56 "pw_presubmit/shell_checks.py", 57 "pw_presubmit/source_in_build.py", 58 "pw_presubmit/todo_check.py", 59 "pw_presubmit/tools.py", 60 ], 61 data = [ 62 "pw_presubmit/format/test_data/bazel_test_data.bazel", 63 "pw_presubmit/format/test_data/bazel_test_data_golden.bazel", 64 "pw_presubmit/format/test_data/clang_format_config", 65 "pw_presubmit/format/test_data/cpp_test_data.cc", 66 "pw_presubmit/format/test_data/cpp_test_data_golden.cc", 67 "pw_presubmit/format/test_data/gn_test_data.gn", 68 "pw_presubmit/format/test_data/gn_test_data_golden.gn", 69 "pw_presubmit/format/test_data/malformed_file.txt", 70 "pw_presubmit/format/test_data/python_test_data.py", 71 "pw_presubmit/format/test_data/python_test_data_golden.py", 72 ], 73 imports = ["."], 74 deps = [ 75 "//pw_cli/py:pw_cli", 76 "//pw_env_setup/py:pw_env_setup", 77 "//pw_package/py:pw_package", 78 ], 79) 80 81pw_py_test( 82 name = "bazel_parser_test", 83 srcs = ["bazel_parser_test.py"], 84 deps = [ 85 ":pw_presubmit", 86 ], 87) 88 89py_library( 90 name = "format_testing_utils", 91 srcs = ["format_testing_utils.py"], 92) 93 94pw_py_test( 95 name = "bazel_checks_test", 96 srcs = ["bazel_checks_test.py"], 97 deps = [":pw_presubmit"], 98) 99 100pw_py_test( 101 name = "bazel_format_test", 102 srcs = ["bazel_format_test.py"], 103 # TODO(b/314139942): Requires buildifier on the path. 104 tags = ["manual"], 105 deps = [ 106 ":format_testing_utils", 107 ":pw_presubmit", 108 ], 109) 110 111pw_py_test( 112 name = "context_test", 113 srcs = ["context_test.py"], 114 # TODO(b/374120469): Make PW_PROJECT_ROOT optional for pw presubmit 115 tags = ["manual"], 116 deps = [ 117 ":pw_presubmit", 118 ], 119) 120 121pw_py_test( 122 name = "cpp_checks_test", 123 srcs = ["cpp_checks_test.py"], 124 deps = [ 125 ":pw_presubmit", 126 ], 127) 128 129pw_py_test( 130 name = "cpp_format_test", 131 srcs = ["cpp_format_test.py"], 132 # TODO(b/314139942): Requires clang-format on the path. 133 tags = ["manual"], 134 deps = [ 135 ":format_testing_utils", 136 ":pw_presubmit", 137 ], 138) 139 140pw_py_test( 141 name = "format_core_test", 142 srcs = ["format_core_test.py"], 143 deps = [ 144 ":pw_presubmit", 145 ], 146) 147 148pw_py_test( 149 name = "gitmodules_test", 150 srcs = ["gitmodules_test.py"], 151 # TODO(b/314139942): Requires git on the path. 152 tags = ["manual"], 153 deps = [ 154 ":pw_presubmit", 155 ], 156) 157 158pw_py_test( 159 name = "gn_format_test", 160 srcs = ["gn_format_test.py"], 161 # TODO(b/314139942): Requires GN on the path. 162 tags = ["manual"], 163 deps = [ 164 ":format_testing_utils", 165 ":pw_presubmit", 166 ], 167) 168 169pw_py_test( 170 name = "inclusive_language_test", 171 srcs = ["inclusive_language_test.py"], 172 deps = [ 173 ":pw_presubmit", 174 ], 175) 176 177pw_py_test( 178 name = "keep_sorted_test", 179 srcs = ["keep_sorted_test.py"], 180 deps = [ 181 ":pw_presubmit", 182 ], 183) 184 185pw_py_test( 186 name = "ninja_parser_test", 187 srcs = ["ninja_parser_test.py"], 188 deps = [ 189 ":pw_presubmit", 190 ], 191) 192 193pw_py_test( 194 name = "presubmit_test", 195 srcs = ["presubmit_test.py"], 196 deps = [ 197 ":pw_presubmit", 198 ], 199) 200 201pw_py_test( 202 name = "python_format_test", 203 srcs = ["python_format_test.py"], 204 # TODO(b/314139942): Requires black on the path. 205 tags = ["manual"], 206 deps = [ 207 ":format_testing_utils", 208 ":pw_presubmit", 209 "@python_packages//black", 210 ], 211) 212 213pw_py_test( 214 name = "owners_checks_test", 215 srcs = ["owners_checks_test.py"], 216 deps = [ 217 ":pw_presubmit", 218 ], 219) 220 221pw_py_test( 222 name = "todo_check_test", 223 srcs = ["todo_check_test.py"], 224 deps = [ 225 ":pw_presubmit", 226 ], 227) 228 229pw_py_test( 230 name = "tools_test", 231 srcs = ["tools_test.py"], 232 deps = [ 233 ":pw_presubmit", 234 ], 235) 236