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

start to seperate lint and unit test #7041

Merged
merged 2 commits into from
Feb 28, 2018
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 .bazelrc
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions hack/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ py_test(
name = "verify_boilerplate",
srcs = ["verify_boilerplate.py"],
data = ["//:all-srcs"],
tags = ["lint"],
)

sh_test(
Expand All @@ -22,6 +23,7 @@ sh_test(
":pylint_bin",
"//:all-srcs",
],
tags = ["lint"],
)

sh_test(
Expand All @@ -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",
Expand All @@ -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",
Expand Down
31 changes: 31 additions & 0 deletions hack/build-then-unit.sh
Original file line number Diff line number Diff line change
@@ -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
44 changes: 38 additions & 6 deletions prow/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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+|$)"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions testgrid/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -5079,6 +5083,11 @@ dashboards:
base_options: 'width=10'
alerts_options:
alert_mail_to_addresses: '[email protected]'
- name: lint
test_group_name: pull-test-infra-lint
base_options: 'width=10'
alerts_options:
alert_mail_to_addresses: '[email protected]'
- name: bazel-canary
test_group_name: pull-test-infra-bazel-canary
base_options: 'width=10'
Expand Down