Skip to content

fix(hermetic-build): prevent overwrite of Version.java in new libraries'#12742

Merged
diegomarquezp merged 3 commits intomainfrom
fix/version-java-template
Apr 10, 2026
Merged

fix(hermetic-build): prevent overwrite of Version.java in new libraries'#12742
diegomarquezp merged 3 commits intomainfrom
fix/version-java-template

Conversation

@diegomarquezp
Copy link
Copy Markdown
Contributor

@diegomarquezp diegomarquezp commented Apr 10, 2026

Applies changes found to work in 59581ef

@diegomarquezp diegomarquezp requested a review from a team as a code owner April 10, 2026 12:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request generalizes the path for preserving Version.java in OwlBot configurations by replacing specific module names with a wildcard regex. However, this introduces an inconsistency with the preservation pattern for integration tests, which still uses specific module names. It is recommended to update the integration test patterns to match the new generalized approach to ensure consistency and prevent potential build issues where integration tests might be incorrectly overwritten.

deep-preserve-regex:
- "/{{ module_name }}/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java"
- "/{{ module_name }}/google-.*/src/main/java/com/google/cloud/.*/v.*/stub/Version.java"
- "/.*google-.*/src/main/java/com/google/cloud/.*/v.*/stub/Version.java"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The generalization of the path to use .* instead of {{ module_name }} for Version.java introduces an inconsistency with the integration tests pattern on line 23, which still uses the specific {{ module_name }}. If the goal is to support libraries where the directory structure might not strictly match {{ module_name }}, or to provide a more generic template for the monorepo, line 23 should also be updated to use .*. Otherwise, integration tests for these libraries may be incorrectly overwritten during the build process.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to new files being introduced to match the owl-bot-staging/v.* prefix.

Copy link
Copy Markdown
Contributor Author

@diegomarquezp diegomarquezp Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the integration tests do not need this pattern because ITs are not generated, so only a pattern that prevents removal is necessary.
On the other hand Version.java is both preserved and generated, where the existing Version.java needs a different pattern than the one about to be transferred (i.e. owl-bot-staging/...), so we need a more relaxed pattern.

deep-preserve-regex:
- "/java-bare-metal-solution/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java"
- "/java-bare-metal-solution/google-.*/src/main/java/com/google/cloud/.*/v.*/stub/Version.java"
- "/.*google-.*/src/main/java/com/google/cloud/.*/v.*/stub/Version.java"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This golden file now contains an inconsistent preservation policy: Version.java is preserved using a generic regex, while integration tests (line 23) are still tied to the specific java-bare-metal-solution path. This should be updated to match the generalized pattern if the intention is for the configuration to be library-agnostic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to new files being introduced to match the owl-bot-staging/v.* prefix.

Copy link
Copy Markdown
Contributor Author

@diegomarquezp diegomarquezp Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the integration tests do not need this pattern because ITs are not generated, so only a pattern that prevents removal is necessary.
On the other hand Version.java is both preserved and generated, where the existing Version.java needs a different pattern than the one about to be transferred (i.e. owl-bot-staging/...), so we need a more relaxed pattern.

@diegomarquezp diegomarquezp marked this pull request as draft April 10, 2026 15:33
@diegomarquezp diegomarquezp marked this pull request as ready for review April 10, 2026 15:58
@diegomarquezp diegomarquezp merged commit 3bcca8e into main Apr 10, 2026
86 of 96 checks passed
@diegomarquezp diegomarquezp deleted the fix/version-java-template branch April 10, 2026 16:41
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.

2 participants