diff --git a/.bazeliskrc b/.bazeliskrc index bd4a535..e920830 100644 --- a/.bazeliskrc +++ b/.bazeliskrc @@ -1 +1 @@ -USE_BAZEL_VERSION=5.4.1 +USE_BAZEL_VERSION=7.7.0 diff --git a/.bazelrc b/.bazelrc index 7a9655a..7cedb34 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,8 +1,16 @@ -# Use a remote build cache that's world-readable. Don't write unless told otherwise. +# Disable Bazel modules (for now). +common --enable_bzlmod=false + +build --cxxopt='-std=c++17' +build --host_cxxopt='-std=c++17' +# Use a remote build cache that's world-readable. Don't write unless told otherwise. build --remote_cache=https://storage.googleapis.com/reboot-dev-bazel-remote-cache-reboot-us build --remote_upload_local_results=false # Print full test logs for failed tests. - test --test_output=errors + +# To debug errors using the remote cache we need the `--verbose_failures` flag to +# get any useful information whatsoever. +build --verbose_failures diff --git a/.github/workflows/check_code_style.yml b/.github/workflows/check_code_style.yml index 3b3080e..84baa4e 100644 --- a/.github/workflows/check_code_style.yml +++ b/.github/workflows/check_code_style.yml @@ -18,7 +18,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["ubuntu-20.04"] + os: ["ubuntu-latest"] steps: # We should checkout the repo with submodules diff --git a/.github/workflows/pre-merge-checks.yml b/.github/workflows/pre-merge-checks.yml index 5b53543..13cf237 100644 --- a/.github/workflows/pre-merge-checks.yml +++ b/.github/workflows/pre-merge-checks.yml @@ -10,36 +10,13 @@ on: jobs: run-tests: name: Run pre-merge checks - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: GOOGLE_APPLICATION_CREDENTIALS: service_account_credentials.json steps: - - name: Checkout reboot-dev/pyprotoc-plugin - uses: actions/checkout@v2 + - uses: actions/checkout@v2 with: - # We don't need special credentials since this is a public repo - # that only depends on other public repos. submodules: recursive - - name: Install Python 3.10 and set it as the default - # To set Python 3.10 as the default we use `update-alternatives`: - # https://linux.die.net/man/8/update-alternatives - # We must set `python3` in addition to `python` because Bazel knows and cares - # about whether it's using python2 or python3, and will enforce its desire by - # explicitly running the `python2` or `python3` command. - run: | - sudo apt-get update \ - && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \ - curl gpg gpg-agent software-properties-common - sudo add-apt-repository ppa:deadsnakes/ppa \ - && sudo apt-get update \ - && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \ - python3.10 \ - python3.10-dev \ - python3.10-venv - sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 - sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1 - python --version - python3 --version - name: Set up read+write remote cache credentials (when on main) # With the exception of GITHUB_TOKEN, secrets are not passed to the runner # when a workflow is triggered from a forked repository. We can therefore diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index d73f3a8..3790e29 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -2,7 +2,7 @@ workspace(name = "com_github_reboot_dev_pyprotoc_plugin") load("//bazel:repos.bzl", "repos") -repos(external = False) +repos() load("//bazel:py_toolchains.bzl", "py_toolchains") diff --git a/bazel/deps.bzl b/bazel/deps.bzl index 510ca54..0cbe689 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -3,7 +3,7 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@pyprotoc_plugin_pypi//:requirements.bzl", pypi_deps = "install_deps") -def deps(repo_mapping = {}): +def deps(): protobuf_deps() - pypi_deps(repo_mapping = repo_mapping) + pypi_deps() diff --git a/bazel/py_toolchains.bzl b/bazel/py_toolchains.bzl index e300d5f..a80795b 100644 --- a/bazel/py_toolchains.bzl +++ b/bazel/py_toolchains.bzl @@ -2,11 +2,10 @@ load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") -def py_toolchains(repo_mapping = {}): +def py_toolchains(): py_repositories() python_register_toolchains( name = "python3_10_12", python_version = "3.10.12", - repo_mapping = repo_mapping, ) diff --git a/bazel/pypi_repos.bzl b/bazel/pypi_repos.bzl index 0647888..ebf8407 100644 --- a/bazel/pypi_repos.bzl +++ b/bazel/pypi_repos.bzl @@ -3,12 +3,11 @@ should be installed later in WORKSPACE file to be accessible. `pip_parse` takes a `requirements_lock` file as input, which is generated by the `bazel run :requirements.update` command.""" -load("@python3_10_12//:defs.bzl", "interpreter") load("@rules_python//python:pip.bzl", "pip_parse") def pypi_repos(): pip_parse( name = "pyprotoc_plugin_pypi", - python_interpreter_target = interpreter, + python_interpreter_target = "@python3_10_12_host//:python", requirements_lock = "@com_github_reboot_dev_pyprotoc_plugin//:requirements_lock.txt", ) diff --git a/bazel/repos.bzl b/bazel/repos.bzl index a5cf218..b10f677 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -9,43 +9,26 @@ # instructions at https://github.com/reboot-dev/pyprotoc-plugin. ######################################################################## -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -def repos(external = True, repo_mapping = {}): - """Adds repositories/archives needed by pyprotoc-plugin +def repos(): + """Adds repositories/archives needed by pyprotoc-plugin.""" - Args: - external: whether or not we're invoking this function as though - though we're an external dependency - repo_mapping: passed through to all other functions that expect/use - repo_mapping, e.g., 'git_repository' - """ - http_archive( + maybe( + http_archive, name = "rules_python", - sha256 = "9acc0944c94adb23fba1c9988b48768b1bacc6583b52a2586895c5b7491e2e31", - strip_prefix = "rules_python-0.27.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.27.0/rules_python-0.27.0.tar.gz", - repo_mapping = repo_mapping, + sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07", + strip_prefix = "rules_python-1.0.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz", ) - if "com_google_protobuf" not in native.existing_rules(): - git_repository( - name = "com_google_protobuf", - remote = "https://github.com/protocolbuffers/protobuf", - # Release v3.19.4. - # TODO(codingcanuck): Update to a newer release after - # https://github.com/protocolbuffers/protobuf/issues/9688 is fixed. - commit = "22d0e265de7d2b3d2e9a00d071313502e7d4cccf", - shallow_since = "1643340956 -0800", - repo_mapping = repo_mapping, - ) - - if external and "com_github_reboot_dev_pyprotoc_plugin" not in native.existing_rules(): - git_repository( - name = "com_github_reboot_dev_pyprotoc_plugin", - remote = "https://github.com/reboot-dev/pyprotoc-plugin", - commit = "9f7a281670f03b77140c4437ac2a56b86f978af6", - shallow_since = "1649038239 +0000", - repo_mapping = repo_mapping, - ) + maybe( + http_archive, + name = "com_google_protobuf", + sha256 = "955ef3235be41120db4d367be81efe6891c9544b3a71194d80c3055865b26e09", + strip_prefix = "protobuf-29.5", + urls = [ + "https://github.com/protocolbuffers/protobuf/archive/v29.5.tar.gz", + ], + ) diff --git a/requirements.in b/requirements.in index 9fb21af..7423a20 100644 --- a/requirements.in +++ b/requirements.in @@ -1,2 +1,2 @@ Jinja2>=3 -protobuf>=3 +protobuf>= 5.29.5 diff --git a/requirements_lock.txt b/requirements_lock.txt index 63b8c40..36a6a0f 100644 --- a/requirements_lock.txt +++ b/requirements_lock.txt @@ -70,16 +70,14 @@ markupsafe==2.1.3 \ --hash=sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2 \ --hash=sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11 # via jinja2 -protobuf==4.25.1 \ - --hash=sha256:0bf384e75b92c42830c0a679b0cd4d6e2b36ae0cf3dbb1e1dfdda48a244f4bcd \ - --hash=sha256:0f881b589ff449bf0b931a711926e9ddaad3b35089cc039ce1af50b21a4ae8cb \ - --hash=sha256:1484f9e692091450e7edf418c939e15bfc8fc68856e36ce399aed6889dae8bb0 \ - --hash=sha256:193f50a6ab78a970c9b4f148e7c750cfde64f59815e86f686c22e26b4fe01ce7 \ - --hash=sha256:3497c1af9f2526962f09329fd61a36566305e6c72da2590ae0d7d1322818843b \ - --hash=sha256:57d65074b4f5baa4ab5da1605c02be90ac20c8b40fb137d6a8df9f416b0d0ce2 \ - --hash=sha256:8bdbeaddaac52d15c6dce38c71b03038ef7772b977847eb6d374fc86636fa510 \ - --hash=sha256:a19731d5e83ae4737bb2a089605e636077ac001d18781b3cf489b9546c7c80d6 \ - --hash=sha256:abc0525ae2689a8000837729eef7883b9391cd6aa7950249dcf5a4ede230d5dd \ - --hash=sha256:becc576b7e6b553d22cbdf418686ee4daa443d7217999125c045ad56322dda10 \ - --hash=sha256:ca37bf6a6d0046272c152eea90d2e4ef34593aaa32e8873fc14c16440f22d4b7 +protobuf==6.32.1 \ + --hash=sha256:2601b779fc7d32a866c6b4404f9d42a3f67c5b9f3f15b4db3cccabe06b95c346 \ + --hash=sha256:2f5b80a49e1eb7b86d85fcd23fe92df154b9730a725c3b38c4e43b9d77018bf4 \ + --hash=sha256:68ff170bac18c8178f130d1ccb94700cf72852298e016a2443bdb9502279e5f1 \ + --hash=sha256:a8a32a84bc9f2aad712041b8b366190f71dde248926da517bde9e832e4412085 \ + --hash=sha256:b00a7d8c25fa471f16bc8153d0e53d6c9e827f0953f3c09aaa4331c718cae5e1 \ + --hash=sha256:b1864818300c297265c83a4982fd3169f97122c299f56a56e2445c3698d34710 \ + --hash=sha256:d0975d0b2f3e6957111aa3935d08a0eb7e006b1505d825f862a1fffc8348e122 \ + --hash=sha256:d8c7e6eb619ffdf105ee4ab76af5a68b60a9d0f66da3ea12d1640e6d8dab7281 \ + --hash=sha256:ee2469e4a021474ab9baafea6cd070e5bf27c7d29433504ddea1a4ee5850f68d # via -r requirements.in diff --git a/rules.bzl b/rules.bzl index b8be2b9..03db4f5 100644 --- a/rules.bzl +++ b/rules.bzl @@ -1,6 +1,6 @@ """Defines rules to create pyprotoc-based bazel rules.""" -load("@rules_proto//proto:defs.bzl", "ProtoInfo") +load("@com_google_protobuf//bazel/common:proto_info.bzl", "ProtoInfo") def _get_proto_sources(context): proto_files = [ diff --git a/submodules/dev-tools b/submodules/dev-tools index 2cd6b53..b0d85d9 160000 --- a/submodules/dev-tools +++ b/submodules/dev-tools @@ -1 +1 @@ -Subproject commit 2cd6b53447768e5fae86885fe20dae03aba16395 +Subproject commit b0d85d95c33f805a37986f890ec8d391c7d51046 diff --git a/tests/cpp/BUILD.bazel b/tests/cpp/BUILD.bazel index 8a20e3f..9913a99 100644 --- a/tests/cpp/BUILD.bazel +++ b/tests/cpp/BUILD.bazel @@ -1,5 +1,6 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library") -load("@rules_proto//proto:defs.bzl", "proto_library") +load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") +load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@rules_python//python:defs.bzl", "py_binary") load(":cpp_rule.bzl", "cc_generate_library") @@ -54,8 +55,9 @@ cc_library( ], ) -cc_binary( +cc_test( name = "cc_test", + size = "small", srcs = ["cc_generated_test.cc"], deps = [ ":cc_library_generated", diff --git a/tests/python/BUILD.bazel b/tests/python/BUILD.bazel index f6d17fd..eac5756 100644 --- a/tests/python/BUILD.bazel +++ b/tests/python/BUILD.bazel @@ -1,10 +1,11 @@ -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") -load("@rules_proto//proto:defs.bzl", "proto_library") +load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") +load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") load(":sample_rule.bzl", "py_sample_library") py_test( name = "library_tests", + size = "small", srcs = [ "library_tests.py", ], @@ -30,7 +31,7 @@ proto_library( py_proto_library( name = "sample_messages_py_proto", - srcs = ["sample_messages.proto"], + deps = [":sample_messages_proto"], ) proto_library( @@ -41,8 +42,7 @@ proto_library( py_proto_library( name = "sample_service_py_proto", - srcs = ["sample_service.proto"], - deps = [":sample_messages_py_proto"], + deps = [":sample_messages_proto"], ) py_sample_library( @@ -62,6 +62,7 @@ py_library( py_test( name = "sample_generated_library_test", + size = "small", srcs = [ "sample_generated_library_test.py", ],