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

bazel: tweaks to get build & test working #3523

Merged
merged 4 commits into from
Oct 3, 2017
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
8 changes: 8 additions & 0 deletions channels/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
filegroup(
name = "channeldata",
srcs = [
"alpha",
"stable",
],
visibility = ["//visibility:public"],
)
8 changes: 8 additions & 0 deletions cmd/kops/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ go_binary(
name = "kops",
library = ":go_default_library",
visibility = ["//visibility:public"],
x_defs = {
"k8s.io/kops.Version": "1.8.0-alpha.1", # keep
"k8s.io/kops.GitVersion": "{BUILD_SCM_REVISION}", # keep
},
)

go_test(
Expand All @@ -126,6 +130,10 @@ go_test(
"delete_confirm_test.go",
"integration_test.go",
],
data = [
"//channels:channeldata", # keep
"//tests/integration:exported_testdata", # keep
],
library = ":go_default_library",
deps = [
"//cmd/kops/util:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions nodeup/pkg/model/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ go_test(
"kube_apiserver_test.go",
"kubelet_test.go",
],
data = glob(["tests/**"]), #keep
library = ":go_default_library",
deps = [
"//nodeup/pkg/distros:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions pkg/model/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ go_test(
"bootstrapscript_test.go",
"context_test.go",
],
data = glob(["tests/**"]), #keep
library = ":go_default_library",
deps = [
"//pkg/apis/kops:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions pkg/model/iam/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["iam_builder_test.go"],
data = glob(["tests/*"]), #keep
library = ":go_default_library",
deps = [
"//pkg/apis/kops:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions pkg/util/templater/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = ["templater_test.go"],
data = glob(["integration_tests.yml"]), #keep
library = ":go_default_library",
deps = [
"//pkg/diff:go_default_library",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_test")
go_test(
name = "go_default_test",
srcs = ["integration_test.go"],
data = glob(["main/*"]), #keep
deps = [
"//pkg/apis/kops:go_default_library",
"//pkg/diff:go_default_library",
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
filegroup(
name = "exported_testdata",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --workspace_status_command=./tools/get_workspace_status
30 changes: 30 additions & 0 deletions tools/get_workspace_status
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# This script will be run bazel when building process starts to
# generate key-value information that represents the status of the
# workspace. The output should be like
#
# KEY1 VALUE1
# KEY2 VALUE2
#
# If the script exits with non-zero code, it's considered as a failure
# and the output will be discarded.

# The code below presents an implementation that works for git repository
git_rev=$(git rev-parse HEAD)
if [[ $? != 0 ]];
then
exit 1
fi
echo "BUILD_SCM_REVISION ${git_rev}"

# Check whether there are any uncommited changes
git diff-index --quiet HEAD --
if [[ $? == 0 ]];
then
tree_status="Clean"
else
tree_status="Modified"
fi
echo "BUILD_SCM_STATUS ${tree_status}"

1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/awsup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
"aws_apitarget.go",
"aws_cloud.go",
"aws_utils.go",
"instancegroups.go",
"logging_retryer.go",
"machine_types.go",
"mock_aws_cloud.go",
Expand Down
2 changes: 2 additions & 0 deletions upup/pkg/fi/cloudup/gce/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ go_library(
"gce_apitarget.go",
"gce_cloud.go",
"gce_url.go",
"instancegroups.go",
"labels.go",
"mock_gce_cloud.go",
"op.go",
"status.go",
"utils.go",
"wrappers.go",
],
visibility = ["//visibility:public"],
deps = [
Expand Down