diff --git a/deps.bzl b/deps.bzl index 2f3e5a1..65bfe1e 100644 --- a/deps.bzl +++ b/deps.bzl @@ -11,11 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -# Workspace dependencies for rules_pkg/pkg -# This is for backwards compatibility with existing usage. Please use -# load("//pkg:deps.bzl", "rules_pkg_dependencies") -# going forward. +"""Workspace dependencies for rules_pkg/pkg. +This is for backwards compatibility with existing usage. Please use + load("//pkg:deps.bzl", "rules_pkg_dependencies") +going forward. +""" load("//pkg:deps.bzl", _rules_pkg_dependencies = "rules_pkg_dependencies") diff --git a/doc_build/BUILD b/doc_build/BUILD index 062e212..c146b33 100644 --- a/doc_build/BUILD +++ b/doc_build/BUILD @@ -23,9 +23,8 @@ load("//:version.bzl", "version") # pairs of rule name and the source file to get it from -# buildifier: leave-alone +# buildifier: leave-alone, do not sort ORDER = [ - # buildifier: do not sort ("toc", None), ("common", None), ("pkg_deb", "//pkg/private/deb:deb.bzl"), diff --git a/pkg/deb.bzl b/pkg/deb.bzl index d63fda0..159ebae 100644 --- a/pkg/deb.bzl +++ b/pkg/deb.bzl @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Forwarder for pkg_deb.""" + load("//pkg/private/deb:deb.bzl", _pkg_deb = "pkg_deb") pkg_deb = _pkg_deb diff --git a/pkg/deps.bzl b/pkg/deps.bzl index 9781d82..d6f013f 100644 --- a/pkg/deps.bzl +++ b/pkg/deps.bzl @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Workspace dependencies for rules_pkg/pkg +"""WORKSPACE dependencies for rules_pkg/pkg.""" load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") diff --git a/pkg/install.bzl b/pkg/install.bzl index 333c5bc..38e1d52 100644 --- a/pkg/install.bzl +++ b/pkg/install.bzl @@ -11,12 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -"""rules for creating install scripts from pkg_filegroups and friends. +"""Rules for creating install scripts from pkg_filegroups and friends. This module provides an interface (`pkg_install`) for creating a `bazel run`-able installation script. - """ load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo") diff --git a/pkg/releasing/defs.bzl b/pkg/releasing/defs.bzl index 3552a59..9c7dbe2 100644 --- a/pkg/releasing/defs.bzl +++ b/pkg/releasing/defs.bzl @@ -1,3 +1,5 @@ +"""Impementation for print_rel_notes.""" + def print_rel_notes( name, repo, diff --git a/pkg/zip.bzl b/pkg/zip.bzl index 916a73b..e51410b 100644 --- a/pkg/zip.bzl +++ b/pkg/zip.bzl @@ -11,6 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +"""Forwarder for pkg_zip.""" + load("//pkg/private/zip:zip.bzl", _pkg_zip = "pkg_zip") pkg_zip = _pkg_zip diff --git a/tests/deb/BUILD b/tests/deb/BUILD index 84787f9..c92c1ba 100644 --- a/tests/deb/BUILD +++ b/tests/deb/BUILD @@ -106,6 +106,6 @@ py_test( package_naming_test( name = "naming_test", - target_under_test = ":test_deb", expected_name = "fizzbuzz_test_all.deb", + target_under_test = ":test_deb", ) diff --git a/tests/deb/deb_tests.bzl b/tests/deb/deb_tests.bzl index 0508704..0227d05 100644 --- a/tests/deb/deb_tests.bzl +++ b/tests/deb/deb_tests.bzl @@ -43,7 +43,6 @@ def _package_naming_test_impl(ctx): ) return analysistest.end(env) - package_naming_test = analysistest.make( _package_naming_test_impl, attrs = { diff --git a/tests/mappings/BUILD b/tests/mappings/BUILD index 098d98e..3294158 100644 --- a/tests/mappings/BUILD +++ b/tests/mappings/BUILD @@ -14,9 +14,9 @@ load( ":mappings_test.bzl", - "manifest_golden_test", - "mappings_analysis_tests", - "mappings_unit_tests", + "manifest_golden_test", + "mappings_analysis_tests", + "mappings_unit_tests", ) load(":mappings_external_repo_test.bzl", "mappings_external_repo_analysis_tests") load( @@ -51,7 +51,10 @@ mappings_external_repo_analysis_tests() directory( name = "treeartifact", - filenames = ["artifact_in_tree1", "artifact_in_tree2"], + filenames = [ + "artifact_in_tree1", + "artifact_in_tree2", + ], ) pkg_files( @@ -85,16 +88,16 @@ write_content_manifest( name = "all", srcs = [ "BUILD", + ":directory-with-contents", ":dirs", ":files", - ":directory-with-contents", ], ) manifest_golden_test( name = "all_test", - target = "all", expected = "all.manifest.golden", + target = "all", ) # @@ -117,6 +120,6 @@ write_content_manifest( manifest_golden_test( name = "utf8_manifest_test", - target = "utf8", expected = "utf8_manifest.golden", + target = "utf8", ) diff --git a/tests/mappings/mappings_external_repo_test.bzl b/tests/mappings/mappings_external_repo_test.bzl index ac27d28..aeb3223 100644 --- a/tests/mappings/mappings_external_repo_test.bzl +++ b/tests/mappings/mappings_external_repo_test.bzl @@ -109,7 +109,6 @@ def _test_pkg_files_extrepo(): expected_dests = ["usr/bin/dir/extproj.sh"], ) - def mappings_external_repo_analysis_tests(): """Declare mappings.bzl analysis tests""" _test_pkg_files_extrepo() diff --git a/tests/mappings/mappings_test.bzl b/tests/mappings/mappings_test.bzl index 78eb019..4792704 100644 --- a/tests/mappings/mappings_test.bzl +++ b/tests/mappings/mappings_test.bzl @@ -20,23 +20,24 @@ load( "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", - "PackageSymlinkInfo",) + "PackageSymlinkInfo", +) load( "//pkg:mappings.bzl", + "REMOVE_BASE_DIRECTORY", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "pkg_mklink", "strip_prefix", - "REMOVE_BASE_DIRECTORY", ) load( "//tests/util:defs.bzl", "directory", "fake_artifact", "generic_base_case_test", - "generic_negative_test" + "generic_negative_test", ) load("@bazel_skylib//lib:new_sets.bzl", "sets") load("@rules_python//python:defs.bzl", "py_test") @@ -62,11 +63,11 @@ def _pkg_files_contents_test_impl(ctx): for got in target_under_test[PackageFilesInfo].dest_src_map.keys(): asserts.true( got in expected_dests, - "got <%s> not in expected set: %s" % (got, ctx.attr.expected_dests)) + "got <%s> not in expected set: %s" % (got, ctx.attr.expected_dests), + ) n_found += 1 asserts.equals(env, len(expected_dests), n_found) - # Simple equality checks for the others, if specified if ctx.attr.expected_attributes: asserts.equals( @@ -468,7 +469,6 @@ def _test_pkg_files_rename(): target_under_test = ":pf_directory_rename_to_empty_g", ) - ########## # Test pkg_mkdirs ########## @@ -969,7 +969,6 @@ _gen_manifest_test_main = rule( }, ) - def manifest_golden_test(name, target, expected): """Tests that a content manifest file matches a golden copy. diff --git a/tests/path_test.bzl b/tests/path_test.bzl index f08b155..a2a46d2 100644 --- a/tests/path_test.bzl +++ b/tests/path_test.bzl @@ -24,14 +24,15 @@ load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest") def _compute_data_path_test_impl(ctx): env = analysistest.begin(ctx) target_under_test = analysistest.target_under_test(env) + # Subtle: This allows you to vendor the library into your own repo at some # arbitrary path. expect = ctx.attr.expected_path - if expect.startswith('tests'): - expect = ctx.label.package + expect[5:] + if expect.startswith("tests"): + expect = ctx.label.package + expect[5:] asserts.equals( env, - expect, + expect, compute_data_path(ctx, ctx.attr.in_path), ) return analysistest.end(env) @@ -88,4 +89,4 @@ def _test_compute_data_path(name): def path_tests(name): """Declare path.bzl analysis tests.""" - _test_compute_data_path(name=name + "_compute_data_path") + _test_compute_data_path(name = name + "_compute_data_path") diff --git a/tests/rpm/BUILD b/tests/rpm/BUILD index 26f4fdf..cf1b740 100644 --- a/tests/rpm/BUILD +++ b/tests/rpm/BUILD @@ -100,13 +100,13 @@ pkg_mkdirs( pkg_mklink( name = "test_links", - link_name = "/usr/bin/link-name", - target = "/usr/bin/link-target", attributes = pkg_attributes( group = "root", mode = "0777", user = "root", ), + link_name = "/usr/bin/link-name", + target = "/usr/bin/link-target", ) pkg_filegroup( @@ -316,10 +316,10 @@ sh_library( pkg_mkdirs( name = "dirtest_dirs", + attributes = pkg_attributes(mode = "0755"), dirs = [ "dir", ], - attributes = pkg_attributes(mode = "0755"), ) pkg_files( @@ -327,9 +327,10 @@ pkg_files( srcs = [ ":config_empty", ], - prefix = "dir", attributes = pkg_attributes(mode = "0644"), + prefix = "dir", ) + pkg_rpm( name = "test_rpm_dirs", srcs = [ @@ -354,7 +355,7 @@ genrule( # pkg_rpm emits two outputs RPMS=($(SRCS)) rpm -qp --queryformat '[%{FILEMODES:perms} %{FILENAMES}\n]' $${RPMS[0]} > $@ - """ + """, ) diff_test( diff --git a/tests/rpm/analysis_tests.bzl b/tests/rpm/analysis_tests.bzl index e032835..52f4c5e 100644 --- a/tests/rpm/analysis_tests.bzl +++ b/tests/rpm/analysis_tests.bzl @@ -191,7 +191,6 @@ def _package_naming_test_impl(ctx): elif f.basename == ctx.attr.expected_default_name and not default_name_found: default_name_found = True - asserts.true( env, packaged_file != None, diff --git a/tests/util/defs.bzl b/tests/util/defs.bzl index 06a266e..94076e3 100644 --- a/tests/util/defs.bzl +++ b/tests/util/defs.bzl @@ -61,10 +61,10 @@ Paths containing directories will also have the intermediate directories created def _fake_artifact_impl(ctx): out_file = ctx.actions.declare_file(ctx.attr.name) - content = ['echo ' + rf.path for rf in ctx.files.runfiles] + content = ["echo " + rf.path for rf in ctx.files.runfiles] ctx.actions.write( output = out_file, - content = '\r\n'.join(content), + content = "\r\n".join(content), is_executable = ctx.attr.executable, ) return DefaultInfo( @@ -137,7 +137,7 @@ def write_content_manifest(name, srcs): name = name, srcs = srcs, use_short_path = True, - out = name + ".manifest" + out = name + ".manifest", ) ############################################################ diff --git a/tests/zip/BUILD b/tests/zip/BUILD index 7244718..c9177a8 100644 --- a/tests/zip/BUILD +++ b/tests/zip/BUILD @@ -44,11 +44,11 @@ pkg_mkdirs( pkg_mklink( name = "link", - target = "/usr/local/foo/foo.real", - link_name = "/usr/bin/foo", attributes = pkg_attributes( mode = "555", ), + link_name = "/usr/bin/foo", + target = "/usr/local/foo/foo.real", ) directory( @@ -85,10 +85,10 @@ pkg_zip( pkg_zip( name = "test_zip_basic", srcs = [ - "//tests:testdata/hello.txt", - "//tests:testdata/loremipsum.txt", ":dirs", ":link", + "//tests:testdata/hello.txt", + "//tests:testdata/loremipsum.txt", ], ) @@ -114,10 +114,10 @@ pkg_zip( pkg_zip( name = "test_zip_basic_timestamp_before_epoch", srcs = [ - "//tests:testdata/hello.txt", - "//tests:testdata/loremipsum.txt", ":dirs", ":link", + "//tests:testdata/hello.txt", + "//tests:testdata/loremipsum.txt", ], timestamp = 0, )