Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Bazel to v3.5.0 #11041

Merged
merged 2 commits into from
Mar 18, 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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.1
3.5.0
81 changes: 43 additions & 38 deletions Makefile

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ git_repository(

http_archive(
name = "bazel_toolchains",
sha256 = "7ebb200ed3ca3d1f7505659c7dfed01c4b5cb04c3a6f34140726fe22f5d35e86",
strip_prefix = "bazel-toolchains-3.4.1",
sha256 = "89a053218639b1c5e3589a859bb310e0a402dedbe4ee369560e66026ae5ef1f2",
strip_prefix = "bazel-toolchains-3.5.0",
urls = [
"https://github.com/bazelbuild/bazel-toolchains/releases/download/3.4.1/bazel-toolchains-3.4.1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/3.4.1/bazel-toolchains-3.4.1.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/releases/download/3.5.0/bazel-toolchains-3.5.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/3.5.0/bazel-toolchains-3.5.0.tar.gz",
],
)

Expand Down
6 changes: 3 additions & 3 deletions docs/contributing/adding_a_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ and then push nodeup using:
export S3_BUCKET_NAME=<yourbucketname>
make kops-install dev-upload UPLOAD_DEST=s3://${S3_BUCKET_NAME}

KOPS_VERSION=`bazel run //cmd/kops version -- --short`
KOPS_VERSION=`bazelisk run //cmd/kops version -- --short`
export KOPS_BASE_URL=https://${S3_BUCKET_NAME}.s3.amazonaws.com/kops/${KOPS_VERSION}/
kops create cluster <clustername> --zones us-east-1b
...
Expand All @@ -251,7 +251,7 @@ If you have changed the dns or kOps controllers, you would want to test them as
For dns-controller:

```bash
KOPS_VERSION=`bazel run //cmd/kops version -- --short`
KOPS_VERSION=`bazelisk run //cmd/kops version -- --short`
export DOCKER_IMAGE_PREFIX=${USER}/
export DOCKER_REGISTRY=
make dns-controller-push
Expand All @@ -261,7 +261,7 @@ export DNSCONTROLLER_IMAGE=${DOCKER_IMAGE_PREFIX}dns-controller:${KOPS_VERSION}
For kops-controller:

```bash
KOPS_VERSION=`bazel run //cmd/kops version -- --short`
KOPS_VERSION=`bazelisk run //cmd/kops version -- --short`
export DOCKER_IMAGE_PREFIX=${USER}/
export DOCKER_REGISTRY=
make kops-controller-push
Expand Down
8 changes: 3 additions & 5 deletions docs/contributing/bazel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

## Overview

Building with bazel offers a deterministic, faster build, including creating smaller docker images.
Building with Bazel offers a deterministic, faster build, including creating smaller docker images.

While bazel works well for small projects, building with kubernetes still has a few challenges. We take the following approach:
While bazel works well for small projects, building with kubernetes still has a few challenges. We take the following approach:

* We use [Bazelisk](https://github.com/bazelbuild/bazelisk), which automatically picks the correct version of Bazel for a branch
* We don't yet generate files in bazel - we use external scripts (for now)
* We vendor our dependencies, rather than relying on gazelle (although actually gazelle works, the issue is when external dependencies like apimachinery include bazel files that confuse gazelle)
* We strip bazel files from external dependencies, so we don't confuse gazelle

## Bazel versions:
For building kOps release branches 1.14 and older, you may need to run an older version of bazel such as `0.24.0`. kOps 1.15 and newer should be able to use more recent versions of bazel due to deprecation fixes that have not be backported.

## How to run

```
Expand Down
3 changes: 1 addition & 2 deletions docs/contributing/vendoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ vendored dependencies.
The following software must be installed prior to running the
update commands:

* [bazel](https://github.com/bazelbuild/bazel)
* [bazelisk](https://github.com/bazelbuild/bazelisk)
* [go mod](https://github.com/golang/go/wiki/Modules)
* [hg](https://www.mercurial-scm.org/wiki/Download)

## Adding a dependency to the vendor directory

Expand Down
1 change: 1 addition & 0 deletions hack/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.16

require (
github.com/bazelbuild/bazel-gazelle v0.22.3
github.com/bazelbuild/bazelisk v1.7.5 // indirect
github.com/client9/misspell v0.3.4
golang.org/x/tools v0.1.0
honnef.co/go/tools v0.1.3
Expand Down
6 changes: 6 additions & 0 deletions hack/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/bazelbuild/bazel-gazelle v0.22.3 h1:cfvF5dcjFKTehIQkLWioFWpGWi41Q38/WBM2d/2QCTs=
github.com/bazelbuild/bazel-gazelle v0.22.3/go.mod h1:ntN7pek1cf7Juk0AHamAsEj3Hokt1Q9jso6bFOVX4Ns=
github.com/bazelbuild/bazelisk v1.7.5 h1:WAUQghzJdzpB5Dr3eBwoywsY9uWSBVSV6MAmDo1m+z8=
github.com/bazelbuild/bazelisk v1.7.5/go.mod h1:z1OyA/qel4OHS8Ym1Tz4XUB6I9c+GJIR+4ch+8XJ6yk=
github.com/bazelbuild/buildtools v0.0.0-20200718160251-b1667ff58f71 h1:Et1IIXrXwhpDvR5wH9REPEZ0sUtzUoJSq19nfmBqzBY=
github.com/bazelbuild/buildtools v0.0.0-20200718160251-b1667ff58f71/go.mod h1:5JP0TXzWDHXv8qvxRC4InIazwdyDseBDbzESUMKk1yU=
github.com/bazelbuild/rules_go v0.0.0-20190719190356-6dae44dc5cab h1:wzbawlkLtl2ze9w/312NHZ84c7kpUCtlkD8HgFY27sw=
github.com/bazelbuild/rules_go v0.0.0-20190719190356-6dae44dc5cab/go.mod h1:MC23Dc/wkXEyk3Wpq6lCqz0ZAYOZDw2DR5y3N1q2i7M=
github.com/bazelbuild/rules_go v0.24.7/go.mod h1:MC23Dc/wkXEyk3Wpq6lCqz0ZAYOZDw2DR5y3N1q2i7M=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down Expand Up @@ -211,6 +214,8 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI=
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
Expand Down Expand Up @@ -268,6 +273,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
Expand Down
25 changes: 25 additions & 0 deletions hack/install-bazelisk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

# Copyright 2021 The Kubernetes Authors.
#
# 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.

set -o errexit
set -o nounset
set -o pipefail

if ! command -v bazelisk &> /dev/null; then
. "$(dirname "${BASH_SOURCE[0]}")/common.sh"
cd "${KOPS_ROOT}/hack" || exit 1
go install github.com/bazelbuild/bazelisk
fi
2 changes: 2 additions & 0 deletions hack/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package hack

import (
_ "github.com/bazelbuild/bazelisk"

_ "github.com/bazelbuild/bazel-gazelle/cmd/gazelle"

_ "github.com/client9/misspell/cmd/misspell"
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

cd "${KOPS_ROOT}" || exit 1

bad_files=$(git ls-files "*.go" | grep -v vendor | xargs bazel run //:gofmt -- -s -w -l)
bad_files=$(git ls-files "*.go" | grep -v vendor | xargs bazelisk run //:gofmt -- -s -w -l)
if [[ -n "${bad_files}" ]]; then
echo "FAIL: 'make gofmt' needs to be run on the following files: "
echo "${bad_files}"
Expand Down