Skip to content

Commit

Permalink
chore: upgrade to Bazel 4 (#2537)
Browse files Browse the repository at this point in the history
Also add integration testing against previous two major releases, so we don't accidentally force users to upgrade
  • Loading branch information
alexeagle authored Mar 22, 2021
1 parent 8d0218c commit 4859a0f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
bazel: 3.6.0
bazel: 4.0.0
tasks:
ubuntu1604:
name: ubuntu1604
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.0
4.0.0
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ so this repo can be thought of as "JavaScript rules for Bazel" as well. (We woul

This repository is maintained by volunteers in the Bazel community. Neither Google, nor the Bazel team, provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases.

We follow semantic versioning. Patch releases have bugfixes, minor releases have new features. Only major releases (1.x, 2.x) have breaking changes.
We follow semantic versioning. Patch releases have bugfixes, minor releases have new features. Only major releases (1.x, 2.x) have breaking changes. We support the last two major releases of Bazel, see `SUPPORTED_BAZEL_VERSIONS` in our `/index.bzl` for the list we test against.

We strive to give you an easy upgrade path when we do introduce a breaking change by documenting a migration path.
If you use code from an `/internal` path, or the labs package, these are not subject to our support policy and may have breaking changes or removals with no warning or migration path.

Expand Down
1 change: 0 additions & 1 deletion e2e/symlinked_node_modules_npm/.bazelversion

This file was deleted.

1 change: 0 additions & 1 deletion e2e/symlinked_node_modules_yarn/.bazelversion

This file was deleted.

5 changes: 3 additions & 2 deletions index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,17 @@ def yarn_install(**kwargs):
# against.
# This version should be updated together with the version of the Bazel
# in .bazelversion. This is asserted in //internal:bazel_version_test.
BAZEL_VERSION = "3.6.0"
BAZEL_VERSION = "4.0.0"

# Versions of Bazel which users should be able to use.
# Ensures we don't break backwards-compatibility,
# accidentally forcing users to update their LTS-supported bazel.
# These are the versions used when testing nested workspaces with
# bazel_integration_test.
SUPPORTED_BAZEL_VERSIONS = [
# TODO: add LTS versions of bazel like 1.0.0, 2.0.0
BAZEL_VERSION,
"3.6.0",
"2.2.0",
]

def check_rules_nodejs_version(minimum_version_string):
Expand Down
38 changes: 17 additions & 21 deletions internal/bazel_integration_test/bazel_integration_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
"""Bazel integration testing
"""

load("@build_bazel_rules_nodejs//:index.bzl", "SUPPORTED_BAZEL_VERSIONS")
load("@build_bazel_rules_nodejs//:index.bzl", "BAZEL_VERSION", "SUPPORTED_BAZEL_VERSIONS")
load("@build_bazel_rules_nodejs//packages:index.bzl", "NPM_PACKAGES")
load("//internal/common:windows_utils.bzl", "BATCH_RLOCATION_FUNCTION", "is_windows")

BAZEL_BINARY = "@build_bazel_bazel_%s//:bazel_binary" % SUPPORTED_BAZEL_VERSIONS[0].replace(".", "_")

# Avoid using non-normalized paths (workspace/../other_workspace/path)
def _to_manifest_path(ctx, file):
if file.short_path.startswith("../"):
Expand All @@ -29,10 +27,6 @@ def _to_manifest_path(ctx, file):
return ctx.workspace_name + "/" + file.short_path

def _bazel_integration_test(ctx):
if len(SUPPORTED_BAZEL_VERSIONS) > 1:
fail("""
bazel_integration_test doesn't support multiple Bazel versions to test against yet.
""")
if len(ctx.files.workspace_files) == 0:
fail("""
No files were found to run under integration testing. See comment in /.bazelrc.
Expand Down Expand Up @@ -126,7 +120,7 @@ ${{COMMAND}}

BAZEL_INTEGRATION_TEST_ATTRS = {
"bazel_binary": attr.label(
default = BAZEL_BINARY,
mandatory = True,
doc = """The bazel binary files to test against.
It is assumed by the test runner that the bazel binary is found at label_workspace/bazel (wksp/bazel.exe on Windows)""",
Expand Down Expand Up @@ -275,16 +269,18 @@ def rules_nodejs_integration_test(name, **kwargs):
for key in npm_packages:
_tar_npm_packages[key + ".tar"] = npm_packages[key]

bazel_integration_test(
name = name,
check_npm_packages = NPM_PACKAGES,
repositories = repositories,
# some bazelrc imports are outside of the nested workspace so
# the test runner will handle these as special cases
bazelrc_imports = {
"//:common.bazelrc": "import %workspace%/../../common.bazelrc",
},
npm_packages = _tar_npm_packages,
tags = tags,
**kwargs
)
for bazel_version in SUPPORTED_BAZEL_VERSIONS:
bazel_integration_test(
name = "%s_%s" % (name, "bazel" + bazel_version) if bazel_version != BAZEL_VERSION else name,
check_npm_packages = NPM_PACKAGES,
repositories = repositories,
bazel_binary = "@build_bazel_bazel_%s//:bazel_binary" % bazel_version.replace(".", "_"),
# some bazelrc imports are outside of the nested workspace so
# the test runner will handle these as special cases
bazelrc_imports = {
"//:common.bazelrc": "import %workspace%/../../common.bazelrc",
},
npm_packages = _tar_npm_packages,
tags = tags,
**kwargs
)

0 comments on commit 4859a0f

Please sign in to comment.