Update latest Bazel version. (#133)
Also use subprocess.check_call instead of subprocess.call. The former
will exit as soon as the subcommand exits with non-zero status.
diff --git a/container/build.py b/container/build.py
index fd57ecc..6d3d276 100644
--- a/container/build.py
+++ b/container/build.py
@@ -13,11 +13,11 @@
# 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.
-
"""Builds a toolchain container, with Google Cloud Container Builder or locally.
To build with Google Cloud Container Builder:
-$ python build.py -p my-gcp-project -d {container_type} -c {container_name} -t latest -b my_bucket
+$ python build.py -p my-gcp-project -d {container_type} -c {container_name} -t
+latest -b my_bucket
will produce docker images in Google Container Registry:
gcr.io/my-gcp-project/{container_type}:latest
and the debian packages installed will be packed as a tarball and stored in
@@ -27,7 +27,8 @@
will produce docker locally as {container_type}:latest
usage:
- build.py -d {rbe-debian8,rbe-debian9,rbe-ubuntu16_04,ubuntu16_04-bazel-docker,ubuntu16_04-bazel}
+ build.py -d
+ {rbe-debian8,rbe-debian9,rbe-ubuntu16_04,ubuntu16_04-bazel-docker,ubuntu16_04-bazel}
[-p PROJECT] [-c CONTAINER] [-t TAG] [-a] [-b BUCKET] [-h]
[-l]
@@ -56,15 +57,12 @@
import subprocess
import sys
-LATEST_BAZEL_VERSION = "0.15.0"
+LATEST_BAZEL_VERSION = "0.15.2"
supported_types = [
- "rbe-debian8",
- "rbe-debian9",
- "rbe-ubuntu16_04",
- "ubuntu16_04-bazel",
- "ubuntu16_04-bazel-docker"
- ]
+ "rbe-debian8", "rbe-debian9", "rbe-ubuntu16_04", "ubuntu16_04-bazel",
+ "ubuntu16_04-bazel-docker"
+]
# Map to store all supported container type and
# the package of target to build it.
@@ -107,8 +105,8 @@
def main(type_, project, container, tag, async_, bucket, local):
- '''Runs the build. More info in module docstring at the top.
- '''
+ """Runs the build. More info in module docstring at the top.
+ """
project_root = subprocess.check_output(
shlex.split("git rev-parse --show-toplevel")).strip()
package = TYPE_PACKAGE_MAP[type_]
@@ -119,33 +117,40 @@
# mount the full root directory (to use bazel builder properly).
os.chdir(project_root)
# We need to run clean to make sure we don't mount local build outputs
- subprocess.call(["bazel", "clean"])
+ subprocess.check_call(["bazel", "clean"])
if local:
local_build(type_, package, target)
else:
- cloud_build(project_root, project, container, tag, async_, bucket, package, target, tarball)
+ cloud_build(project_root, project, container, tag, async_, bucket, package,
+ target, tarball)
+
def local_build(type_, package, target):
- '''Runs the build locally. More info in module docstring at the top.
- '''
+ """Runs the build locally. More info in module docstring at the top.
+ """
print("Building container locally.")
- subprocess.call(shlex.split("bazel run //{}:{}".format(package, target)))
+ subprocess.check_call(
+ shlex.split("bazel run //{}:{}".format(package, target)))
print("Testing container locally.")
- subprocess.call(
- "bazel test //{}:{}-test".format(package, target).split())
+ subprocess.check_call("bazel test //{}:{}-test".format(package,
+ target).split())
print("Tagging container.")
- subprocess.call(shlex.split("docker tag bazel/{}:{} {}:latest".format(
- package, target, type_)))
+ subprocess.check_call(
+ shlex.split("docker tag bazel/{}:{} {}:latest".format(
+ package, target, type_)))
print(("\n{TYPE}:lastest container is now available to use.\n"
- "To try it: docker run -it {TYPE}:latest \n").format(TYPE=type_))
+ "To try it: docker run -it {TYPE}:latest \n").format(TYPE=type_))
-def cloud_build(project_root, project, container, tag, async_, bucket, package, target, tarball):
- '''Runs the build in the cloud. More info in module docstring at the top.
- '''
+
+def cloud_build(project_root, project, container, tag, async_, bucket, package,
+ target, tarball):
+ """Runs the build in the cloud. More info in module docstring at the top.
+ """
print("Building container in Google Cloud Container Builder.")
# Setup GCP project id for the build
- subprocess.call(shlex.split("gcloud config set project {}".format(project)))
+ subprocess.check_call(
+ shlex.split("gcloud config set project {}".format(project)))
# Ensure all BUILD files under /third_party have the right permission.
# This is because in some systems the BUILD files under /third_party
# (after git clone) will be with permission 640 and the build will
@@ -158,27 +163,27 @@
config_file = "{}/container/cloudbuild.yaml".format(project_root)
extra_substitution = ",_BUCKET={},_TARBALL={}".format(bucket, tarball)
if not bucket:
- config_file = "{}/container/cloudbuild_no_bucket.yaml".format(
- project_root)
+ config_file = "{}/container/cloudbuild_no_bucket.yaml".format(project_root)
extra_substitution = ""
async_arg = ""
if async_:
async_arg = "--async"
- subprocess.call(shlex.split((
- "gcloud container builds submit . "
- "--config={CONFIG} "
- "--substitutions _PROJECT={PROJECT},_CONTAINER={CONTAINER},"
- "_TAG={TAG},_PACKAGE={PACKAGE},_TARGET={TARGET}{EXTRA_SUBSTITUTION} "
- "--machine-type=n1-highcpu-32 "
- "{ASYNC}").format(
- CONFIG=config_file,
- PROJECT=project,
- CONTAINER=container,
- TAG=tag,
- PACKAGE=package,
- TARGET=target,
- EXTRA_SUBSTITUTION=extra_substitution,
- ASYNC=async_arg)))
+ subprocess.check_call(
+ shlex.split(
+ ("gcloud container builds submit . "
+ "--config={CONFIG} "
+ "--substitutions _PROJECT={PROJECT},_CONTAINER={CONTAINER},"
+ "_TAG={TAG},_PACKAGE={PACKAGE},_TARGET={TARGET}{EXTRA_SUBSTITUTION} "
+ "--machine-type=n1-highcpu-32 "
+ "{ASYNC}").format(
+ CONFIG=config_file,
+ PROJECT=project,
+ CONTAINER=container,
+ TAG=tag,
+ PACKAGE=package,
+ TARGET=target,
+ EXTRA_SUBSTITUTION=extra_substitution,
+ ASYNC=async_arg)))
def parse_arguments():
diff --git a/container/ubuntu16_04/layers/bazel/version.bzl b/container/ubuntu16_04/layers/bazel/version.bzl
index 3de3830..b38ed44 100644
--- a/container/ubuntu16_04/layers/bazel/version.bzl
+++ b/container/ubuntu16_04/layers/bazel/version.bzl
@@ -1,4 +1,5 @@
BAZEL_VERSION_SHA256S = {
"0.14.1": "7b14e4fc76bf85c4abf805833e99f560f124a3b96d56e0712c693e94e19d1376",
"0.15.0": "7f6748b48a7ea6bdf00b0e1967909ce2181ebe6f377638aa454a7d09a0e3ea7b",
+ "0.15.2": "13eae0f09565cf17fc1c9ce1053b9eac14c11e726a2215a79ebaf5bdbf435241",
}