Merge pull request #84378 from serathius/static-analysis-bazel-25
Handle bazel >= 0.25 in stable metric static analysis
This commit is contained in:
		| @@ -19,6 +19,16 @@ set -o nounset | |||||||
| set -o pipefail | set -o pipefail | ||||||
|  |  | ||||||
| KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. | KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. | ||||||
|  | BAZEL_OUT_DIR="$KUBE_ROOT/bazel-bin" | ||||||
|  | BAZEL_GEN_DIR="$KUBE_ROOT/bazel-genfiles" | ||||||
|  | METRICS_LIST_PATH="test/instrumentation/stable-metrics-list.yaml" | ||||||
|  |  | ||||||
| bazel build //test/instrumentation:list_stable_metrics | bazel build //test/instrumentation:list_stable_metrics | ||||||
| cp "$KUBE_ROOT/bazel-genfiles/test/instrumentation/stable-metrics-list.yaml" "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml" | if [ -d "$BAZEL_OUT_DIR" ]; then | ||||||
|  |   cp "$BAZEL_OUT_DIR/$METRICS_LIST_PATH" "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml" | ||||||
|  | else | ||||||
|  |   # Handle bazel < 0.25 | ||||||
|  |   # https://github.com/bazelbuild/bazel/issues/6761 | ||||||
|  |   echo "$BAZEL_OUT_DIR not found trying $BAZEL_GEN_DIR" | ||||||
|  |   cp "$BAZEL_GEN_DIR/$METRICS_LIST_PATH" "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml" | ||||||
|  | fi | ||||||
|   | |||||||
| @@ -18,13 +18,23 @@ set -o errexit | |||||||
| set -o pipefail | set -o pipefail | ||||||
|  |  | ||||||
| KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. | KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../.. | ||||||
|  | BAZEL_OUT_DIR="$KUBE_ROOT/bazel-bin" | ||||||
|  | BAZEL_GEN_DIR="$KUBE_ROOT/bazel-genfiles" | ||||||
|  | METRICS_LIST_PATH="test/instrumentation/stable-metrics-list.yaml" | ||||||
|  |  | ||||||
| # detect if run from bazel | # detect if run from bazel | ||||||
| if [ -z "${TEST_BINARY}" ]; then | if [ -z "${TEST_BINARY}" ]; then | ||||||
|   bazel build //test/instrumentation:list_stable_metrics |   bazel build //test/instrumentation:list_stable_metrics | ||||||
|   OUTPUT_FILE="$KUBE_ROOT/bazel-genfiles/test/instrumentation/stable-metrics-list.yaml" |  | ||||||
|  |   if [ -d "$BAZEL_OUT_DIR" ]; then | ||||||
|  |     OUTPUT_FILE="$BAZEL_OUT_DIR/$METRICS_LIST_PATH" | ||||||
|  |   else | ||||||
|  |     # Handle bazel < 0.25 | ||||||
|  |     # https://github.com/bazelbuild/bazel/issues/6761 | ||||||
|  |     OUTPUT_FILE="$BAZEL_GEN_DIR/$METRICS_LIST_PATH" | ||||||
|  |   fi | ||||||
| else | else | ||||||
|   OUTPUT_FILE="$KUBE_ROOT/test/instrumentation/stable-metrics-list.yaml" |   OUTPUT_FILE="$KUBE_ROOT/$METRICS_LIST_PATH" | ||||||
| fi | fi | ||||||
|  |  | ||||||
| if diff -u "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml" "$OUTPUT_FILE"; then | if diff -u "$KUBE_ROOT/test/instrumentation/testdata/stable-metrics-list.yaml" "$OUTPUT_FILE"; then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot