Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Add support for Bazel 3.0.0 #639

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildifier:
# TODO (suvanjan): Re-enable once issues are fixed.
warnings: "attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,confusing-name,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,function-docstring,git-repository,http-archive,integer-division,load,load-on-top,module-docstring,name-conventions,native-build,native-package,no-effect,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unreachable,unsorted-dict-items,unused-variable"
platforms:
ubuntu1604:
ubuntu1804:
build_targets:
- "--"
- "..."
Expand All @@ -18,7 +18,7 @@ platforms:
- "-//images/gcloud-bazel:gcloud-layer"
test_targets:
- "..."
ubuntu1804:
ubuntu2004:
build_targets:
- "--"
- "..."
Expand All @@ -29,12 +29,6 @@ platforms:
test_targets:
- "..."
macos:
shell_commands:
# create a python2 symlink
# see https://github.com/bazelbuild/continuous-integration/issues/854
# TODO(nlopezgi): remove once issue above is fixed
- mkdir /tmp/bin
- ln -s /usr/bin/python2.7 /tmp/bin/python2
build_targets:
- "--"
- "..."
Expand All @@ -44,15 +38,20 @@ platforms:
- "-//images/gcloud-bazel:gcloud-layer"
build_flags:
- "--verbose_failures"
# add the python2 symlink to the PATH
# see https://github.com/bazelbuild/continuous-integration/issues/854
# TODO(nlopezgi): remove once issue above is fixed
- "--action_env=PATH=/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/tmp/bin/"
test_targets:
- "..."
test_flags:
- "--verbose_failures"
# add the python2 symlink to the PATH
# see https://github.com/bazelbuild/continuous-integration/issues/854
# TODO(nlopezgi): remove once issue above is fixed
- "--action_env=PATH=/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/tmp/bin/"
min_supported_version:
name: "Minimum Supported Version"
bazel: "2.2.0"
platform: ubuntu1604
build_targets:
- "--"
- "..."
- "-//images/gcloud-bazel:gcloud_push"
- "-//images/gcloud-bazel:gcloud_installer"
- "-//images/gcloud-bazel:gcloud_install"
- "-//images/gcloud-bazel:gcloud-layer"
test_targets:
- "..."
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
3.0.0
16 changes: 3 additions & 13 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,13 @@ load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()

# Only needed if using the packaging rules.
load("@rules_python//python:pip.bzl", "pip3_import", "pip_repositories")
load("@rules_python//python:pip.bzl", "pip_install")

pip_repositories()

