Skip to content

Commit c313bd7

Browse files
Nicolas Lopezk8s-ci-robot
Nicolas Lopez
authored andcommitted
cleanups split off from large PR (bazelbuild#538)
- add .bazelingorefile to ignore example repo directories - move output_bases to use bazel-* gitignored dir - add missing license headers and doc fixes
1 parent 3a82cfe commit c313bd7

File tree

8 files changed

+67
-30
lines changed

8 files changed

+67
-30
lines changed

.bazelignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Disable targets that are part of an embedded bazel project as buildkite
2+
# only recognizes a single top level WORKSPACE file.
3+
tests/rbe_repo/examples

WORKSPACE

+6-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
workspace(name = "bazel_toolchains")
1515

16-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
16+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
1717
load(
1818
"//repositories:repositories.bzl",
1919
bazel_toolchains_repositories = "repositories",
@@ -359,7 +359,7 @@ rbe_autoconfig(
359359
name = "rbe_autoconf_output_base",
360360
bazel_version = _ubuntu1604_bazel,
361361
create_testdata = True,
362-
output_base = "tests/config/rbe_autoconf_output_base",
362+
output_base = "bazel-rbe-tests/config/rbe_autoconf_output_base",
363363
use_checked_in_confs = "False",
364364
)
365365

@@ -368,7 +368,7 @@ rbe_autoconfig(
368368
bazel_version = _ubuntu1604_bazel,
369369
create_java_configs = False,
370370
create_testdata = True,
371-
output_base = "tests/config/rbe_autoconf_output_base_no_java",
371+
output_base = "bazel-rbe-tests/config/rbe_autoconf_output_base_no_java",
372372
use_checked_in_confs = "False",
373373
)
374374

@@ -377,7 +377,7 @@ rbe_autoconfig(
377377
bazel_version = _ubuntu1604_bazel,
378378
create_cc_configs = False,
379379
create_testdata = True,
380-
output_base = "tests/config/rbe_autoconf_output_base_no_cc",
380+
output_base = "bazel-rbe-tests/config/rbe_autoconf_output_base_no_cc",
381381
use_checked_in_confs = "False",
382382
)
383383

@@ -388,15 +388,15 @@ rbe_autoconfig(
388388
"local_config_sh",
389389
],
390390
create_testdata = True,
391-
output_base = "tests/config/rbe_autoconf_config_repos_output_base",
391+
output_base = "bazel-rbe-tests/config/rbe_autoconf_config_repos_output_base",
392392
)
393393

394394
rbe_autoconfig(
395395
name = "rbe_autoconf_output_base_config_dir",
396396
bazel_version = _ubuntu1604_bazel,
397397
config_dir = "test_config_dir",
398398
create_testdata = True,
399-
output_base = "tests/config/rbe_autoconf_output_base",
399+
output_base = "bazel-rbe-tests/config/rbe_autoconf_output_base",
400400
use_checked_in_confs = "False",
401401
)
402402

@@ -420,11 +420,3 @@ load("//rules/rbe_repo:util.bzl", "rbe_autoconfig_root")
420420
# Needed for testing purposes. Creates a file that exposes
421421
# the value of RBE_AUTOCONF_ROOT
422422
rbe_autoconfig_root(name = "rbe_autoconfig_root")
423-
424-
# Experiment with tags to see if renovate updates them correctly.
425-
# TODO (suvanjan): Remove this after experimentation is complete.
426-
http_archive(
427-
name = "renovate_src",
428-
sha256 = "3e9c7dcc3ab602dde9656d7ce1c8969f56dd1480b881f272d5d6ad8a713bddcc",
429-
url = "https://github.com/smukherj1/renovate-src/archive/0.24.1-1.tar.gz",
430-
)

rules/BUILD

+10
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,13 @@ bzl_library(
7272
"@io_bazel_rules_docker//container",
7373
],
7474
)
75+
76+
bzl_library(
77+
name = "rbe_repo",
78+
srcs = [
79+
"rbe_repo.bzl",
80+
],
81+
deps = [
82+
"@bazel_toolchains//rules/rbe_repo",
83+
],
84+
)

rules/container/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1616

1717
licenses(["notice"]) # Apache 2.0
1818

