From 506d87b963fa3540c719bb2765cf49913804272c Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Wed, 2 Aug 2023 08:15:54 -0700 Subject: [PATCH] Update bazel, rules_go and gazelle --- Makefile | 2 +- WORKSPACE | 30 +++++++++++++++++++++++------- images/default/Dockerfile | 2 +- tools/bazel.mk | 2 +- tools/rules_go_sdk.patch | 10 +++++----- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 1e00e0c91..f9e95245d 100644 --- a/Makefile +++ b/Makefile @@ -205,7 +205,7 @@ nogo-tests: # For unit tests, we take everything in the root, pkg/... and tools/..., and # pull in all directories in runsc except runsc/container. unit-tests: ## Local package unit tests in pkg/..., tools/.., etc. - @$(call test,--test_tag_filters=-nogo --test_filter=-//runsc/container/... //:all pkg/... tools/... runsc/... vdso/... test/trace/...) + @$(call test,'--test_tag_filters=-nogo,-requires-kvm' //:all pkg/... tools/... runsc/... vdso/... test/trace/...) .PHONY: unit-tests # See unit-tests: this includes runsc/container. diff --git a/WORKSPACE b/WORKSPACE index fb79487c2..51008ffbc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -52,19 +52,34 @@ http_archive( # Allow for patching of the go_sdk. "//tools:rules_go_sdk.patch", ], - sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", + sha256 = "278b7ff5a826f3dc10f04feaf0b70d48b68748ccd512d7f98bf442077f043fe3", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.41.0/rules_go-v0.41.0.zip", ], ) http_archive( - name = "bazel_gazelle", - sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405", + name = "googleapis", + sha256 = "9d1a930e767c93c825398b8f8692eca3fe353b9aaadedfbcf1fca2282c85df88", + strip_prefix = "googleapis-64926d52febbf298cb82a8f472ade4a3969ba922", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", - "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz", + "https://github.com/googleapis/googleapis/archive/64926d52febbf298cb82a8f472ade4a3969ba922.zip", + ], +) + +load("@googleapis//:repository_rules.bzl", "switched_rules_by_language") + +switched_rules_by_language( + name = "com_google_googleapis_imports", +) + +http_archive( + name = "bazel_gazelle", + sha256 = "29218f8e0cebe583643cbf93cae6f971be8a2484cdcfa1e45057658df8d54002", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz", ], ) @@ -2897,6 +2912,7 @@ go_repository( go_repository( name = "com_github_googleapis_gax_go_v2", + build_file_proto_mode = "disable_global", importpath = "github.com/googleapis/gax-go/v2", sum = "h1:IcsPKeInNvYi7eqSaDjiZqDDKu5rsmunY0Y1YupQSSQ=", version = "v2.7.0", diff --git a/images/default/Dockerfile b/images/default/Dockerfile index 921c45257..18eb8bde5 100644 --- a/images/default/Dockerfile +++ b/images/default/Dockerfile @@ -25,6 +25,6 @@ RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud ln -s /google-cloud-sdk/bin/gcloud /usr/bin/gcloud # Download the official bazel binary. The APT repository isn't used because there is not packages for arm64. -RUN sh -c 'curl -o /usr/local/bin/bazel https://releases.bazel.build/6.1.1/release/bazel-6.1.1-linux-$(uname -m | sed s/aarch64/arm64/) && chmod ugo+x /usr/local/bin/bazel' +RUN sh -c 'curl -o /usr/local/bin/bazel https://releases.bazel.build/6.3.1/release/bazel-6.3.1-linux-$(uname -m | sed s/aarch64/arm64/) && chmod ugo+x /usr/local/bin/bazel' WORKDIR /workspace ENTRYPOINT ["/usr/local/bin/bazel"] diff --git a/tools/bazel.mk b/tools/bazel.mk index ce94b7f68..1909d6753 100644 --- a/tools/bazel.mk +++ b/tools/bazel.mk @@ -264,7 +264,7 @@ build = $(call header,BUILD $(1)) && $(call build_paths,$(1),echo {}) copy = $(call header,COPY $(1) $(2)) && $(call build_paths,$(1),cp -fa {} $(2)) run = $(call header,RUN $(1) $(2)) && $(call build_paths,$(1),{} $(2)) sudo = $(call header,SUDO $(1) $(2)) && $(call build_paths,$(1),sudo -E {} $(2)) -test = $(call header,TEST $(1)) && $(call wrapper,$(BAZEL) test $(BAZEL_OPTIONS) $(TEST_OPTIONS) $(1)) +test = $(call header,TEST $(1)) && $(call wrapper,$(BAZEL) test --strip=never $(BAZEL_OPTIONS) $(TEST_OPTIONS) $(1)) sudocopy = $(call header,COPY $(1) $(2)) && $(call build_paths,$(1),sudo cp -fa {} $(2)) clean: ## Cleans the bazel cache. diff --git a/tools/rules_go_sdk.patch b/tools/rules_go_sdk.patch index 76caf47ff..3a6347eed 100644 --- a/tools/rules_go_sdk.patch +++ b/tools/rules_go_sdk.patch @@ -1,7 +1,7 @@ diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl --- a/go/private/sdk.bzl +++ b/go/private/sdk.bzl -@@ -126,6 +126,8 @@ def _go_download_sdk_impl(ctx): +@@ -130,6 +130,8 @@ def _go_download_sdk_impl(ctx): "sdks": ctx.attr.sdks, "urls": ctx.attr.urls, "version": version, @@ -10,7 +10,7 @@ diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl "strip_prefix": ctx.attr.strip_prefix, } return None -@@ -141,6 +143,8 @@ go_download_sdk_rule = repository_rule( +@@ -145,6 +147,8 @@ go_download_sdk_rule = repository_rule( ), "urls": attr.string_list(default = ["https://dl.google.com/go/{}"]), "version": attr.string(), @@ -19,12 +19,12 @@ diff --git a/go/private/sdk.bzl b/go/private/sdk.bzl "strip_prefix": attr.string(default = "go"), "_sdk_build_file": attr.label( default = Label("//go/private:BUILD.sdk.bazel"), -@@ -423,6 +427,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256): +@@ -440,6 +444,8 @@ def _remote_sdk(ctx, urls, strip_prefix, sha256): res = ctx.execute(["tar", "-xf", "go_sdk.tar.gz", "--strip-components=1"]) if res.return_code: fail("error extracting Go SDK:\n" + res.stdout + res.stderr) + if ctx.attr.patch: + ctx.patch(ctx.attr.patch, strip=ctx.attr.patch_strip) ctx.delete("go_sdk.tar.gz") - else: - ctx.download_and_extract( + elif (urls[0].endswith(".zip") and + host_goos != "windows" and