pip3_import(
pip_install(
name = "py_deps",
requirements = "//:requirements.txt",
)

load("@py_deps//:requirements.bzl", "pip_install")

pip_install()

http_archive(
name = "com_github_grpc_grpc",
sha256 = "f880ebeb2ccf0e47721526c10dd97469200e40b5f101a0d9774eb69efa0bd07a",
Expand All @@ -87,15 +81,11 @@ load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()

pip3_import(
pip_install(
name = "grpc_python_dependencies",
requirements = "@com_github_grpc_grpc//:requirements.bazel.txt",
)

load("@grpc_python_dependencies//:requirements.bzl", _grpc_pip_install = "pip_install")

_grpc_pip_install()

# upb_deps and apple_rules_dependencies are needed for grpc
load("@upb//bazel:workspace_deps.bzl", "upb_deps")

Expand Down
113 changes: 64 additions & 49 deletions k8s/k8s.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@
"""Rules for manipulation of K8s constructs."""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//toolchains/kubectl:kubectl_configure.bzl", "kubectl_configure")
load(":with-defaults.bzl", _k8s_defaults = "k8s_defaults")

k8s_defaults = _k8s_defaults

def k8s_repositories():
"""Download dependencies of k8s rules."""

excludes = native.existing_rules().keys()
_com_github_yaml_pyyaml_build_file = """\
load("@rules_python//python:defs.bzl", "py_binary", "py_library")

if "com_github_yaml_pyyaml" not in excludes:
# Used by utilities for roundtripping yaml.
http_archive(
name = "com_github_yaml_pyyaml",
build_file_content = """
py_library(
name = "yaml",
srcs = glob(["lib/yaml/*.py"]),
Expand All @@ -46,11 +40,21 @@ py_library(
],
visibility = ["//visibility:public"],
)
""",
sha256 = "e9df8412ddabc9c21b4437ee138875b95ebb32c25f07f962439e16005152e00e",
strip_prefix = "pyyaml-5.1.2",
urls = ["https://github.com/yaml/pyyaml/archive/5.1.2.zip"],
)
"""

# buildifier: disable=unnamed-macro
def k8s_repositories():
"""Download dependencies of k8s rules."""

# Used by utilities for roundtripping yaml.
maybe(
http_archive,
name = "com_github_yaml_pyyaml",
build_file_content = _com_github_yaml_pyyaml_build_file,
sha256 = "e9df8412ddabc9c21b4437ee138875b95ebb32c25f07f962439e16005152e00e",
strip_prefix = "pyyaml-5.1.2",
urls = ["https://github.com/yaml/pyyaml/archive/5.1.2.zip"],
)

# Register the default kubectl toolchain targets for supported platforms
# note these work with the autoconfigured toolchain
Expand All @@ -60,38 +64,49 @@ py_library(
"@io_bazel_rules_k8s//toolchains/kubectl:kubectl_osx_toolchain",
"@io_bazel_rules_k8s//toolchains/kubectl:kubectl_windows_toolchain",
)
if "io_bazel_rules_go" not in excludes:
http_archive(
name = "io_bazel_rules_go",
sha256 = "ac03931e56c3b229c145f1a8b2a2ad3e8d8f1af57e43ef28a26123362a1e3c7e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.4/rules_go-v0.24.4.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.24.4/rules_go-v0.24.4.tar.gz",
],
)
if "bazel_gazelle" not in excludes:
http_archive(
name = "bazel_gazelle",
sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
],
)
if "io_bazel_rules_docker" not in excludes:
http_archive(
name = "io_bazel_rules_docker",
sha256 = "6287241e033d247e9da5ff705dd6ef526bac39ae82f3d17de1b69f8cb313f9cd",
strip_prefix = "rules_docker-0.14.3",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.14.3/rules_docker-v0.14.3.tar.gz"],
)
if "bazel_skylib" not in excludes:
http_archive(
name = "bazel_skylib",
sha256 = "7ac0fa88c0c4ad6f5b9ffb5e09ef81e235492c873659e6bb99efb89d11246bcb",
strip_prefix = "bazel-skylib-1.0.3",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/1.0.3.tar.gz"],
)
if "k8s_config" not in excludes:
# WORKSPACE target to configure the kubectl tool
kubectl_configure(name = "k8s_config", build_srcs = False)

maybe(
http_archive,
name = "io_bazel_rules_go",
sha256 = "52d0a57ea12139d727883c2fef03597970b89f2cc2a05722c42d1d7d41ec065b",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.24.13/rules_go-v0.24.13.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.24.13/rules_go-v0.24.13.tar.gz",
],
)

maybe(
http_archive,
name = "bazel_gazelle",
sha256 = "222e49f034ca7a1d1231422cdb67066b885819885c356673cb1f72f748a3c9d4",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.3/bazel-gazelle-v0.22.3.tar.gz",
],
)

maybe(
http_archive,
name = "io_bazel_rules_docker",
sha256 = "f4a39a410da7e497a7ccd19e28c69c93a851d6adb76798355a0c8ba9855e9b75",
strip_prefix = "rules_docker-e15c9ebf203b7fa708e69ff5f1cdcf427d7edf6f",
# `master` as of 2021-02-04
urls = [
"https://github.com/bazelbuild/rules_docker/archive/e15c9ebf203b7fa708e69ff5f1cdcf427d7edf6f.zip",
],
)

maybe(
http_archive,
name = "bazel_skylib",
sha256 = "7ac0fa88c0c4ad6f5b9ffb5e09ef81e235492c873659e6bb99efb89d11246bcb",
strip_prefix = "bazel-skylib-1.0.3",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/1.0.3.tar.gz"],
)

# WORKSPACE target to configure the kubectl tool
maybe(
kubectl_configure,
name = "k8s_config",
build_srcs = False,
)
17 changes: 8 additions & 9 deletions k8s/k8s_go_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Macro to load Go package dependencies of Go binaries in this repository."""

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load(
"@io_bazel_rules_docker//repositories:go_repositories.bzl",
rules_docker_go_deps = "go_deps",
Expand All @@ -36,12 +37,10 @@ def deps():
rules_docker_repositories()
rules_docker_go_deps()

excludes = native.existing_rules().keys()

if "com_github_google_go_cmp" not in excludes:
go_repository(
name = "com_github_google_go_cmp",
importpath = "github.com/google/go-cmp",
sum = "h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=",
version = "v0.3.1",
)
maybe(
go_repository,
name = "com_github_google_go_cmp",
importpath = "github.com/google/go-cmp",
sum = "h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=",
version = "v0.3.1",
)