From 579aca37538af8e3f610e2729860ea427d7be721 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 27 Feb 2018 14:51:12 -0800 Subject: [PATCH 1/2] tag lints and create test configs for lint/unit bazel tests --- .bazelrc | 8 ++++++++ hack/BUILD.bazel | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/.bazelrc b/.bazelrc index 3ab4b3d2004f..3ca26fae5621 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1,11 @@ build --workspace_status_command=./print-workspace-status.sh run --workspace_status_command=./print-workspace-status.sh test --features=race --test_output=errors + +# you can run only lint tests with: +# bazel test //... --config=lint +test:lint --test_tag_filters=lint + +# you can run non-lint tests with: +# bazel test //... --config=unit +test:unit --test_tag_filters=-lint diff --git a/hack/BUILD.bazel b/hack/BUILD.bazel index 1e55319d7c2c..81fd023d01ff 100644 --- a/hack/BUILD.bazel +++ b/hack/BUILD.bazel @@ -13,6 +13,7 @@ py_test( name = "verify_boilerplate", srcs = ["verify_boilerplate.py"], data = ["//:all-srcs"], + tags = ["lint"], ) sh_test( @@ -22,6 +23,7 @@ sh_test( ":pylint_bin", "//:all-srcs", ], + tags = ["lint"], ) sh_test( @@ -32,10 +34,12 @@ sh_test( "//:all-srcs", "//vendor/github.com/client9/misspell/cmd/misspell", ], + tags = ["lint"], ) test_suite( name = "verify-all", + tags = ["lint"], tests = [ "verify-pylint", "verify_boilerplate", @@ -45,6 +49,7 @@ test_suite( py_binary( name = "pylint_bin", srcs = ["pylint_bin.py"], + tags = ["lint"], # NOTE: this should only contain direct third party imports and pylint deps = [ "@influxdb", From 3881ce7fd718f171987da809003ef9aeb95e27b4 Mon Sep 17 00:00:00 2001 From: Benjamin Elder Date: Tue, 27 Feb 2018 15:14:06 -0800 Subject: [PATCH 2/2] switch test-infra bazel canary to config=unit, create lint job --- hack/build-then-unit.sh | 31 +++++++++++++++++++++++++++++ prow/config.yaml | 44 +++++++++++++++++++++++++++++++++++------ testgrid/config.yaml | 9 +++++++++ 3 files changed, 78 insertions(+), 6 deletions(-) create mode 100755 hack/build-then-unit.sh diff --git a/hack/build-then-unit.sh b/hack/build-then-unit.sh new file mode 100755 index 000000000000..29accbfe7fc5 --- /dev/null +++ b/hack/build-then-unit.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env 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. + +# used in presubmits / CI testing +# bazel build then unit test, exiting non-zero if either failed + +local res=0 + +bazel build //... +if [[ $? -ne 0 ]]; then + res=1 +fi + +bazel test //... --config=unit +if [[ $? -ne 0 ]]; then + res=1 +fi + +exit $res diff --git a/prow/config.yaml b/prow/config.yaml index 4427e673f3ed..02a7eb340ae6 100644 --- a/prow/config.yaml +++ b/prow/config.yaml @@ -4800,8 +4800,6 @@ presubmits: - name: pull-test-infra-bazel-canary agent: kubernetes context: pull-test-infra-bazel-canary - branches: - - master always_run: false rerun_command: "/test pull-test-infra-bazel-canary" trigger: "(?m)^/test pull-test-infra-bazel-canary,?(\\s+|$)" @@ -4818,11 +4816,9 @@ presubmits: - "--repo=k8s.io/$(REPO_NAME)=$(PULL_REFS)" - "--service-account=/etc/service-account/service-account.json" - "--upload=gs://kubernetes-jenkins/pr-logs" + - "--scenario=kubernetes_execute_bazel" - "--" # end bootstrap args, scenario args below - - "--build=//..." - - "--install=gubernator/test_requirements.txt" - - "--test=//..." - - "--test-args=--test_output=errors" + - "hack/build-then-unit.sh" env: - name: BAZEL_REMOTE_CACHE_ENABLED value: "true" @@ -4863,6 +4859,42 @@ presubmits: hostPath: path: /mnt/disks/ssd0 + - name: pull-test-infra-lint + agent: kubernetes + context: pull-test-infra-lint + # TODO(bentheelder): set always_run once we've switched over to use --config=unit for the bazel job + always_run: false + rerun_command: "/test pull-test-infra-lint" + trigger: "(?m)^/test pull-test-infra-lint,?(\\s+|$)" + labels: + preset-service-account: true + preset-bazel-scratch-dir: true + spec: + containers: + - image: gcr.io/k8s-testimages/kubekins-e2e:latest-experimental + imagePullPolicy: Always + args: + - "--clean" + - "--job=$(JOB_NAME)" + - "--repo=k8s.io/$(REPO_NAME)=$(PULL_REFS)" + - "--service-account=/etc/service-account/service-account.json" + - "--upload=gs://kubernetes-jenkins/pr-logs" + - "--scenario=kubernetes_bazel" + - "--" # end bootstrap args, scenario args below + - "--install=gubernator/test_requirements.txt" + - "--test=//..." + - "--test-args=--config=lint" + env: + - name: BAZEL_REMOTE_CACHE_ENABLED + value: "true" + # Bazel needs privileged mode in order to sandbox builds. + securityContext: + privileged: true + volumeMounts: + resources: + requests: + memory: "2Gi" + - name: pull-test-infra-verify-bazel agent: kubernetes context: pull-test-infra-verify-bazel diff --git a/testgrid/config.yaml b/testgrid/config.yaml index 2a08d6a5308b..e73cc8a58674 100644 --- a/testgrid/config.yaml +++ b/testgrid/config.yaml @@ -1856,6 +1856,10 @@ test_groups: gcs_prefix: kubernetes-jenkins/pr-logs/directory/pull-test-infra-bazel-canary days_of_results: 1 num_columns_recent: 20 +- name: pull-test-infra-lint + gcs_prefix: kubernetes-jenkins/pr-logs/directory/pull-test-infra-lint + days_of_results: 1 + num_columns_recent: 20 - name: pull-test-infra-gubernator gcs_prefix: kubernetes-jenkins/pr-logs/directory/pull-test-infra-gubernator days_of_results: 1 @@ -5079,6 +5083,11 @@ dashboards: base_options: 'width=10' alerts_options: alert_mail_to_addresses: 'bentheelder+alerts@google.com' + - name: lint + test_group_name: pull-test-infra-lint + base_options: 'width=10' + alerts_options: + alert_mail_to_addresses: 'bentheelder+alerts@google.com' - name: bazel-canary test_group_name: pull-test-infra-bazel-canary base_options: 'width=10'