From fff490558816802c5b3d51169f797046f369453f Mon Sep 17 00:00:00 2001 From: Mike Kruskal Date: Fri, 28 Jul 2023 17:07:02 -0700 Subject: [PATCH] Drop support for Bazel 5. This moves all our CI to Bazel 6 and drops the additional parameterization we had on Bazel version. PiperOrigin-RevId: 551986376 --- .github/workflows/test_cpp.yml | 60 ++++++++--------- .github/workflows/test_csharp.yml | 8 +-- .github/workflows/test_java.yml | 22 +++---- .github/workflows/test_objectivec.yml | 8 +-- .github/workflows/test_php.yml | 28 ++++---- .github/workflows/test_php_ext.yml | 2 +- .github/workflows/test_python.yml | 8 +-- .github/workflows/test_ruby.yml | 40 +++++------- .github/workflows/test_rust.yml | 4 +- src/google/protobuf/compiler/BUILD.bazel | 10 ++- .../command_line_interface_unittest.cc | 5 ++ .../compiler/test_plugin_injection.bzl | 65 +++++++++++++++++++ 12 files changed, 164 insertions(+), 96 deletions(-) create mode 100644 src/google/protobuf/compiler/test_plugin_injection.bzl diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml index ad2a5e300533..ed90e97833fd 100644 --- a/.github/workflows/test_cpp.yml +++ b/.github/workflows/test_cpp.yml @@ -26,20 +26,16 @@ jobs: - { name: No-RTTI, flags: --cxxopt=-fno-rtti } include: # Set defaults - - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize@sha256:309dae3122031447d714414814d262e5f31cb93c0e248e9c02f9d8cdafd7e3b9 + - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize@sha256:04cd765285bc52cbbf51d66c8c66d8603579cf0f19cc42df26b09d2c270541fb - targets: //pkg/... //src/... @com_google_protobuf_examples//... # Override cases with custom images - config: { name: "TCMalloc" } - image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/tcmalloc@sha256:4df3b4749e787ba0a671ec0b783d0f1ba05f60be4c9e9fd72c875550a0cde1ea" + image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/tcmalloc@sha256:e4493c58e7c3f3a0775e0b19a46bc822e866a5275b7a5463f509af8072f283db" targets: "//src/..." - config: { name: "aarch64" } targets: "//src/... //src/google/protobuf/compiler:protoc_aarch64_test" - image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-3af05275178e16af30961976af126eabbbb2c733" - # TODO(b/278116805) Enable this once Bazel 6 is supported. - #- config: { name: "Bazel6" } - # targets: "//src/..." - # image: "us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.0.0-6361b3a6e5c97e9951d03a4de28542fc45f1adab" + image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-222e7e87028b7098e088f5ca7cae06d32f483eb5" name: Linux ${{ matrix.config.name }} runs-on: ubuntu-latest steps: @@ -48,7 +44,7 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: image: ${{ matrix.image }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -68,9 +64,9 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:${{ matrix.version }}-5.4.0-2d15d9e888c9e7f90961dbd3afc8ea209717fb4b + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:${{ matrix.version }}-6.3.0-518b4fcd8d0ded2484c94f02e835526cacfdac2d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: cpp_linux/gcc-${{ matrix.version }} bazel: test //pkg/... //src/... @com_google_protobuf_examples//... @@ -90,19 +86,19 @@ jobs: submodules: recursive - name: Cross compile protoc for ${{ matrix.arch }} id: cross-compile - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 + uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} architecture: linux-${{ matrix.arch }} - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: linux-release-${{ matrix.arch }} - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:${{ matrix.arch }}-3af05275178e16af30961976af126eabbbb2c733 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:${{ matrix.arch }}-222e7e87028b7098e088f5ca7cae06d32f483eb5 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} entrypoint: bash command: > @@ -137,12 +133,12 @@ jobs: ref: ${{ inputs.safe-checkout }} - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: linux-cmake-${{ matrix.name }} - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.13.3-e6272cdfe97c6df307e17b83f3a7a70844f6fc08 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -162,12 +158,12 @@ jobs: submodules: recursive - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: linux-cmake-install - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -191,12 +187,12 @@ jobs: ref: ${{ inputs.safe-checkout }} - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: linux-cmake-examples - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.10.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -231,14 +227,14 @@ jobs: submodules: recursive - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: linux-cmake-gcc-${{ matrix.name }} - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-5.4.0-307caa02808127e49720f3e77d6a9f3b3ef5a915 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-518b4fcd8d0ded2484c94f02e835526cacfdac2d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} entrypoint: bash command: >- @@ -261,12 +257,12 @@ jobs: submodules: recursive - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: linux-cmake-${{ matrix.name }} - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.13.3-1da1e086a7d1863b8bdd181ef6388a02dcd62f3a credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -285,12 +281,12 @@ jobs: submodules: recursive - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: linux-cmake-32-bit - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/32bit@sha256:f99f051daa8b12f4ebad5927f389bc71372f771ab080290ab451cbaf1648f9ea platform: linux/386 @@ -331,7 +327,7 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel@v1 + uses: protocolbuffers/protobuf-ci/bazel@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel: ${{ matrix.bazel }} @@ -386,7 +382,7 @@ jobs: submodules: recursive - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: ${{ matrix.name }} vsversion: ${{ matrix.vsversion }} @@ -394,7 +390,7 @@ jobs: # Install phase. - name: Configure CMake for install if: matrix.install-flags - uses: protocolbuffers/protobuf-ci/bash@v1 + uses: protocolbuffers/protobuf-ci/bash@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} command: cmake . ${{ matrix.install-flags }} ${{ env.CCACHE_CMAKE_FLAGS }} @@ -416,7 +412,7 @@ jobs: run: cmake --build . --target clean && rm CMakeCache.txt - name: Configure CMake - uses: protocolbuffers/protobuf-ci/bash@v1 + uses: protocolbuffers/protobuf-ci/bash@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} command: cmake . ${{ matrix.flags }} ${{ env.CCACHE_CMAKE_FLAGS }} diff --git a/.github/workflows/test_csharp.yml b/.github/workflows/test_csharp.yml index f0cafc380947..21c1aebecd47 100644 --- a/.github/workflows/test_csharp.yml +++ b/.github/workflows/test_csharp.yml @@ -21,9 +21,9 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/csharp:3.1.415-6.0.100-508417e5215994ade7585d28ba3aad681a25fa5d + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/csharp:3.1.415-6.0.100-66964dc8b07b6d1fc73a5cc14e59e84c1c534cea credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: csharp_linux bazel: test //csharp/... --action_env=DOTNET_CLI_TELEMETRY_OPTOUT=1 --test_env=DOTNET_CLI_HOME=/home/bazel @@ -60,7 +60,7 @@ jobs: - name: Build protobuf C# tests under x86_64 docker image # Tests are built "dotnet publish" because we want all the dependencies to the copied to the destination directory # (we want to avoid references to ~/.nuget that won't be available in the subsequent docker run) - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: mcr.microsoft.com/dotnet/sdk:6.0.100-bullseye-slim credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -77,7 +77,7 @@ jobs: # running under current user's UID and GID. To be able to do that, we need to provide a home directory for the user # otherwise the UID would be homeless under the docker container and pip install wouldn't work. For simplicity, # we just run map the user's home to a throwaway temporary directory - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: mcr.microsoft.com/dotnet/sdk:6.0.100-bullseye-slim-arm64v8 skip-staleness-check: true diff --git a/.github/workflows/test_java.yml b/.github/workflows/test_java.yml index 89c487fe97fd..a23abb3fbad1 100644 --- a/.github/workflows/test_java.yml +++ b/.github/workflows/test_java.yml @@ -19,19 +19,19 @@ jobs: include: - name: OpenJDK 8 version: '8' - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:8-03a376b5d6ef66f827fc307716e3b841cc26b709 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:8-1fdbb997433cb22c1e49ef75ad374a8d6bb88702 targets: //java/... //java/internal:java_version - name: OpenJDK 11 version: '11' - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-03a376b5d6ef66f827fc307716e3b841cc26b709 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-1fdbb997433cb22c1e49ef75ad374a8d6bb88702 targets: //java/... //java/internal:java_version - name: OpenJDK 17 version: '17' - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:17-03a376b5d6ef66f827fc307716e3b841cc26b709 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:17-1fdbb997433cb22c1e49ef75ad374a8d6bb88702 targets: //java/... //java/internal:java_version - name: aarch64 version: 'aarch64' - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-3af05275178e16af30961976af126eabbbb2c733 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-222e7e87028b7098e088f5ca7cae06d32f483eb5 targets: //java/... //src/google/protobuf/compiler:protoc_aarch64_test name: Linux ${{ matrix.name }} @@ -42,7 +42,7 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: image: ${{ matrix.image }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -58,9 +58,9 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run Linkage Monitor test - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:8-03a376b5d6ef66f827fc307716e3b841cc26b709 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:8-1fdbb997433cb22c1e49ef75ad374a8d6bb88702 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: java_linux/8 bazel: test --test_output=all //java:linkage_monitor --spawn_strategy=standalone @@ -75,9 +75,9 @@ jobs: ref: ${{ inputs.safe-checkout }} - name: Build protoc id: build-protoc - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 + uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} architecture: linux-x86_64 - name: Move protoc into place and clean up @@ -89,9 +89,9 @@ jobs: mvn -e -B -Dhttps.protocols=TLSv1.2 install -Dmaven.test.skip=true working-directory: java - name: Generate pom.xml files from the template - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-03a376b5d6ef66f827fc307716e3b841cc26b709 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-1fdbb997433cb22c1e49ef75ad374a8d6bb88702 credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: java_linux/11 # protobuf-java and protobuf-java-util are the member of the BOM diff --git a/.github/workflows/test_objectivec.yml b/.github/workflows/test_objectivec.yml index c3c04e9e1f0b..ae19ec670162 100644 --- a/.github/workflows/test_objectivec.yml +++ b/.github/workflows/test_objectivec.yml @@ -39,13 +39,13 @@ jobs: ref: ${{ inputs.safe-checkout }} - name: Setup ccache - uses: protocolbuffers/protobuf-ci/ccache@v1 + uses: protocolbuffers/protobuf-ci/ccache@v2 with: cache-prefix: objectivec_${{ matrix.platform }}_${{ matrix.xc_config }} support-modules: true - name: Run tests - uses: protocolbuffers/protobuf-ci/bash@v1 + uses: protocolbuffers/protobuf-ci/bash@v2 env: CC: ${{ github.workspace }}/ci/clang_wrapper CXX: ${{ github.workspace }}/ci/clang_wrapper++ @@ -81,7 +81,7 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Pod lib lint - uses: protocolbuffers/protobuf-ci/bash@v1 + uses: protocolbuffers/protobuf-ci/bash@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} command: | @@ -122,7 +122,7 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: bazel ${{ matrix.config.bazel_action }} - uses: protocolbuffers/protobuf-ci/bazel@v1 + uses: protocolbuffers/protobuf-ci/bazel@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel: ${{ matrix.config.bazel_action }} ${{ matrix.config.flags }} ${{ matrix.bazel_targets }} diff --git a/.github/workflows/test_php.yml b/.github/workflows/test_php.yml index 2da2f4f1727d..e61db63b5908 100644 --- a/.github/workflows/test_php.yml +++ b/.github/workflows/test_php.yml @@ -44,14 +44,14 @@ jobs: ref: ${{ inputs.safe-checkout }} submodules: recursive - name: Setup composer - uses: protocolbuffers/protobuf-ci/composer-setup@v1 + uses: protocolbuffers/protobuf-ci/composer-setup@v2 with: cache-prefix: php-${{ matrix.version-short }} directory: php - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:${{ matrix.version }}-508417e5215994ade7585d28ba3aad681a25fa5d + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:${{ matrix.version }}-66964dc8b07b6d1fc73a5cc14e59e84c1c534cea credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} extra-flags: -e COMPOSER_HOME=/workspace/composer-cache command: ${{ matrix.command }} @@ -85,20 +85,20 @@ jobs: - name: Cross compile protoc for i386 id: cross-compile - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 + uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} architecture: linux-i386 - name: Setup composer - uses: protocolbuffers/protobuf-ci/composer-setup@v1 + uses: protocolbuffers/protobuf-ci/composer-setup@v2 with: cache-prefix: php-${{ matrix.version }} directory: php - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: ${{ env.image }} skip-staleness-check: true @@ -123,20 +123,20 @@ jobs: - name: Cross compile protoc for aarch64 id: cross-compile - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 + uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} architecture: linux-aarch64 - name: Setup composer - uses: protocolbuffers/protobuf-ci/composer-setup@v1 + uses: protocolbuffers/protobuf-ci/composer-setup@v2 with: cache-prefix: php-8.0 directory: php - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php-aarch64:0cc100b6e03d14c1e8f71ae794dc162ed122fe31@sha256:77b70feba68dced1f0fd21b52a08d3d2e0c5c797bfe68435a0038ce87ecfd310 platform: linux/arm64 @@ -180,13 +180,13 @@ jobs: run: php --version | grep ${{ matrix.version }} || (echo "Invalid PHP version - $(php --version)" && exit 1) - name: Setup composer - uses: protocolbuffers/protobuf-ci/composer-setup@v1 + uses: protocolbuffers/protobuf-ci/composer-setup@v2 with: cache-prefix: php-${{ matrix.version }} directory: php - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel@v1 + uses: protocolbuffers/protobuf-ci/bazel@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: php_macos/${{ matrix.version }} @@ -199,7 +199,7 @@ jobs: popd - name: Run conformance tests - uses: protocolbuffers/protobuf-ci/bazel@v1 + uses: protocolbuffers/protobuf-ci/bazel@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: php_macos/${{ matrix.version }} diff --git a/.github/workflows/test_php_ext.yml b/.github/workflows/test_php_ext.yml index 1c3f3bb9e3de..d922859a7ccc 100644 --- a/.github/workflows/test_php_ext.yml +++ b/.github/workflows/test_php_ext.yml @@ -22,7 +22,7 @@ jobs: ref: ${{ inputs.safe-checkout }} - name: Package extension - uses: protocolbuffers/protobuf-ci/bazel@v1 + uses: protocolbuffers/protobuf-ci/bazel@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: php_ext/${{ matrix.version }} diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index f82aa469fdb0..49c10633a040 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -30,7 +30,7 @@ jobs: targets: //python/... //python:aarch64_test # TODO(b/262628111) Enable this once conformance tests are fixed. flags: --define=use_fast_cpp_protos=true --test_tag_filters=-conformance - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-3af05275178e16af30961976af126eabbbb2c733 + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-222e7e87028b7098e088f5ca7cae06d32f483eb5 name: Linux ${{ matrix.type }} ${{ matrix.version }} runs-on: ubuntu-latest @@ -40,9 +40,9 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:{0}-508417e5215994ade7585d28ba3aad681a25fa5d', matrix.version) }} + image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:{0}-66964dc8b07b6d1fc73a5cc14e59e84c1c534cea', matrix.version) }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: python_linux/${{ matrix.type }}_${{ matrix.version }} bazel: test ${{ matrix.targets }} ${{ matrix.flags }} --test_env=KOKORO_PYTHON_VERSION @@ -85,7 +85,7 @@ jobs: source venv/bin/activate - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel@v1 + uses: protocolbuffers/protobuf-ci/bazel@v2 env: KOKORO_PYTHON_VERSION: ${{ matrix.version }} with: diff --git a/.github/workflows/test_ruby.yml b/.github/workflows/test_ruby.yml index b9b21bfd0c17..b94836997773 100644 --- a/.github/workflows/test_ruby.yml +++ b/.github/workflows/test_ruby.yml @@ -17,13 +17,11 @@ jobs: fail-fast: false matrix: include: - - { name: Ruby 2.7, ruby: ruby-2.7.0, bazel: 5.1.1} - - { name: Ruby 3.0, ruby: ruby-3.0.2, bazel: 5.1.1} - - { name: Ruby 3.1, ruby: ruby-3.1.0, bazel: 5.1.1} - - { name: Ruby 3.2, ruby: ruby-3.2.0, bazel: 5.1.1} - - { name: JRuby 9.4, ruby: jruby-9.4.3.0, bazel: 5.1.1} - - { name: Ruby 2.7 (Bazel6), ruby: ruby-2.7.0, bazel: 6.0.0} - - { name: JRuby 9.4 (Bazel6), ruby: jruby-9.4.3.0, bazel: 6.0.0} + - { name: Ruby 2.7, ruby: ruby-2.7.0 } + - { name: Ruby 3.0, ruby: ruby-3.0.2 } + - { name: Ruby 3.1, ruby: ruby-3.1.0 } + - { name: Ruby 3.2, ruby: ruby-3.2.0 } + - { name: JRuby 9.4, ruby: jruby-9.4.3.0 } name: Linux ${{ matrix.name }} runs-on: ubuntu-latest @@ -33,9 +31,9 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:{0}-{1}-508417e5215994ade7585d28ba3aad681a25fa5d', matrix.ruby, matrix.bazel) }} + image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:{0}-6.3.0-66964dc8b07b6d1fc73a5cc14e59e84c1c534cea', matrix.ruby) }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: ruby_linux/${{ matrix.ruby }}_${{ matrix.bazel }} bazel: test //ruby/... //ruby/tests:ruby_version --test_env=KOKORO_RUBY_VERSION @@ -51,14 +49,14 @@ jobs: - name: Cross compile protoc for aarch64 id: cross-compile - uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 + uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} architecture: linux-aarch64 - name: Run tests - uses: protocolbuffers/protobuf-ci/docker@v1 + uses: protocolbuffers/protobuf-ci/docker@v2 with: image: arm64v8/ruby:2.7.3-buster skip-staleness-check: true @@ -96,7 +94,7 @@ jobs: run: ruby --version | grep ${{ matrix.version }} || (echo "Invalid Ruby version - $(ruby --version)" && exit 1) - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel@v1 + uses: protocolbuffers/protobuf-ci/bazel@v2 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: ruby_macos/${{ matrix.version }} @@ -107,13 +105,11 @@ jobs: fail-fast: false matrix: include: - - { name: Ruby 2.7, ruby: ruby-2.7.0, bazel: 5.1.1} - - { name: Ruby 3.0, ruby: ruby-3.0.2, bazel: 5.1.1} - - { name: Ruby 3.1, ruby: ruby-3.1.0, bazel: 5.1.1} - - { name: Ruby 3.2, ruby: ruby-3.2.0, bazel: 5.1.1} - - { name: JRuby 9.4, ruby: jruby-9.4.3.0, bazel: 5.1.1} - - { name: Ruby 2.7 (Bazel6), ruby: ruby-2.7.0, bazel: 6.0.0} - - { name: JRuby 9.4 (Bazel6), ruby: jruby-9.4.3.0, bazel: 6.0.0} + - { name: Ruby 2.7, ruby: ruby-2.7.0 } + - { name: Ruby 3.0, ruby: ruby-3.0.2 } + - { name: Ruby 3.1, ruby: ruby-3.1.0 } + - { name: Ruby 3.2, ruby: ruby-3.2.0 } + - { name: JRuby 9.4, ruby: jruby-9.4.3.0 } name: Install ${{ matrix.name }} runs-on: ubuntu-latest steps: @@ -122,9 +118,9 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:${{ matrix.ruby }}-${{ matrix.bazel }}-508417e5215994ade7585d28ba3aad681a25fa5d + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:${{ matrix.ruby }}-6.3.0-66964dc8b07b6d1fc73a5cc14e59e84c1c534cea credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: ruby_install/${{ matrix.ruby }}_${{ matrix.bazel }} bash: > diff --git a/.github/workflows/test_rust.yml b/.github/workflows/test_rust.yml index ee86f6d64e3e..086ac5084a71 100644 --- a/.github/workflows/test_rust.yml +++ b/.github/workflows/test_rust.yml @@ -21,9 +21,9 @@ jobs: with: ref: ${{ inputs.safe-checkout }} - name: Run tests - uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + uses: protocolbuffers/protobuf-ci/bazel-docker@v2 with: - image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.0.0-6361b3a6e5c97e9951d03a4de28542fc45f1adab + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} bazel-cache: rust_linux bazel: | diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel index d5f3a7aecbdb..9b4c243d18d2 100644 --- a/src/google/protobuf/compiler/BUILD.bazel +++ b/src/google/protobuf/compiler/BUILD.bazel @@ -12,6 +12,7 @@ load( load("@rules_proto//proto:defs.bzl", "proto_library") load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test") load("//build_defs:cpp_opts.bzl", "COPTS") +load("test_plugin_injection.bzl", "inject_plugin_paths") proto_library( name = "plugin_proto", @@ -267,6 +268,8 @@ cc_test( ], ) +inject_plugin_paths("test_plugin_paths") + cc_test( name = "command_line_interface_unittest", srcs = ["command_line_interface_unittest.cc"], @@ -278,8 +281,10 @@ cc_test( ], }) + [ # Note: This only works on Windows with symlinks and runfiles enabled. - "-DGOOGLE_PROTOBUF_FAKE_PLUGIN_PATH=\\\"$(rootpath :fake_plugin)\\\"", - "-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH=\\\"$(rootpath :test_plugin)\\\"", + # "-DGOOGLE_PROTOBUF_FAKE_PLUGIN_PATH=\\\"$(rootpath :fake_plugin)\\\"", + # "-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH=\\\"$(rootpath :test_plugin)\\\"", + # Workaround for https://github.com/bazelbuild/bazel/issues/19124. + "-DGOOGLE_PROTOBUF_USE_BAZEL_GENERATED_PLUGIN_PATHS=1", ], data = [ ":fake_plugin", @@ -293,6 +298,7 @@ cc_test( ":command_line_interface", ":command_line_interface_tester", ":mock_code_generator", + ":test_plugin_paths", "//:protobuf", "//src/google/protobuf:cc_test_protos", "//src/google/protobuf:test_textproto", diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index 4fe1211b7c82..7cd9a9b06466 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc @@ -73,6 +73,11 @@ #include "google/protobuf/unittest.pb.h" #include "google/protobuf/unittest_custom_options.pb.h" +#ifdef GOOGLE_PROTOBUF_USE_BAZEL_GENERATED_PLUGIN_PATHS +// This is needed because of https://github.com/bazelbuild/bazel/issues/19124. +#include "google/protobuf/compiler/test_plugin_paths.h" +#endif // GOOGLE_PROTOBUF_USE_BAZEL_GENERATED_PLUGIN_PATHS + // Must be included last. #include "google/protobuf/port_def.inc" diff --git a/src/google/protobuf/compiler/test_plugin_injection.bzl b/src/google/protobuf/compiler/test_plugin_injection.bzl new file mode 100644 index 000000000000..aec25441e806 --- /dev/null +++ b/src/google/protobuf/compiler/test_plugin_injection.bzl @@ -0,0 +1,65 @@ +# Protocol Buffers - Google's data interchange format +# Copyright 2008 Google Inc. All rights reserved. +# https:#developers.google.com/protocol-buffers/ +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +load("//build_defs:cpp_opts.bzl", "COPTS") + +# This works around https://github.com/bazelbuild/bazel/issues/19124 by using a generated header to +# inject the Bazel path of the test plugins. The simpler alternative is broken in Bazel 6.3.0, +# which is to just inject these via copts. +def inject_plugin_paths(name): + hdr = name + ".h" + native.genrule( + name = "test_plugin_paths_gen", + outs = [hdr], + srcs = [ + ":fake_plugin", + ":test_plugin", + ], + cmd = """ +cat <<'EOF' >$(OUTS) +#ifndef GOOGLE_PROTOBUF_COMPILER_TEST_PLUGIN_PATHS_H__ +#define GOOGLE_PROTOBUF_COMPILER_TEST_PLUGIN_PATHS_H__ + +#define GOOGLE_PROTOBUF_TEST_PLUGIN_PATH "$(rootpath :test_plugin)" +#define GOOGLE_PROTOBUF_FAKE_PLUGIN_PATH "$(rootpath :fake_plugin)" + +#endif // GOOGLE_PROTOBUF_COMPILER_TEST_PLUGIN_PATHS_H__ +""", + visibility = ["//visibility:private"], + testonly = True, + ) + + native.cc_library( + name = name, + hdrs = [hdr], + strip_include_prefix = "/src", + copts = COPTS, + testonly = True, + )