diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ac2e90b91d..ce892c54377 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -191,11 +191,6 @@ jobs: - name: Install requirements run: | pip install -r dev_tools/requirements/deps/protos.txt - sudo apt install curl gnupg - curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg - sudo mv bazel.gpg /etc/apt/trusted.gpg.d/ - echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list - sudo apt update && sudo apt install bazel - name: Build protos run: check/build-changed-protos coverage: @@ -335,4 +330,4 @@ jobs: - name: Install npm dependencies run: check/npm ci - name: Test - run: check/ts-coverage \ No newline at end of file + run: check/ts-coverage diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index dbc8e4fbc88..00000000000 --- a/WORKSPACE +++ /dev/null @@ -1,62 +0,0 @@ -# General bazel utility -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# ========================= -# Proto dependencies below. -# ========================= - -# Native proto_library is deprecated; this is a replacement. See -# https://docs.bazel.build/versions/master/be/protocol-buffer.html#proto_library -http_archive( - name = "rules_proto", - sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208", - strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz", - "https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz", - ], -) - -# Use this zlib rule that depends on github since it is more reliable than zlib.net. -http_archive( - name = "zlib", - build_file = "@com_google_protobuf//:third_party/zlib.BUILD", - sha256 = "629380c90a77b964d896ed37163f5c3a34f6e6d897311f1df2a7016355c45eff", - strip_prefix = "zlib-1.2.11", - urls = ["https://github.com/madler/zlib/archive/v1.2.11.tar.gz"], -) - -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") -rules_proto_dependencies() -rules_proto_toolchains() - -# In protobuf 3.8.0, this function is used only to load the zlib dependency. -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") -protobuf_deps() - -http_archive( - name = "bazel_skylib", - url = "https://github.com/bazelbuild/bazel-skylib/releases/download/0.9.0/bazel_skylib-0.9.0.tar.gz", - sha256 = "1dde365491125a3db70731e25658dfdd3bc5dbdfd11b840b3e987ecf043c7ca0", -) - -# Python compatibility. -http_archive( - name = "six_archive", - build_file = "@com_google_protobuf//:six.BUILD", - sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", - url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55", -) -bind( - name = "six", - actual = "@six_archive//:six", -) - -# proto_library, py_proto_library, and cc_proto_library rules implicitly -# depend on @com_google_protobuf for protoc and proto runtimes. -http_archive( - name = "com_google_protobuf", - sha256 = "1e622ce4b84b88b6d2cdf1db38d1a634fe2392d74f0b7b74ff98f3a51838ee53", - strip_prefix = "protobuf-3.8.0", - urls = ["https://github.com/google/protobuf/archive/v3.8.0.zip"], -) diff --git a/check/build-changed-protos b/check/build-changed-protos index 7b2b3657e4a..b48824abafa 100755 --- a/check/build-changed-protos +++ b/check/build-changed-protos @@ -71,30 +71,9 @@ if [[ ! -z "$changed" ]]; then done fi -# Check if any of the build files have changed. -build_changed=$(git diff --name-only ${rev} -- \ - | grep "google/api/.*BUILD$" \ - | sed -e "s/BUILD//") - -if [[ -z "$build_changed" ]]; then - echo -e "No BUILD files changed." -else - # Build all the targets for the changed BUILD rule. - echo -e "BUILD file changed in directories: '${build_changed[@]}'" - for build_prefix in $build_changed - do - (set -x; bazel build "${build_prefix}...:*") - done -fi - -# We potentially will attempt to build a second time, but this is not -# a problem as bazel returns immediately. +# We potentially will attempt to build a second time. for base in $changed do - (set -x; bazel build "${base}_proto"; \ - bazel build "${base}_py_proto"; \ - bazel build "${base}_cc_proto") - python -m grpc_tools.protoc -I=cirq-google --python_out=cirq-google --mypy_out=cirq-google ${base}.proto done @@ -109,4 +88,4 @@ if [[ ! -z "$untracked" ]]; then echo -e "\033[31m ${generated}\033[0m" done exit 1 -fi \ No newline at end of file +fi diff --git a/check/build-protos b/check/build-protos deleted file mode 100755 index 65ccc8a3467..00000000000 --- a/check/build-protos +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -################################################################################ -# Runs bazel build for proto files in cirq/google/api/* -# -# See build-changed-protos for a version of this that only builds changed -# protos. -# -# Usage: -# check/build-protos -################################################################################ - -# Get the working directory to the repo root. -cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd "$(git rev-parse --show-toplevel)" - -protos=$(find -type f -name "*.proto" -printf '%P\n' \ - | grep "google/api/.*\.proto$" \ - | sed -e "s/\.proto$//") -for base in $protos: -do - echo -e "Found proto: '${base}.proto'" -done - -for base in $protos -do - bazel build "${base}_proto" - bazel build "${base}_py_proto" - bazel build "${base}_cc_proto" -done diff --git a/cirq-google/cirq_google/api/v1/BUILD b/cirq-google/cirq_google/api/v1/BUILD deleted file mode 100644 index 5a1b72d9328..00000000000 --- a/cirq-google/cirq_google/api/v1/BUILD +++ /dev/null @@ -1,62 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") - -proto_library( - name = "operations_proto", - srcs = ["operations.proto"], -) - -py_proto_library( - name = "operations_py_proto", - srcs = ["operations.proto"], -) - -cc_proto_library( - name = "operations_cc_proto", - deps = [ - ":operations_proto", - ], -) - -proto_library( - name = "params_proto", - srcs = ["params.proto"], -) - -py_proto_library( - name = "params_py_proto", - srcs = ["params.proto"], -) - -cc_proto_library( - name = "params_cc_proto", - deps = [ - ":params_proto", - ], -) - -proto_library( - name = "program_proto", - srcs = ["program.proto"], - deps = [ - ":operations_proto", - ":params_proto", - ], -) - -py_proto_library( - name = "program_py_proto", - srcs = ["program.proto"], - deps = [ - ":operations_py_proto", - ":params_py_proto", - ], -) - -cc_proto_library( - name = "program_cc_proto", - deps = [ - ":program_proto", - ], -) diff --git a/cirq-google/cirq_google/api/v2/BUILD b/cirq-google/cirq_google/api/v2/BUILD deleted file mode 100644 index a99f5d2ca39..00000000000 --- a/cirq-google/cirq_google/api/v2/BUILD +++ /dev/null @@ -1,153 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") - -proto_library( - name = "batch_proto", - srcs = ["batch.proto"], - deps = [ - ":program_proto", - ":result_proto", - ":run_context_proto" - ], -) - -py_proto_library( - name = "batch_py_proto", - srcs = ["batch.proto"], - deps = [ - ":program_py_proto", - ":result_py_proto", - ":run_context_py_proto" - ], -) - -cc_proto_library( - name = "batch_cc_proto", - deps = [ - ":batch_proto" - ], -) - - -proto_library( - name = "calibration_proto", - srcs = ["calibration.proto"], - deps = [ - ":metrics_proto", - ":program_proto" - ], -) - -py_proto_library( - name = "calibration_py_proto", - srcs = ["calibration.proto"], - deps = [ - ":metrics_py_proto", - ":program_py_proto" - ], -) - -cc_proto_library( - name = "calibration_cc_proto", - deps = [ - ":calibration_proto" - ], -) - -proto_library( - name = "device_proto", - srcs = ["device.proto"], -) - -py_proto_library( - name = "device_py_proto", - srcs = ["device.proto"], -) - -cc_proto_library( - name = "device_cc_proto", - deps = [ - ":device_proto" - ], -) - -proto_library( - name = "metrics_proto", - srcs = ["metrics.proto"], -) - -py_proto_library( - name = "metrics_py_proto", - srcs = ["metrics.proto"], -) - -cc_proto_library( - name = "metrics_cc_proto", - deps = [ - ":metrics_proto" - ], -) - -proto_library( - name = "program_proto", - srcs = ["program.proto"], -) - -py_proto_library( - name = "program_py_proto", - srcs = ["program.proto"], -) - -cc_proto_library( - name = "program_cc_proto", - deps = [ - ":program_proto" - ], -) - -proto_library( - name = "result_proto", - srcs = ["result.proto"], - deps = [ - ":program_proto", - ], -) - -py_proto_library( - name = "result_py_proto", - srcs = ["result.proto"], - deps = [ - ":program_py_proto", - ], -) - -cc_proto_library( - name = "result_cc_proto", - deps = [ - ":result_proto", - ], -) - -proto_library( - name = "run_context_proto", - srcs = ["run_context.proto"], - deps = [ - ":program_proto", - ], -) - -py_proto_library( - name = "run_context_py_proto", - srcs = ["run_context.proto"], - deps = [ - ":program_py_proto", - ], -) - -cc_proto_library( - name = "run_context_cc_proto", - deps = [ - ":run_context_proto", - ], -) diff --git a/docs/dev/development.md b/docs/dev/development.md index 43e314146c9..11cc7e14d3c 100644 --- a/docs/dev/development.md +++ b/docs/dev/development.md @@ -151,10 +151,6 @@ Cirq's protobufs live at [cirq/api/google](https://github.com/quantumlib/Cirq/tr If any protos are updated, their dependents can be rebuilt by calling the script [dev_tools/build-protos.sh](https://github.com/quantumlib/Cirq/tree/master/dev_tools). This script uses grpcio-tools and protobuf version 3.8.0 to generate the python proto api. -Additionally, for workflows that use bazel (relevant for C/C++ code depending on Cirq), we have made available bazel rulesets for generating both python and C/C++ proto apis. -These rules live in the BUILD files [here](https://github.com/quantumlib/Cirq/tree/master/cirq/api/google/v1) and [here](https://github.com/quantumlib/Cirq/tree/master/cirq/api/google/v2). -Downstream projects should load Cirq as an [external dependency](https://docs.bazel.build/versions/master/external.html), allowing rules from those BUILD files to be used directly. - ## Continuous integration and local testing There are a few options for running continuous integration checks, varying from easy and fast to slow and reliable.