From a09b600b2ffc3c5fe0bccdac1db5607ba3f52823 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Sun, 29 Oct 2023 09:10:54 +0100 Subject: [PATCH] chore: remove BUILD rules for building our release artifact I'll send a follow-up PR to simply use 'git archive' to create it, along with GitHub Actions based release automation following Google security best-practice. --- BUILD | 14 -------- distro/BUILD | 74 ------------------------------------------ distro/check_build.sh | 59 --------------------------------- doc_build/BUILD | 15 ++------- licenses/generic/BUILD | 5 --- licenses/spdx/BUILD | 5 --- rules/BUILD | 8 ++--- rules/private/BUILD | 5 --- rules_gathering/BUILD | 5 +-- sample_reports/BUILD | 5 --- tools/BUILD | 6 ---- tools/test_helpers.bzl | 6 ---- 12 files changed, 8 insertions(+), 199 deletions(-) delete mode 100644 distro/BUILD delete mode 100755 distro/check_build.sh diff --git a/BUILD b/BUILD index 31520c4..630a5c4 100644 --- a/BUILD +++ b/BUILD @@ -48,17 +48,3 @@ exports_files( ]), visibility = ["//visibility:public"], ) - -filegroup( - name = "standard_package", - srcs = glob([ - "*.bzl", - "*.md", - ]) + [ - "MODULE.bazel", - "BUILD", - "LICENSE", - "WORKSPACE.bzlmod", - ], - visibility = ["//distro:__pkg__"], -) diff --git a/distro/BUILD b/distro/BUILD deleted file mode 100644 index 7291cad..0000000 --- a/distro/BUILD +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2022 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# 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. - -load("//:version.bzl", "version") -load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") -load("@rules_pkg//pkg/releasing:defs.bzl", "print_rel_notes") - -package( - default_visibility = ["//visibility:public"], - default_applicable_licenses = ["//:license"], -) - -licenses(["notice"]) - -alias( - name = "distro", - actual = "rules_license-%s" % version, -) - -# Build the artifact to put on the github release page. -pkg_tar( - name = "rules_license-%s" % version, - srcs = [ - ":small_workspace", - "//:standard_package", - "//licenses/generic:standard_package", - "//licenses/spdx:standard_package", - "//rules:standard_package", - "//rules_gathering:standard_package", - "//rules/private:standard_package", - "//sample_reports:standard_package", - "//tools:standard_package", - ], - extension = "tar.gz", - # It is all source code, so make it read-only. - mode = "0444", - # Make it owned by root so it does not have the uid of the CI robot. - owner = "0.0", - package_dir = ".", - strip_prefix = ".", - tags = [ - "no_windows", - ], -) - -genrule( - name = "small_workspace", - srcs = ["//:WORKSPACE"], - outs = ["WORKSPACE"], - cmd = "sed -e '/### INTERNAL ONLY/,$$d' $(location //:WORKSPACE) >$@", - tags = [ - "no_windows", - ], -) - -print_rel_notes( - name = "relnotes", - outs = ["relnotes.txt"], - mirror_host = "mirror.bazel.build", - org = "bazelbuild", - repo = "rules_license", - version = version, -) diff --git a/distro/check_build.sh b/distro/check_build.sh deleted file mode 100755 index bfcae6d..0000000 --- a/distro/check_build.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -ef -# -# This is a temporary hack to verify the distribution archive is sound. -# -# The intent is to create a rule which does this and add to -# rules_pkg. Comments within it are mostly for future me -# while writing that. - -TARBALL=$(bazel build //distro:distro 2>&1 | grep 'rules_license-.*\.tar\.gz' | sed -e 's/ //g') -REPO_NAME='rules_license' - -# This part can be standard from the rule - - -TARNAME=$(basename "$TARBALL") - -TMP=$(mktemp -d) -trap '/bin/rm -rf "$TMP"; exit 0' 0 1 2 3 15 - -cp "$TARBALL" "$TMP" - -cd "$TMP" -cat >WORKSPACE <BUILD <LICENSE - -# Then a list of commands to run. This can be a template -# too so we can substitute the path to bazel. -bazel build ... -bazel build @rules_license//rules/... -bazel build @rules_license//licenses/... -bazel query @rules_license//licenses/generic/... -bazel query ... diff --git a/doc_build/BUILD b/doc_build/BUILD index 66ce6f7..c1a7884 100644 --- a/doc_build/BUILD +++ b/doc_build/BUILD @@ -26,17 +26,6 @@ load("//:version.bzl", "version") package(default_package_metadata = ["//:license", "//:package_info"]) -filegroup( - name = "standard_package", - srcs = [ - "BUILD", - ] + glob([ - "*.bzl", - "*.py", - ]), - visibility = ["//distro:__pkg__"], -) - exports_files( glob([ "*.bzl", @@ -91,8 +80,8 @@ bzl_library( name = "lib_of_everything", srcs = [ "//:version.bzl", - "//rules:standard_package", - "//rules_gathering:standard_package", + "//rules:bzl", + "//rules_gathering:bzl", ], visibility = ["//visibility:public"], ) diff --git a/licenses/generic/BUILD b/licenses/generic/BUILD index def2334..9ccf312 100644 --- a/licenses/generic/BUILD +++ b/licenses/generic/BUILD @@ -44,11 +44,6 @@ package( licenses(["notice"]) -filegroup( - name = "standard_package", - srcs = ["BUILD"], -) - # "none" should be used for packages which are distributed with no license of # any kind. You can use this no-op license as a positive indication that the # code's license terms were reviewed, so that linters will not flag it later as diff --git a/licenses/spdx/BUILD b/licenses/spdx/BUILD index feb0580..80689d0 100644 --- a/licenses/spdx/BUILD +++ b/licenses/spdx/BUILD @@ -61,11 +61,6 @@ package( licenses(["notice"]) -filegroup( - name = "standard_package", - srcs = ["BUILD"], -) - license_kind( name = "0BSD", conditions = [], diff --git a/rules/BUILD b/rules/BUILD index 387019a..fd95601 100644 --- a/rules/BUILD +++ b/rules/BUILD @@ -33,12 +33,10 @@ trace( visibility = ["//visibility:public"], ) +# TODO(alexeagle): use gazelle to replace all these with bzl_library filegroup( - name = "standard_package", - srcs = glob([ - "**/BUILD", - "**/*.bzl", - ]), + name = "bzl", + srcs = glob(["**/*.bzl"]), ) # Do not create a bzl_library(). That would create a dependency loop back diff --git a/rules/private/BUILD b/rules/private/BUILD index 452e623..e502357 100644 --- a/rules/private/BUILD +++ b/rules/private/BUILD @@ -20,11 +20,6 @@ package( licenses(["notice"]) -filegroup( - name = "standard_package", - srcs = glob(["**"]), -) - # Do not create a bzl_library(). That would create a dependency loop back # to bazel-skylib. We export the .bzl files to the documentation maker. exports_files( diff --git a/rules_gathering/BUILD b/rules_gathering/BUILD index 6798eb6..49e1c14 100644 --- a/rules_gathering/BUILD +++ b/rules_gathering/BUILD @@ -18,9 +18,10 @@ package( default_visibility = ["//visibility:public"], ) +# TODO(alexeagle): use gazelle to replace all these with bzl_library filegroup( - name = "standard_package", - srcs = glob(["**"]), + name = "bzl", + srcs = glob(["*.bzl"]), ) # Do not create a bzl_library(). That would create a dependency loop back diff --git a/sample_reports/BUILD b/sample_reports/BUILD index 62aafba..97f827f 100644 --- a/sample_reports/BUILD +++ b/sample_reports/BUILD @@ -22,11 +22,6 @@ package( licenses(["notice"]) -filegroup( - name = "standard_package", - srcs = glob(["**"]), -) - # Do not create a bzl_library(). That would create a dependency loop back # to bazel-skylib. We export the .bzl files to the documentation maker. exports_files( diff --git a/tools/BUILD b/tools/BUILD index d42f4b7..1e6f8ac 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -23,12 +23,6 @@ package( licenses(["notice"]) -filegroup( - name = "standard_package", - srcs = glob(["**"]), - visibility = ["//distro:__pkg__"], -) - exports_files(["diff_test.sh"]) py_binary( diff --git a/tools/test_helpers.bzl b/tools/test_helpers.bzl index 77e288a..a748c5a 100644 --- a/tools/test_helpers.bzl +++ b/tools/test_helpers.bzl @@ -60,12 +60,6 @@ def golden_cmd_test( """ actual = name + ".output" - # There are some cases where tools are provided and exec_tools are provided. - # Specifying both in the same genrule, confuses the host vs exec rules, - # which prevents python3 from execution. - if tools and exec_tools: - fail("Only set one: tools or exec_tools. " + - "Setting both confuses python execution mode (host vs exec).") native.genrule( name = name + "_output", srcs = srcs,