chore: remove check_bazel_version Also check_rules_nodejs_version, though a stub is left behind to avoid needing a patch in rules_sass which calls it. We can use the one in bazel_skylib instead. Fixes #2622
diff --git a/docs/Built-ins.md b/docs/Built-ins.md index bc63a1e..3cd8f8e 100755 --- a/docs/Built-ins.md +++ b/docs/Built-ins.md
@@ -1631,40 +1631,6 @@ -## check_bazel_version - -**USAGE** - -<pre> -check_bazel_version(<a href="#check_bazel_version-minimum_bazel_version">minimum_bazel_version</a>, <a href="#check_bazel_version-message">message</a>) -</pre> - - Verify the users Bazel version is at least the given one. - -This can be used in rule implementations that depend on changes in Bazel, -to warn users about a mismatch between the rule and their installed Bazel -version. - -This should *not* be used in users WORKSPACE files. To locally pin your -Bazel version, just create the .bazelversion file in your workspace. - - -**PARAMETERS** - - -<h4 id="check_bazel_version-minimum_bazel_version">minimum_bazel_version</h4> - -a string indicating the minimum version - - - -<h4 id="check_bazel_version-message">message</h4> - -optional string to print to your users, could be used to help them update - -Defaults to `""` - - ## copy_to_bin **USAGE**
diff --git a/index.bzl b/index.bzl index 5260f8e..359d44a 100644 --- a/index.bzl +++ b/index.bzl
@@ -18,7 +18,6 @@ """ load("//:version.bzl", "VERSION") -load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_bazel_version") load("//internal/common:check_version.bzl", "check_version") load("//internal/common:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin") load("//internal/common:params_file.bzl", _params_file = "params_file") @@ -35,7 +34,6 @@ load("//internal/pkg_npm:pkg_npm.bzl", _pkg_npm = "pkg_npm_macro") load("//internal/pkg_web:pkg_web.bzl", _pkg_web = "pkg_web") -check_bazel_version = _check_bazel_version nodejs_binary = _nodejs_binary nodejs_test = _nodejs_test node_repositories = _node_repositories @@ -102,7 +100,6 @@ minimum_version_string, )) -# Export check_rules_nodejs_version symbol for pre-5.0 backward compat. This -# will eventually get removed as we move to the core @rules_nodejs package in -# future release. -check_rules_nodejs_version = check_build_bazel_rules_nodejs_version +def check_rules_nodejs_version(*_): + # buildifier: disable=print + print("WARNING: check_rules_nodejs_version has been removed. This is a no-op, please remove the call.")
diff --git a/index.for_docs.bzl b/index.for_docs.bzl index 42eab46..50b0181 100644 --- a/index.for_docs.bzl +++ b/index.for_docs.bzl
@@ -23,7 +23,6 @@ This is necessary to bootstrap Bazel to run the package manager to download other rules from NPM. """ -load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_bazel_version") load("//internal/common:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin") load("//internal/common:params_file.bzl", _params_file = "params_file") load("//internal/generated_file_test:generated_file_test.bzl", _generated_file_test = "generated_file_test") @@ -34,7 +33,6 @@ load("//internal/pkg_npm:pkg_npm.bzl", _pkg_npm = "pkg_npm") load("//internal/pkg_web:pkg_web.bzl", _pkg_web = "pkg_web") -check_bazel_version = _check_bazel_version copy_to_bin = _copy_to_bin params_file = _params_file nodejs_binary = _nodejs_binary
diff --git a/internal/common/BUILD.bazel b/internal/common/BUILD.bazel index da34750..d0baa65 100644 --- a/internal/common/BUILD.bazel +++ b/internal/common/BUILD.bazel
@@ -27,9 +27,6 @@ visibility = ["//visibility:public"], ) -# Exported to be consumed for generating stardoc. -exports_files(["check_bazel_version.bzl"]) - check_version_test_suite() filegroup(
diff --git a/internal/common/check_bazel_version.bzl b/internal/common/check_bazel_version.bzl deleted file mode 100644 index ace77fc..0000000 --- a/internal/common/check_bazel_version.bzl +++ /dev/null
@@ -1,92 +0,0 @@ -# Copyright 2017 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. - -"""Check Bazel version - -We recommend forcing all users to update to at least the same version of Bazel -as the continuous integration, so they don't trip over incompatibilities with -rules used in the project. -""" - -load(":check_version.bzl", "check_version", "check_version_range") - -# From https://github.com/tensorflow/tensorflow/blob/5541ef4fbba56cf8930198373162dd3119e6ee70/tensorflow/workspace.bzl#L44 - -# Check that a specific bazel version is being used. -# Args: minimum_bazel_version in the form "<major>.<minor>.<patch>" -def check_bazel_version(minimum_bazel_version, message = ""): - """ - Verify the users Bazel version is at least the given one. - - This can be used in rule implementations that depend on changes in Bazel, - to warn users about a mismatch between the rule and their installed Bazel - version. - - This should *not* be used in users WORKSPACE files. To locally pin your - Bazel version, just create the .bazelversion file in your workspace. - - Args: - minimum_bazel_version: a string indicating the minimum version - message: optional string to print to your users, could be used to help them update - """ - if "bazel_version" not in dir(native): - fail("\nCurrent Bazel version is lower than 0.2.1, expected at least %s\n" % - minimum_bazel_version) - elif native.bazel_version and not check_version(native.bazel_version, minimum_bazel_version): - fail("\nCurrent Bazel version is {}, expected at least {}\n{}".format( - native.bazel_version, - minimum_bazel_version, - message, - )) - -# Check that a bazel version being used is in the version range. -# Args: -# minimum_bazel_version in the form "<major>.<minor>.<patch>" -# maximum_bazel_version in the form "<major>.<minor>.<patch>" -def check_bazel_version_range(minimum_bazel_version, maximum_bazel_version, message = ""): - """ - Verify the users Bazel version is in the version range. - - This should be called from the `WORKSPACE` file so that the build fails as - early as possible. For example: - - ``` - # in WORKSPACE: - load("@build_bazel_rules_nodejs//:index.bzl", "check_bazel_version_range") - check_bazel_version_range("0.11.0", "0.22.0") - ``` - - Args: - minimum_bazel_version: a string indicating the minimum version - maximum_bazel_version: a string indicating the maximum version - message: optional string to print to your users, could be used to help them update - """ - if "bazel_version" not in dir(native): - fail("\nCurrent Bazel version is lower than 0.2.1, expected at least %s\n" % - minimum_bazel_version) - elif not native.bazel_version: - print("\nCurrent Bazel is not a release version, cannot check for " + - "compatibility.") - print("Make sure that you are running at least Bazel %s.\n" % minimum_bazel_version) - elif not check_version_range( - native.bazel_version, - minimum_bazel_version, - maximum_bazel_version, - ): - fail("\nCurrent Bazel version is {}, expected >= {} and <= {}\n{}".format( - native.bazel_version, - minimum_bazel_version, - maximum_bazel_version, - message, - ))
diff --git a/internal/node/BUILD.bazel b/internal/node/BUILD.bazel index 308fa21..f8b877f 100644 --- a/internal/node/BUILD.bazel +++ b/internal/node/BUILD.bazel
@@ -31,6 +31,7 @@ "//internal/npm_install:bzl", "//third_party/github.com/bazelbuild/bazel-skylib:bzl", "@bazel_skylib//lib:types", + "@bazel_skylib//lib:versions", "@rules_nodejs//nodejs:bzl", ], )
diff --git a/internal/node/node_repositories.bzl b/internal/node/node_repositories.bzl index 114cf3a..00f894b 100644 --- a/internal/node/node_repositories.bzl +++ b/internal/node/node_repositories.bzl
@@ -18,11 +18,11 @@ See https://docs.bazel.build/versions/main/skylark/repository_rules.html """ +load("@bazel_skylib//lib:versions.bzl", "versions") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@rules_nodejs//nodejs/private:os_name.bzl", "OS_ARCH_NAMES", "node_exists_for_os", "os_name") load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains", node_repositories_rule = "node_repositories") load("@rules_nodejs//nodejs:yarn_repositories.bzl", "yarn_repositories") -load("//internal/common:check_bazel_version.bzl", "check_bazel_version") def node_repositories(**kwargs): """ @@ -35,12 +35,7 @@ """ # Require that users update Bazel, so that we don't need to support older ones. - check_bazel_version( - message = """ - Bazel current LTS version (4.0.0) is the minimum required to use rules_nodejs. - """, - minimum_bazel_version = "4.0.0", - ) + versions.check("4.0.0") # Back-compat: allow yarn_repositories args to be provided to node_repositories yarn_args = {}
diff --git a/internal/npm_install/npm_install.bzl b/internal/npm_install/npm_install.bzl index 3f61bc0..79d04f9 100644 --- a/internal/npm_install/npm_install.bzl +++ b/internal/npm_install/npm_install.bzl
@@ -24,7 +24,6 @@ load("@rules_nodejs//nodejs/private:os_name.bzl", "is_windows_os", "os_name") load("@rules_nodejs//nodejs/private:node_labels.bzl", "get_node_label", "get_npm_label") load("//:version.bzl", "VERSION") -load("//internal/common:check_bazel_version.bzl", "check_bazel_version") COMMON_ATTRIBUTES = dict(dict(), **{ "data": attr.label_list( @@ -637,27 +636,8 @@ repository_ctx.path("node_modules"), ) -def _check_min_bazel_version(rule, repository_ctx): - if repository_ctx.attr.symlink_node_modules: - # When using symlink_node_modules enforce the minimum Bazel version required - check_bazel_version( - message = """ - A minimum Bazel version of 0.26.0 is required for the %s @%s repository rule. - - By default, yarn_install and npm_install in build_bazel_rules_nodejs >= 0.30.0 - depends on the managed directory feature added in Bazel 0.26.0. See - https://github.com/bazelbuild/rules_nodejs/wiki#migrating-to-rules_nodejs-030. - - You can opt out of this feature by setting `symlink_node_modules = False` - on all of your yarn_install & npm_install rules. - """ % (rule, repository_ctx.attr.name), - minimum_bazel_version = "0.26.0", - ) - def _npm_install_impl(repository_ctx): """Core implementation of npm_install.""" - _check_min_bazel_version("npm_install", repository_ctx) - is_windows_host = is_windows_os(repository_ctx) node = repository_ctx.path(get_node_label(repository_ctx)) npm = get_npm_label(repository_ctx) @@ -804,8 +784,6 @@ def _yarn_install_impl(repository_ctx): """Core implementation of yarn_install.""" - _check_min_bazel_version("yarn_install", repository_ctx) - is_windows_host = is_windows_os(repository_ctx) node = repository_ctx.path(get_node_label(repository_ctx)) yarn_label = repository_ctx.attr.yarn
diff --git a/packages/concatjs/internal/ts_repositories.bzl b/packages/concatjs/internal/ts_repositories.bzl index 30cb405..1d655a9 100644 --- a/packages/concatjs/internal/ts_repositories.bzl +++ b/packages/concatjs/internal/ts_repositories.bzl
@@ -20,7 +20,7 @@ load("@bazel_gazelle//:deps.bzl", "go_repository") # END-DEV-ONLY -load("@build_bazel_rules_nodejs//:index.bzl", "check_bazel_version", "check_rules_nodejs_version") +load("@bazel_skylib//lib:versions.bzl", "versions") def ts_setup_workspace(): """This repository rule should be called from your WORKSPACE file. @@ -30,10 +30,7 @@ """ # 0.18.0: support for .bazelignore - check_bazel_version("0.18.0") - - # 0.16.8: ng_package fix for packaging binary files - check_rules_nodejs_version("0.16.8") + versions.check("0.18.0") # BEGIN-DEV-ONLY def ts_setup_dev_workspace():