19+
package(default_visibility = ["//visibility:public"])
20+
1921
bzl_library(
2022
name = "debian_pkg_tar",
2123
srcs = [

rules/rbe_repo/BUILD

+19
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,22 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
licenses(["notice"]) # Apache 2.0
16+
17+
package(default_visibility = ["//visibility:public"])
18+
19+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
20+
21+
bzl_library(
22+
name = "rbe_repo",
23+
srcs = [
24+
"build_gen.bzl",
25+
"checked_in.bzl",
26+
"container.bzl",
27+
"outputs.bzl",
28+
"toolchain_config_suite_spec.bzl",
29+
"util.bzl",
30+
"version_check.bzl",
31+
],
32+
)

rules/rbe_repo/container.bzl

+9-11
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ def _create_docker_cmd(
116116
]
117117
ctx.file("container/run_in_container.sh", "\n".join(docker_cmd), True)
118118

119-
# Verifies if we need to pull a container to resolve the configs.
120119
def pull_container_needed(ctx):
121120
"""Returns whether or not pulling a container is needed.
122121
@@ -155,8 +154,8 @@ def pull_image(ctx, docker_tool_path, image_name):
155154
def get_java_home(ctx, docker_tool_path, image_name):
156155
"""Gets the value of java_home.
157156
158-
Gets the value of java_home either from attr or
159-
by running docker run image_name printenv JAVA_HOME.
157+
Gets the value of java_home either from attr or
158+
by running docker run image_name printenv JAVA_HOME.
160159
161160
Args:
162161
ctx: the Bazel context object.
@@ -191,8 +190,6 @@ def get_java_home(ctx, docker_tool_path, image_name):
191190
"create_java_configs is set to True")
192191
return java_home
193192

194-
# Runs the container (creates command to run inside container) and extracts the
195-
# toolchain configs.
196193
def run_and_extract(
197194
ctx,
198195
bazel_version,
@@ -204,8 +201,8 @@ def run_and_extract(
204201
use_default_project):
205202
"""Runs the container and extracts the toolchain configs.
206203
207-
Runs the container (creates command to run inside container) and extracts the
208-
toolchain configs.
204+
Runs the container (creates command to run inside container) and extracts the
205+
toolchain configs.
209206
210207
Args:
211208
ctx: the Bazel context object.
@@ -217,7 +214,8 @@ def run_and_extract(
217214
local_config_cc
218215
docker_tool_path: path to the docker binary.
219216
image_name: name of the image to pull.
220-
project_root: the absolute path to the root of the project
217+
project_root: the absolute path to the root of the project that will
218+
be mounted/copied to the container
221219
use_default_project: whether or not to use the default project to generate configs
222220
"""
223221
outputs_tar = ctx.attr.name + "_out.tar"
@@ -244,10 +242,10 @@ def run_and_extract(
244242
clean_data_volume_cmd = ""
245243
if ctx.attr.copy_resources:
246244
copy_data_cmd.append("data_volume=$(docker create -v " + _ROOT_DIR + " " + image_name + ")")
247-
copy_data_cmd.append("docker cp $(realpath " + project_root + ") $data_volume:" + _REPO_DIR)
248-
copy_data_cmd.append("docker cp " + str(ctx.path("container")) + " $data_volume:" + _ROOT_DIR + "/container")
245+
copy_data_cmd.append(docker_tool_path + " cp $(realpath " + project_root + ") $data_volume:" + _REPO_DIR)
246+
copy_data_cmd.append(docker_tool_path + " cp " + str(ctx.path("container")) + " $data_volume:" + _ROOT_DIR + "/container")
249247
docker_run_flags += ["--volumes-from", "$data_volume"]
250-
clean_data_volume_cmd = "docker rm $data_volume"
248+
clean_data_volume_cmd = docker_tool_path + " rm $data_volume"
251249
else:
252250
mount_read_only_flag = ":ro"
253251
if use_default_project:

rules/rbe_repo/version_check.bzl

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright 2017 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
114
""" Helpers to parse and check version of bazel."""
215

316
def extract_version_number(bazel_version_fallback):

tests/rbe_repo/BUILD

+5-5
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ sh_test(
445445
srcs = [":rbe_autoconf_output_base_checks.sh"],
446446
args = [
447447
"$(location @rbe_autoconfig_root//:AUTOCONF_ROOT)",
448-
"tests/config/rbe_autoconf_output_base",
448+
"bazel-rbe-tests/config/rbe_autoconf_output_base",
449449
_ubuntu1604_bazel,
450450
"assert_output_base_cc_confs",
451451
"assert_output_base_java_confs",
@@ -463,7 +463,7 @@ sh_test(
463463
srcs = [":rbe_autoconf_output_base_checks.sh"],
464464
args = [
465465
"$(location @rbe_autoconfig_root//:AUTOCONF_ROOT)",
466-
"tests/config/rbe_autoconf_output_base_no_java",
466+
"bazel-rbe-tests/config/rbe_autoconf_output_base_no_java",
467467
_ubuntu1604_bazel,
468468
"assert_output_base_cc_confs",
469469
"assert_output_base_no_java_confs",
@@ -481,7 +481,7 @@ sh_test(
481481
srcs = [":rbe_autoconf_output_base_checks.sh"],
482482
args = [
483483
"$(location @rbe_autoconfig_root//:AUTOCONF_ROOT)",
484-
"tests/config/rbe_autoconf_output_base_no_cc",
484+
"bazel-rbe-tests/config/rbe_autoconf_output_base_no_cc",
485485
_ubuntu1604_bazel,
486486
"assert_output_base_no_cc_confs",
487487
"assert_output_base_java_confs",
@@ -499,7 +499,7 @@ sh_test(
499499
srcs = [":rbe_autoconf_output_base_checks.sh"],
500500
args = [
501501
"$(location @rbe_autoconfig_root//:AUTOCONF_ROOT)",
502-
"tests/config/rbe_autoconf_config_repos_output_base",
502+
"bazel-rbe-tests/config/rbe_autoconf_config_repos_output_base",
503503
_ubuntu1604_bazel,
504504
"assert_output_base_cc_confs",
505505
"assert_output_base_java_confs",
@@ -526,7 +526,7 @@ sh_test(
526526
srcs = [":rbe_autoconf_output_base_config_dir_checks.sh"],
527527
args = [
528528
"$(location @rbe_autoconfig_root//:AUTOCONF_ROOT)",
529-
"tests/config/rbe_autoconf_output_base",
529+
"bazel-rbe-tests/config/rbe_autoconf_output_base",
530530
"test_config_dir",
531531
_ubuntu1604_bazel,
532532
"assert_output_base_cc_confs",

0 commit comments

Comments
 (0)