Skip to content

Commit

Permalink
Run buildifier on the build files and add it to "make check". (envoyp…
Browse files Browse the repository at this point in the history
…roxy#2088)

Signed-off-by: Piotr Sikora <[email protected]>
  • Loading branch information
PiotrSikora authored and istio-testing committed Jan 24, 2019
1 parent eafb657 commit 54d5807
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 47 deletions.
1 change: 0 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ genrule(
cmd = "echo $${ISTIO_VERSION:-\"0.3.0-dev\"} > \"$@\"",
visibility = ["//visibility:public"],
)

21 changes: 14 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

# http_archive is not a native function since bazel 0.19
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

load(
"//:repositories.bzl",
"googletest_repositories",
"mixerapi_dependencies",
"//:repositories.bzl",
"googletest_repositories",
"mixerapi_dependencies",
)

googletest_repositories()

mixerapi_dependencies()

bind(
Expand All @@ -36,35 +36,42 @@ bind(
#
# Determine SHA256 `wget https://github.com/envoyproxy/envoy/archive/COMMIT.tar.gz && sha256sum COMMIT.tar.gz`
ENVOY_SHA = "bbf5674c2c9a901ec4e964e4dd1d845516e672b2"

ENVOY_SHA256 = "a4e56688cd274db367a5ab905e4d02da6d271189c564ae05e87812c63790c7d6"

http_archive(
name = "envoy",
sha256 = ENVOY_SHA256,
strip_prefix = "envoy-" + ENVOY_SHA,
url = "https://github.com/envoyproxy/envoy/archive/" + ENVOY_SHA + ".tar.gz",
sha256 = ENVOY_SHA256,
)

load("@envoy//bazel:repositories.bzl", "envoy_dependencies")

envoy_dependencies()

load("@envoy//bazel:cc_configure.bzl", "cc_configure")

cc_configure()

load("@envoy_api//bazel:repositories.bzl", "api_dependencies")

api_dependencies()

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

go_rules_dependencies()

go_register_toolchains()

# Nov 28, 2017 (bazel 0.8.0 support)
RULES_PROTOBUF_SHA = "563b674a2ce6650d459732932ea2bc98c9c9a9bf"

RULES_PROTOBUF_SHA256 = "338e0d65cd709c6a6f9b5702466e641d536479be8b564d1e12a5d1de22a5cff6"

http_archive(
name = "org_pubref_rules_protobuf",
sha256 = RULES_PROTOBUF_SHA256,
strip_prefix = "rules_protobuf-" + RULES_PROTOBUF_SHA,
url = "https://github.com/pubref/rules_protobuf/archive/" + RULES_PROTOBUF_SHA + ".tar.gz",
sha256 = RULES_PROTOBUF_SHA256,
)
2 changes: 1 addition & 1 deletion cc_gogo_protobuf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
GOGO_PROTO_SHA = "100ba4e885062801d56799d78530b73b178a78f3"
GOGO_PROTO_SHA256 = "b04eb8eddd2d15d8b12d111d4ef7816fca6e5c5d495adf45fb8478278aa80f79"

def cc_gogoproto_repositories(bind=True):
def cc_gogoproto_repositories(bind = True):
BUILD = """
# Copyright 2017 Istio Authors. All Rights Reserved.
#
Expand Down
2 changes: 1 addition & 1 deletion googleapis.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
GOOGLEAPIS_SHA = "13ac2436c5e3d568bd0e938f6ed58b77a48aba15"
GOOGLEAPIS_SHA256 = "f48956fb8c55617ed052c20884465f06b9a57b807164431185be397ea46993ca"

def googleapis_repositories(bind=True):
def googleapis_repositories(bind = True):
GOOGLEAPIS_BUILD_FILE = """
package(default_visibility = ["//visibility:public"])
Expand Down
2 changes: 1 addition & 1 deletion include/istio/mixerclient/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ licenses(["notice"])
cc_library(
name = "headers_lib",
hdrs = [
"client.h",
"check_response.h",
"client.h",
"environment.h",
"options.h",
"timer.h",
Expand Down
2 changes: 1 addition & 1 deletion include/istio/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ cc_library(
"attribute_names.h",
],
visibility = ["//visibility:public"],
)
)
2 changes: 1 addition & 1 deletion protobuf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
PROTOBUF_SHA = "7492b5681231c79f0265793fa57dc780ae2481d6"
PROTOBUF_SHA256 = "46f1da3a6a6db66dd240cf95a5553198f7c6e98e6ac942fceb8a1cf03291d96e"

def protobuf_repositories(load_repo=True, bind=True):
def protobuf_repositories(load_repo = True, bind = True):
if load_repo:
http_archive(
name = "com_google_protobuf",
Expand Down
45 changes: 40 additions & 5 deletions script/check-style
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if [[ ! -x "${CLANG_FORMAT}" ]]; then
echo "Unsupported environment." ; exit 1 ;
fi

echo "clang-bin: http://releases.llvm.org/${CLANG_VERSION_REQUIRED}/clang+llvm-${CLANG_VERSION_REQUIRED}-${CLANG_BIN}"
echo "Downloading clang-format: http://releases.llvm.org/${CLANG_VERSION_REQUIRED}/clang+llvm-${CLANG_VERSION_REQUIRED}-${CLANG_BIN}"

CLANG_VERSION="$(${CLANG_FORMAT} -version | cut -d ' ' -f 3)"
if [[ "${CLANG_VERSION}" != "${CLANG_VERSION_REQUIRED}" ]]; then
Expand All @@ -42,7 +42,31 @@ if [[ ! -x "${CLANG_FORMAT}" ]]; then
curl --silent --show-error --retry 10 \
"http://releases.llvm.org/${CLANG_VERSION_REQUIRED}/clang+llvm-${CLANG_VERSION_REQUIRED}-${CLANG_BIN}" \
| tar Jx -C "${CLANG_DIRECTORY}" --strip=1 \
|| { echo "Could not install required clang-format. Skip formating." ; exit 0 ; }
|| { echo "Could not install required clang-format. Skip formatting." ; exit 1 ; }
fi
fi

BUILDIFIER=$(which buildifier)
if [[ ! -x "${BUILDIFIER}" ]]; then
BUILDIFIER="${HOME}/bin/buildifier"
if [[ ! -x "${BUILDIFIER}" ]]; then

if [ "$(uname)" == "Darwin" ]; then
BUILDIFIER_BIN="buildifier.osx"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
BUILDIFIER_BIN="buildifier"
else
echo "Unsupported environment." ; exit 1 ;
fi

echo "Downloading buildifier: https://github.com/bazelbuild/buildtools/releases/download/0.20.0/${BUILDIFIER_BIN}"

mkdir -p "${HOME}/bin"
curl --silent --show-error --retry 10 --location \
"https://github.com/bazelbuild/buildtools/releases/download/0.20.0/${BUILDIFIER_BIN}" \
-o "${BUILDIFIER}" \
|| { echo "Could not install required buildifier. Skip formatting." ; exit 1 ; }
chmod +x ${BUILDIFIER}
fi
fi

Expand All @@ -54,10 +78,21 @@ SOURCE_FILES=($(git ls-tree -r HEAD --name-only | grep -E '\.(h|c|cc|proto)$'))
"${CLANG_FORMAT}" -style=Google -i "${SOURCE_FILES[@]}" \
|| { echo "Could not run clang-format." ; exit 1 ; }

CHANGED_FILES=($(git diff HEAD --name-only | grep -E '\.(h|c|cc|proto)$'))
CHANGED_SOURCE_FILES=($(git diff HEAD --name-only | grep -E '\.(h|c|cc|proto)$'))

BAZEL_FILES=($(git ls-tree -r HEAD --name-only | grep -E '(\.bzl|BUILD|WORKSPACE)$'))
"${BUILDIFIER}" "${BAZEL_FILES[@]}" \
|| { echo "Could not run buildifier." ; exit 1 ; }

CHANGED_BAZEL_FILES=($(git diff HEAD --name-only | grep -E '(\.bzl|BUILD|WORKSPACE)$'))

if [[ "${#CHANGED_FILES}" -ne 0 ]]; then
echo "Files not formatted: ${CHANGED_FILES[@]}"
if [[ "${#CHANGED_SOURCE_FILES}" -ne 0 ]]; then
echo -e "Source file(s) not formatted:\n${CHANGED_SOURCE_FILES[@]}"
fi
if [[ "${#CHANGED_BAZEL_FILES}" -ne 0 ]]; then
echo -e "Bazel file(s) not formatted:\n${CHANGED_BAZEL_FILES[@]}"
fi
if [[ "${#CHANGED_SOURCE_FILES}" -ne 0 || "${#CHANGED_BAZEL_FILES}" -ne 0 ]]; then
exit 1
fi
echo "All files are properly formatted."
Expand Down
2 changes: 1 addition & 1 deletion src/envoy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ envoy_cc_binary(

pkg_tar(
name = "envoy_tar",
srcs = [":envoy"],
extension = "tar.gz",
files = [":envoy"],
mode = "0755",
package_dir = "/usr/local/bin/",
tags = ["manual"],
Expand Down
8 changes: 4 additions & 4 deletions src/envoy/http/authn/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ envoy_cc_library(
deps = [
"//external:authentication_policy_config_cc_proto",
"//src/envoy/http/jwt_auth:jwt_lib",
"//src/envoy/utils:filter_names_lib",
"//src/envoy/utils:utils_lib",
"//src/istio/authn:context_proto_cc",
"//src/envoy/utils:filter_names_lib",
],
)

Expand All @@ -64,10 +64,10 @@ envoy_cc_library(
":authenticator",
"//external:authentication_policy_config_cc_proto",
"//src/envoy/utils:authn_lib",
"//src/envoy/utils:filter_names_lib",
"//src/envoy/utils:utils_lib",
"//src/istio/authn:context_proto_cc",
"@envoy//source/exe:envoy_common_lib",
"//src/envoy/utils:filter_names_lib",
],
)

Expand Down Expand Up @@ -99,8 +99,8 @@ envoy_cc_test(
deps = [
":authenticator",
":test_utils",
"@envoy//test/mocks/network:network_mocks",
"//src/envoy/utils:filter_names_lib",
"@envoy//test/mocks/network:network_mocks",
"@envoy//test/mocks/ssl:ssl_mocks",
"@envoy//test/test_common:utility_lib",
],
Expand Down Expand Up @@ -162,8 +162,8 @@ envoy_cc_test(
repository = "@envoy",
deps = [
":filter_lib",
"//src/envoy/utils:filter_names_lib",
"@envoy//source/common/common:utility_lib",
"@envoy//test/integration:http_protocol_integration_lib",
"//src/envoy/utils:filter_names_lib",
],
)
4 changes: 2 additions & 2 deletions src/envoy/http/jwt_auth/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ envoy_cc_library(
repository = "@envoy",
deps = [
":jwt_authenticator_lib",
"@envoy//source/exe:envoy_common_lib",
"//src/envoy/utils:filter_names_lib",
"@envoy//source/exe:envoy_common_lib",
],
)

Expand All @@ -80,8 +80,8 @@ envoy_cc_library(
repository = "@envoy",
deps = [
":http_filter_lib",
"@envoy//source/exe:envoy_common_lib",
"//src/envoy/utils:filter_names_lib",
"@envoy//source/exe:envoy_common_lib",
],
)

Expand Down
3 changes: 2 additions & 1 deletion src/envoy/tcp/forward_downstream_sni/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ envoy_cc_library(
"@envoy//source/exe:envoy_common_lib",
],
)

envoy_cc_library(
name = "forward_downstream_sni_lib",
srcs = ["forward_downstream_sni.cc"],
Expand All @@ -47,8 +48,8 @@ envoy_cc_test(
srcs = ["forward_downstream_sni_test.cc"],
repository = "@envoy",
deps = [
":forward_downstream_sni_lib",
":config_lib",
":forward_downstream_sni_lib",
"@envoy//test/mocks/network:network_mocks",
"@envoy//test/mocks/server:server_mocks",
"@envoy//test/mocks/stream_info:stream_info_mocks",
Expand Down
8 changes: 4 additions & 4 deletions src/envoy/tcp/sni_verifier/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ envoy_cc_library(

envoy_cc_library(
name = "sni_verifier_lib",
srcs = [ "sni_verifier.cc"],
hdrs = [ "sni_verifier.h"],
repository = "@envoy",
srcs = ["sni_verifier.cc"],
hdrs = ["sni_verifier.h"],
external_deps = ["ssl"],
repository = "@envoy",
deps = [
"@envoy//source/exe:envoy_common_lib",
],
Expand All @@ -49,8 +49,8 @@ envoy_cc_test(
srcs = ["sni_verifier_test.cc"],
repository = "@envoy",
deps = [
":sni_verifier_lib",
":config_lib",
":sni_verifier_lib",
"@envoy//test/mocks/network:network_mocks",
"@envoy//test/mocks/server:server_mocks",
"@envoy//test/test_common:tls_utility_lib",
Expand Down
4 changes: 2 additions & 2 deletions src/envoy/tcp/tcp_cluster_rewrite/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ envoy_cc_library(
repository = "@envoy",
deps = [
":tcp_cluster_rewrite_lib",
"//src/envoy/utils:utils_lib",
"//external:tcp_cluster_rewrite_config_cc_proto",
"//src/envoy/utils:utils_lib",
"@envoy//source/exe:envoy_common_lib",
],
)
Expand All @@ -53,8 +53,8 @@ envoy_cc_test(
srcs = ["tcp_cluster_rewrite_test.cc"],
repository = "@envoy",
deps = [
":tcp_cluster_rewrite_lib",
":config_lib",
":tcp_cluster_rewrite_lib",
"@envoy//test/mocks/network:network_mocks",
"@envoy//test/mocks/server:server_mocks",
"@envoy//test/mocks/stream_info:stream_info_mocks",
Expand Down
2 changes: 1 addition & 1 deletion src/envoy/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ envoy_cc_library(
repository = "@envoy",
visibility = ["//visibility:public"],
deps = [
":filter_names_lib",
":utils_lib",
"//include/istio/utils:attribute_names_header",
"//src/istio/authn:context_proto_cc",
"//src/istio/utils:attribute_names_lib",
"//src/istio/utils:utils_lib",
":filter_names_lib",
"@envoy//source/exe:envoy_common_lib",
],
)
Expand Down
2 changes: 1 addition & 1 deletion src/istio/control/tcp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ cc_test(
linkstatic = 1,
deps = [
":control_lib",
"//src/istio/utils:utils_lib",
"//external:googletest_main",
"//src/istio/utils:utils_lib",
],
)

Expand Down
6 changes: 3 additions & 3 deletions src/istio/utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ cc_library(
"local_attributes.cc",
"protobuf.cc",
"status.cc",
"utils.cc"
"utils.cc",
],
hdrs = [
"utils.h",
],
visibility = ["//visibility:public"],
deps = [
":attribute_names_lib",
"//external:mixer_client_config_cc_proto",
"//external:protobuf",
"//include/istio/utils:headers_lib",
"//include/istio/utils:attribute_names_header",
"//external:mixer_client_config_cc_proto",
"//include/istio/utils:headers_lib",
],
)

Expand Down
12 changes: 6 additions & 6 deletions test/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ envoy_cc_test(
srcs = ["istio_http_integration_test.cc"],
repository = "@envoy",
deps = [
"@envoy//source/common/common:utility_lib",
"@envoy//test/integration:http_protocol_integration_lib",
"//include/istio/utils:attribute_names_header",
"//src/envoy/http/authn:filter_lib",
"//src/envoy/http/jwt_auth:http_filter_factory",
"//src/envoy/http/jwt_auth:jwt_lib",
"//src/envoy/utils:filter_names_lib",
"//src/envoy/http/mixer:filter_lib",
"//src/envoy/utils:filter_names_lib",
"@envoy//source/common/common:utility_lib",
"@envoy//test/integration:http_protocol_integration_lib",
],
)

Expand All @@ -42,13 +42,13 @@ envoy_cc_test(
srcs = ["exchanged_token_integration_test.cc"],
repository = "@envoy",
deps = [
"@envoy//source/common/common:utility_lib",
"@envoy//test/integration:http_protocol_integration_lib",
"//include/istio/utils:attribute_names_header",
"//src/envoy/http/authn:filter_lib",
"//src/envoy/http/jwt_auth:http_filter_factory",
"//src/envoy/http/jwt_auth:jwt_lib",
"//src/envoy/utils:filter_names_lib",
"//src/envoy/http/mixer:filter_lib",
"//src/envoy/utils:filter_names_lib",
"@envoy//source/common/common:utility_lib",
"@envoy//test/integration:http_protocol_integration_lib",
],
)
Loading

0 comments on commit 54d5807

Please sign in to comment.