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

Move buildifier to buildkite. #680

Merged
merged 3 commits into from
Jan 31, 2019
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
1 change: 1 addition & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
buildifier: true
platforms:
ubuntu1404:
test_targets:
Expand Down
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ addons:
packages:
- bazel

install:
- go get -u github.com/bazelbuild/buildifier/buildifier

script:
# Check for issues with the format of our bazel config files.
- buildifier -mode=check $(find . -name BUILD -type f)
- buildifier -mode=check $(find . -name WORKSPACE -type f)
- buildifier -mode=check $(find . -name '*.bzl' -type f)

# Test things by executing the various build configurations under testing/
- ./testing/e2e.sh
4 changes: 2 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("//contrib:test.bzl", "container_test")

# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,8 +19,6 @@ licenses(["notice"]) # Apache 2.0

exports_files(["LICENSE"])

load("//contrib:test.bzl", "container_test")

config_setting(
name = "fastbuild",
values = {"compilation_mode": "fastbuild"},
Expand Down
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ _nodejs_image_repos()

http_archive(
name = "bazel_toolchains",
sha256 = "07a81ee03f5feae354c9f98c884e8e886914856fb2b6a63cba4619ef10aaaf0b",
strip_prefix = "bazel-toolchains-31b5dc8c4e9c7fd3f5f4d04c6714f2ce87b126c1",
sha256 = "767325343fb2e3a8dd77bccff30cfa66056e88049d339a977f77a85ecc3fc580",
strip_prefix = "bazel-toolchains-ad7f0157e13d5d3a4b893652a375b03ee9e032b4",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/31b5dc8c4e9c7fd3f5f4d04c6714f2ce87b126c1.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/31b5dc8c4e9c7fd3f5f4d04c6714f2ce87b126c1.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/ad7f0157e13d5d3a4b893652a375b03ee9e032b4.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/ad7f0157e13d5d3a4b893652a375b03ee9e032b4.tar.gz",
],
)
12 changes: 6 additions & 6 deletions cc/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
The signature of this rule is compatible with cc_binary.
"""

load(
"//container:container.bzl",
"container_pull",
)
load(
"//lang:image.bzl",
"app_layer",
Expand All @@ -24,10 +28,6 @@ load(
"//repositories:repositories.bzl",
_repositories = "repositories",
)
load(
"//container:container.bzl",
"container_pull",
)

# Load the resolved digests.
load(":cc.bzl", "DIGESTS")
Expand All @@ -54,10 +54,10 @@ def repositories():
)

DEFAULT_BASE = select({
"@io_bazel_rules_docker//:fastbuild": "@cc_image_base//image",
"//conditions:default": "@cc_image_base//image",
"@io_bazel_rules_docker//:debug": "@cc_debug_image_base//image",
"@io_bazel_rules_docker//:fastbuild": "@cc_image_base//image",
"@io_bazel_rules_docker//:optimized": "@cc_image_base//image",
"//conditions:default": "@cc_image_base//image",
})

def cc_image(name, base = None, deps = [], layers = [], binary = None, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions container/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,8 +17,6 @@ package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # Apache 2.0

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files(["push-tag.sh.tpl"])

filegroup(
Expand Down
12 changes: 6 additions & 6 deletions container/bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
"""Rule for bundling Container images into a tarball."""

load("@bazel_skylib//lib:dicts.bzl", "dicts")
load(
"//skylib:label.bzl",
_string_to_label = "string_to_label",
)
load(
"//container:layer_tools.bzl",
_assemble_image = "assemble",
Expand All @@ -26,6 +22,10 @@ load(
_layer_tools = "tools",
)
load("//container:providers.bzl", "BundleInfo")
load(
"//skylib:label.bzl",
_string_to_label = "string_to_label",
)

def _container_bundle_impl(ctx):
"""Implementation for the container_bundle rule."""
Expand Down Expand Up @@ -89,10 +89,10 @@ def _container_bundle_impl(ctx):

container_bundle_ = rule(
attrs = dicts.add({
"images": attr.string_dict(),
"image_target_strings": attr.string_list(),
# Implicit dependencies.
"image_targets": attr.label_list(allow_files = True),
"image_target_strings": attr.string_list(),
"images": attr.string_dict(),
"stamp": attr.bool(
default = False,
mandatory = False,
Expand Down
7 changes: 1 addition & 6 deletions container/container.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@
load("//container:bundle.bzl", _container_bundle = "container_bundle")
load("//container:flatten.bzl", _container_flatten = "container_flatten")
load("//container:image.bzl", _container_image = "container_image", _image = "image")
load("//container:layer.bzl", _container_layer = "container_layer")
load("//container:import.bzl", _container_import = "container_import")
load("//container:layer.bzl", _container_layer = "container_layer")
load("//container:load.bzl", _container_load = "container_load")
load("//container:pull.bzl", _container_pull = "container_pull")
load("//container:push.bzl", _container_push = "container_push")
load(
"@bazel_tools//tools/build_defs/repo:http.bzl",
"http_archive",
"http_file",
)

# Explicitly re-export the functions
container_bundle = _container_bundle
Expand Down
104 changes: 49 additions & 55 deletions container/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,14 @@ expectation in such cases is that users will write something like:
"""

