mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Currently if you build with `--incompatible_enable_proto_toolchain_resolution`
(on by default in Bazel 9) on main or any recent Git commit, you end up using
an old v33.0 prebuilt protoc binary. The `authenticity_validation` rule does
not catch this, because it just checks that the `RELEASE_VERSION` prebuilt we
downloaded has version `RELEASE_VERSION`. This constant is never updated in
Git, only in releases published to BCR. As a result, we get mysterious compiler
errors rather than a clear error about what is going wrong.
This commit fixes the problem by keeping `RELEASE_VERSION` up to date with the
existing `PROTOC_VERSION`. This will cause the build to fail loudly if you try
to use a prebuilt protoc binary with a protobuf Git checkout. To make sure that
developers do not hit this issue, I updated .bazelrc to explicitly turn off use
of the prebuilt protoc.
I also removed `examples/example_without_cc_toolchain/`, because I don't think
this test is doing anything useful anymore. It attempts to exercise the
prebuilt protoc, but that is something we do not expect to work correctly with
unreleased protobuf code, and with my change it would result in a build error.
Closes #28167
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/28167 from protocolbuffers:prebuilt d7c67c9ce7
PiperOrigin-RevId: 943511369
120 lines
4.6 KiB
YAML
120 lines
4.6 KiB
YAML
name: Bazel Tests
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
continuous-run:
|
|
required: true
|
|
description: "Boolean string denoting whether this run is continuous --
|
|
empty string for presubmit, non-empty string for continuous."
|
|
type: string
|
|
safe-checkout:
|
|
required: true
|
|
description: "The SHA key for the commit we want to run over"
|
|
type: string
|
|
continuous-prefix:
|
|
required: true
|
|
description: "The string continuous-only tests should be prefixed with when displaying test results."
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
examples:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runner: [ ubuntu, windows, macos ]
|
|
bazelversion: [ '8.6.0', '9.0.0' ]
|
|
bzlmod: [ true, false ]
|
|
toolchain_resolution:
|
|
# Default flags, uses from prebuilt protoc
|
|
- ""
|
|
# Still uses prebuilt protoc
|
|
- "--incompatible_enable_proto_toolchain_resolution=false"
|
|
# Uses protoc from source.
|
|
- "--@com_google_protobuf//bazel/flags:prefer_prebuilt_protoc=false"
|
|
exclude:
|
|
- bazelversion: '9.0.0'
|
|
bzlmod: false
|
|
runs-on: ${{ matrix.runner }}-latest
|
|
name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Examples ${{ matrix.runner }} ${{ matrix.bazelversion }}${{ matrix.bzlmod && ' (bzlmod)' || '' }} ${{ matrix.toolchain_resolution && ' (toolchain resolution)' || '' }}
|
|
steps:
|
|
- name: Checkout pending changes
|
|
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
|
|
uses: protocolbuffers/protobuf-ci/checkout@v5
|
|
with:
|
|
ref: ${{ inputs.safe-checkout }}
|
|
|
|
# rules_jvm_external doesn't support Java 8, which is the default version
|
|
# on some github runners. When this is selected, it results in some
|
|
# opaque errors about coursier (see
|
|
# https://github.com/bazel-contrib/rules_jvm_external/issues/1337).
|
|
- name: Pin to Java 11
|
|
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
|
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '11'
|
|
|
|
- name: Windows startup flags
|
|
if: ${{ runner.os == 'Windows' && (!matrix.continuous-only || inputs.continuous-run) }}
|
|
working-directory: examples
|
|
shell: bash
|
|
run: echo "startup --output_user_root=C:/ --windows_enable_symlinks" >> .bazelrc
|
|
|
|
- name: Configure Bazel version
|
|
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
|
|
working-directory: examples
|
|
shell: bash
|
|
run: echo "${{ matrix.bazelversion }}" > .bazelversion
|
|
|
|
- name: Run tests
|
|
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
|
|
uses: protocolbuffers/protobuf-ci/bazel@v5
|
|
with:
|
|
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
|
|
bazel-cache: examples-${{ matrix.bazelversion }}-${{ matrix.bzlmod }}-${{ matrix.toolchain_resolution }}
|
|
version: ${{ matrix.bazelversion }}
|
|
bash: >
|
|
cd examples;
|
|
bazel build //... @com_google_protobuf-examples-with-hyphen//... $BAZEL_FLAGS --enable_bzlmod=${{ matrix.bzlmod }} --enable_workspace=${{ !matrix.bzlmod }} ${{ matrix.toolchain_resolution }};
|
|
|
|
bazel-tests-ubuntu:
|
|
strategy:
|
|
fail-fast: false # Don't cancel all jobs if one fails.
|
|
name: Bazel Tests ubuntu
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout pending changes
|
|
uses: protocolbuffers/protobuf-ci/checkout@v5
|
|
with:
|
|
ref: ${{ inputs.safe-checkout }}
|
|
- name: Run tests
|
|
uses: protocolbuffers/protobuf-ci/bazel-docker@v5
|
|
with:
|
|
image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:9.0.0-9dca0d9417f43f5f1e97e59969fb0f3e6ae3bd9c
|
|
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
|
|
bazel-cache: "bazel-tests"
|
|
bazel: test //bazel/...
|
|
|
|
bazel-tests-windows-macos:
|
|
strategy:
|
|
fail-fast: false # Don't cancel all jobs if one fails.
|
|
matrix:
|
|
runner: [ windows-2022, macos-14 ]
|
|
name: Bazel Tests ${{ matrix.runner }}
|
|
runs-on: ${{ matrix.runner }}
|
|
steps:
|
|
- name: Checkout pending changes
|
|
uses: protocolbuffers/protobuf-ci/checkout@v5
|
|
with:
|
|
ref: ${{ inputs.safe-checkout }}
|
|
- name: Run tests
|
|
uses: protocolbuffers/protobuf-ci/bazel@v5
|
|
with:
|
|
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
|
|
bazel-cache: "bazel-tests-${{ matrix.runner }}"
|
|
bazel: test //bazel/...
|
|
version: 8.6.0
|