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

add hack/update-deps.sh #3

Merged
merged 2 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# build outputs
/bazel-*
/_artifacts
/_output

# macoOS
.DS_Store

# Files generated by IDEs, e.g. IntelliJ IDEA
.idea/
*.iml
.vscode/*
*.swp
*.sublime-project
*.sublime-workspace
*~
16 changes: 16 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# bazel workspace, see: https://bazel.build/

# rules for rules go current stable release below
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "97cf62bdef33519412167fd1e4b0810a318a7c234f5f8dc4f53e2da86241c492",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.15.3/rules_go-0.15.3.tar.gz"],
)

load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")

go_rules_dependencies()

go_register_toolchains()
4 changes: 4 additions & 0 deletions hack/.kazelcfg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"GoPrefix": "k8s.io/test-infra",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wound up fixing this in the next commit, FYI

"AddSourcesRules": true
}
44 changes: 44 additions & 0 deletions hack/update-bazel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Copyright 2016 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

REPO_ROOT=$(git rev-parse --show-toplevel)


# https://github.com/kubernetes/test-infra/issues/5699#issuecomment-348350792
cd ${REPO_ROOT}
TMP_GOPATH=$(mktemp -d)

cleanup() {
rm -rf "${TMP_GOPATH}"
}

trap cleanup EXIT

OUTPUT_GOBIN="${REPO_ROOT}/_output/bin"
GOBIN="${OUTPUT_GOBIN}" go install ./vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle
GOBIN="${OUTPUT_GOBIN}" go install ./vendor/github.com/kubernetes/repo-infra/kazel

touch "${REPO_ROOT}/vendor/BUILD.bazel"

"${OUTPUT_GOBIN}/gazelle" fix \
-external=vendored \
-mode=fix

"${OUTPUT_GOBIN}/kazel" \
-cfg-path="${REPO_ROOT}/hack/.kazelcfg.json"
55 changes: 55 additions & 0 deletions hack/update-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Copyright 2018 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.


# Run dep ensure and generate bazel rules.
#
# Usage:
# update-deps.sh <ARGS>
#
# The args are sent to dep ensure -v <ARGS>

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

REPO_ROOT=$(git rev-parse --show-toplevel)

trap 'echo "FAILED" >&2' ERR

# TODO(bentheelder): support first-class using a bazel-built dep instead
DEP="dep"

cd "${REPO_ROOT}"


# dep itself has a problematic testdata directory with infinite symlinks which
# makes bazel sad: https://github.com/golang/dep/pull/1412
# dep should probably be removing it, but it doesn't:
# https://github.com/golang/dep/issues/1580
rm -rf vendor/github.com/golang/dep/internal/fs/testdata
# go-bindata does too, and is not maintained ...
rm -rf vendor/github.com/jteeuwen/go-bindata/testdata
# docker has a contrib dir with nothing we use in it, dep will retain the licenses
# which includes some GPL, so we manually prune this.
# See https://github.com/kubernetes/steering/issues/57
rm -rf vendor/github.com/docker/docker/contrib
"${DEP}" ensure -v "$@"
rm -rf vendor/github.com/golang/dep/internal/fs/testdata
rm -rf vendor/github.com/jteeuwen/go-bindata/testdata
rm -rf vendor/github.com/docker/docker/contrib
hack/update-bazel.sh
echo SUCCESS
10 changes: 5 additions & 5 deletions pkg/build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ go_library(
importpath = "sigs.k8s.io/kind/pkg/build",
visibility = ["//visibility:public"],
deps = [
"//kind/pkg/build/kube:go_default_library",
"//kind/pkg/build/sources:go_default_library",
"//kind/pkg/exec:go_default_library",
"//pkg/build/kube:go_default_library",
"//pkg/build/sources:go_default_library",
"//pkg/exec:go_default_library",
"//vendor/github.com/pkg/errors:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
],
Expand All @@ -30,8 +30,8 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//kind/pkg/build/kube:all-srcs",
"//kind/pkg/build/sources:all-srcs",
"//pkg/build/kube:all-srcs",
"//pkg/build/sources:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
Expand Down
4 changes: 2 additions & 2 deletions pkg/build/sources/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//kind/hack:bindata.bzl", "go_bindata")
load("//hack:bindata.bzl", "go_bindata")

# IMPORTANT: if you make any cahnges here, you must also update hack/generate.sh
go_bindata(
name = "bindata",
srcs = [
"//kind/images:all-srcs",
"//images:all-srcs",
],
outs = [
"images_sources.go",
Expand Down