load("@bazel_skylib//lib:dicts.bzl", "dicts")
load(
"//skylib:filetype.bzl",
container_filetype = "container",
deb_filetype = "deb",
tar_filetype = "tar",
)
load(
"@bazel_tools//tools/build_defs/hash:hash.bzl",
_hash_tools = "tools",
_sha256 = "sha256",
)
load(
"//skylib:zip.bzl",
_gzip = "gzip",
_zip_tools = "tools",
)
load(
"//skylib:label.bzl",
_string_to_label = "string_to_label",
"//container:layer.bzl",
_layer = "layer",
)
load(
"//container:layer_tools.bzl",
Expand All @@ -69,20 +58,25 @@ load(
)
load(
"//container:providers.bzl",
"ImageInfo",
"LayerInfo",
)
load(
"//container:layer.bzl",
_layer = "layer",
"//skylib:filetype.bzl",
container_filetype = "container",
)
load(
"//skylib:label.bzl",
_string_to_label = "string_to_label",
)
load(
"//skylib:path.bzl",
"dirname",
"strip_prefix",
_canonicalize_path = "canonicalize",
_join_path = "join",
)
load("//container:providers.bzl", "ImageInfo")
load(
"//skylib:zip.bzl",
_zip_tools = "tools",
)

def _get_base_config(ctx, name, base):
if ctx.files.base or base:
Expand Down Expand Up @@ -386,33 +380,33 @@ def _impl(
# These are the constituent parts of the Container image, which each
# rule in the chain must preserve.
container_parts = {
# A list of paths to the layer digests.
"blobsum": shas,
# The path to the v2.2 configuration file.
"config": config_file,
"config_digest": config_digest,

# The path to the v2.2 manifest file.
"manifest": manifest_file,
"manifest_digest": manifest_digest,

# A list of paths to the layer .tar.gz files
"zipped_layer": zipped_layers,
# A list of paths to the layer digests.
"blobsum": shas,
# A list of paths to the layer diff_ids.
"diff_id": diff_ids,

# The File containing digest of the image.
"digest": output_digest,

# A list of paths to the layer .tar files
"unzipped_layer": unzipped_layers,
# A list of paths to the layer diff_ids.
"diff_id": diff_ids,

# At the root of the chain, we support deriving from a tarball
# base image.
"legacy": parent_parts.get("legacy"),

# The path to the v2.2 manifest file.
"manifest": manifest_file,
"manifest_digest": manifest_digest,

# Keep track of all files/emptyfiles/symlinks that we have already added to the image layers.
"transitive_files": transitive_files,

# A list of paths to the layer .tar files
"unzipped_layer": unzipped_layers,

# A list of paths to the layer .tar.gz files
"zipped_layer": zipped_layers,
}

# We support incrementally loading or assembling this single image
Expand Down Expand Up @@ -454,46 +448,46 @@ def _impl(

_attrs = dicts.add(_layer.attrs, {
"base": attr.label(allow_files = container_filetype),
"legacy_repository_naming": attr.bool(default = False),
# TODO(mattmoor): Default this to False.
"legacy_run_behavior": attr.bool(default = True),
"cmd": attr.string_list(),
"create_image_config": attr.label(
default = Label("//container:create_image_config"),
cfg = "host",
executable = True,
allow_files = True,
),
"creation_time": attr.string(),
# Run the container using host networking, so that the service is
# available to the developer without having to poke around with
# docker inspect.
"docker_run_flags": attr.string(
default = "-i --rm --network=host",
),
"user": attr.string(),
"labels": attr.string_dict(),
"cmd": attr.string_list(),
"creation_time": attr.string(),
"entrypoint": attr.string_list(),
"ports": attr.string_list(), # Skylark doesn't support int_list...
"volumes": attr.string_list(),
"workdir": attr.string(),
"layers": attr.label_list(providers = [LayerInfo]),
"repository": attr.string(default = "bazel"),
"stamp": attr.bool(default = False),
"launcher": attr.label(allow_single_file = True),
"launcher_args": attr.string_list(default = []),
"label_file_strings": attr.string_list(),
# Implicit/Undocumented dependencies.
"label_files": attr.label_list(
allow_files = True,
),
"label_file_strings": attr.string_list(),
"create_image_config": attr.label(
default = Label("//container:create_image_config"),
cfg = "host",
executable = True,
allow_files = True,
),
"labels": attr.string_dict(),
"launcher": attr.label(allow_single_file = True),
"launcher_args": attr.string_list(default = []),
"layers": attr.label_list(providers = [LayerInfo]),
"legacy_repository_naming": attr.bool(default = False),
# TODO(mattmoor): Default this to False.
"legacy_run_behavior": attr.bool(default = True),
# null_cmd and null_entrypoint are hidden attributes from users.
# They are needed because specifying cmd or entrypoint as {None, [] or ""}
# and not specifying them at all in the container_image rule would both make
# ctx.attr.cmd or ctx.attr.entrypoint to be [].
# We need these flags to distinguish them.
"null_cmd": attr.bool(default = False),
"null_entrypoint": attr.bool(default = False),
"ports": attr.string_list(), # Skylark doesn't support int_list...
"repository": attr.string(default = "bazel"),
"stamp": attr.bool(default = False),
"user": attr.string(),
"volumes": attr.string_list(),
"workdir": attr.string(),
"_digester": attr.label(
default = "@containerregistry//:digester",
cfg = "host",
Expand Down
Loading