Skip to content

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Oct 7, 2025

Add compatibility test to check that old Rust gencode works with newer runtime

This way this works is that we download our prebuilt protoc release binary and
put simple MODULE.bazel and BUILD.bazel files in front of it so that it
looks like a normal Bazel dependency. We can then run all our Cargo tests using
that protoc binary to generate code.

The nice thing about this approach is that it should require pretty minimal
maintenance going forward. Since we're not building the old protoc from source,
we don't have to worry about it bit-rotting and requiring new patches. Any time
we add new tests, those will also get picked up immediately, as long as they
are run with Cargo and not just Bazel.

One drawback is that this only works for Linux on x86-64, but this seems fine
since the compatibility we are trying to test is unlikely to be
platform-specific.

If and when we ever add bug fixes or new features that will not work with old
gencode, we will need a way to exclude their tests from compatibility testing.
I believe that should be easy to handle by just putting something like
#[cfg(not(compatibility_test))] above the necessary test cases.

Ordinarily our protobuf_codegen crate will refuse to allow any mismatch
between the protoc version and runtime version, but I had to make an exception
so that it would allow us to have a mismatch for testing purposes. If the
ALLOW_PROTOC_VERSION_MISMATCH environment variable is set then the codegen
crate will not enforce that the versions match.

@copybara-service copybara-service bot force-pushed the test_816413950 branch 5 times, most recently from 02b4b53 to d177537 Compare October 8, 2025 17:00
…r runtime

This way this works is that we download our prebuilt protoc release binary and
put simple `MODULE.bazel` and `BUILD.bazel` files in front of it so that it
looks like a normal Bazel dependency. We can then run all our Cargo tests using
that protoc binary to generate code.

The nice thing about this approach is that it should require pretty minimal
maintenance going forward. Since we're not building the old protoc from source,
we don't have to worry about it bit-rotting and requiring new patches. Any time
we add new tests, those will also get picked up immediately, as long as they
are run with Cargo and not just Bazel.

One drawback is that this only works for Linux on x86-64, but this seems fine
since the compatibility we are trying to test is unlikely to be
platform-specific.

If and when we ever add bug fixes or new features that will not work with old
gencode, we will need a way to exclude their tests from compatibility testing.
I believe that should be easy to handle by just putting something like
`#[cfg(not(compatibility_test))]` above the necessary test cases.

Ordinarily our `protobuf_codegen` crate will refuse to allow any mismatch
between the protoc version and runtime version, but I had to make an exception
so that it would allow us to have a mismatch for testing purposes. If the
`ALLOW_PROTOC_VERSION_MISMATCH` environment variable is set then the codegen
crate will not enforce that the versions match.

PiperOrigin-RevId: 816413950
Copy link

Auto-closing Copybara pull request

@github-actions github-actions bot closed this Oct 15, 2025
@github-actions github-actions bot deleted the test_816413950 branch October 15, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants