tests: Use fixed copyright year in tests.#4036
Conversation
Summary of ChangesHello @blakeli0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the robustness of the test suite by introducing a configurable copyright year for generated code. By allowing the copyright year to be set via an environment variable, particularly for tests, it ensures that test outcomes remain consistent and independent of the actual calendar year, thereby preventing potential test failures caused by year transitions. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to use a fixed copyright year for tests by using an environment variable. The changes in pom.xml set this environment variable for the test execution, and CommentComposer.java is updated to read this variable. This is a good approach for making tests deterministic.
I've added one comment with a suggestion to refactor the new getCurrentYear method to improve maintainability by extracting the magic string into a constant and to use the modern java.time API instead of Calendar.
...ator-java/src/main/java/com/google/api/generator/gapic/composer/comment/CommentComposer.java
Outdated
Show resolved
Hide resolved
This reverts commit 31c4de6.
...ator-java/src/main/java/com/google/api/generator/gapic/composer/comment/CommentComposer.java
Outdated
Show resolved
Hide resolved
gapic-generator-java/pom.xml
Outdated
| </additionalClasspathElement> | ||
| </additionalClasspathElements> | ||
| <environmentVariables> | ||
| <TEST_CURRENT_YEAR>2025</TEST_CURRENT_YEAR> |
There was a problem hiding this comment.
qq, would this override the value of an env var I set locally on my computer? Do you know which one has precendence?
If this takes precedence, maybe we can set this as a maven property so that we can configure this (if we need to ever test locally) with something like -DoverrideYear=YEAR
There was a problem hiding this comment.
Thanks for the suggestion! I made it a Maven property since it's generally a better practice. I tested that this override does take precedence.
.cloudbuild/library_generation/cloudbuild-library-generation-integration-test.yaml
Outdated
Show resolved
Hide resolved
zhumin8
left a comment
There was a problem hiding this comment.
LTGM. I'd be great if you could add a bit of documentation:
- Document this new env variable perhaps in https://github.com/googleapis/sdk-platform-java/blob/main/hermetic_build/README.md
- Make a note that env var does not apply to "Java generator golden integration tests" as you explained in the description, so this nuance is not lost.
I added more comments to CommentComposer, including nuances of the golden integration tests as well. |
|
|
This variable was removed in googleapis/sdk-platform-java#4036
#2660) * chore: Update generation configuration at Thu Jan 15 16:44:58 UTC 2026 * chore: remove usage of GOOD_LICENSE This variable was removed in googleapis/sdk-platform-java#4036 * chore: generate libraries at Thu Jan 15 16:59:29 UTC 2026 --------- Co-authored-by: Diego Marquez <[email protected]>
* chore: Update generation configuration at Thu Dec 4 02:36:21 UTC 2025 (#2616) * chore: add release-please config for protobuf-4.x (#2620) * chore: add release-please config for protobuf-4.x * chore: generate libraries at Wed Dec 3 19:03:35 UTC 2025 * Change release type from java-backport to java-yoshi * Refactor release-please.yml to remove redundancy Removed duplicate bumpMinorPreMajor setting for java-yoshi. --------- Co-authored-by: cloud-java-bot <[email protected]> * feat: Make v1 the default protocolVersion (#2623) * deps: update dependency com.google.cloud:google-cloud-bigquery to v2.56.0 (#2617) Co-authored-by: Mike Prieto <[email protected]> * chore(deps): update dependency com.google.cloud:libraries-bom to v26.72.0 (#2618) Co-authored-by: Mike Prieto <[email protected]> * chore: Update generation configuration at Thu Dec 11 02:39:02 UTC 2025 (#2621) * chore: Update generation configuration at Fri Dec 5 02:36:42 UTC 2025 * chore: Update generation configuration at Sat Dec 6 02:34:10 UTC 2025 * chore: generate libraries at Sat Dec 6 02:34:39 UTC 2025 * chore: Update generation configuration at Tue Dec 9 02:36:52 UTC 2025 * chore: Update generation configuration at Wed Dec 10 02:37:35 UTC 2025 * chore: Update generation configuration at Thu Dec 11 02:39:02 UTC 2025 * chore: generate libraries at Thu Dec 11 02:39:32 UTC 2025 * deps: update dependency com.google.protobuf:protobuf-java-util to v4.33.2 (#2625) * deps: update dependency com.google.cloud:google-cloud-core to v2.62.2 (#2632) * deps: update dependency com.google.cloud:sdk-platform-java-config to v3.54.2 (#2633) * deps: update actions/checkout action to v6 (#2619) Co-authored-by: Mike Prieto <[email protected]> * chore(main): release 1.143.2-SNAPSHOT (#2614) * chore(main): release 1.143.2-SNAPSHOT * chore: generate libraries at Thu Dec 11 20:10:46 UTC 2025 --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: cloud-java-bot <[email protected]> * chore(main): release 1.144.0 (#2635) * chore(main): release 1.144.0 * chore: generate libraries at Thu Dec 11 22:30:31 UTC 2025 --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: cloud-java-bot <[email protected]> * chore(main): release 1.144.1-SNAPSHOT (#2637) :robot: I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please). * fix: Lower the Subscriber protocol version to disable the streaming pull keepalive feature (#2652) * feat: Make v1 the default protocolVersion * fix: Lower the Subscriber protocol version to disable the streaming pull keepalive feature * fix: Downgrade streaming pull keepalive close stream log from WARNING to FINE * fix: Change from FINE to INFO for ping monitor stream closure log * chore(main): release 1.144.1 (#2654) * chore(main): release 1.144.1 * chore: generate libraries at Mon Dec 22 21:34:41 UTC 2025 --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: cloud-java-bot <[email protected]> * chore: cleanup release-please config (#2624) * chore: cleanup release-please config - Remove redundant options already declared at the top level.\n- Remove bumpMinorPreMajor for repositories after the first major release. * chore: format release-please.yml * deps: update googleapis/sdk-platform-java action to v2.65.1 (#2657) * deps: update dependency com.google.cloud:sdk-platform-java-config to v3.55.1 (#2658) * chore: Update generation configuration at Thu Jan 15 16:44:58 UTC 2026 (#2660) * chore: Update generation configuration at Thu Jan 15 16:44:58 UTC 2026 * chore: remove usage of GOOD_LICENSE This variable was removed in googleapis/sdk-platform-java#4036 * chore: generate libraries at Thu Jan 15 16:59:29 UTC 2026 --------- Co-authored-by: Diego Marquez <[email protected]> * chore(main): release 1.144.2-SNAPSHOT (#2655) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> * chore(main): release 1.145.0 (#2661) * chore(main): release 1.145.0 * chore: generate libraries at Thu Jan 15 19:49:21 UTC 2026 --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: cloud-java-bot <[email protected]> --------- Co-authored-by: cloud-java-bot <[email protected]> Co-authored-by: Diego Marquez <[email protected]> Co-authored-by: cloud-java-bot <[email protected]> Co-authored-by: Mike Prieto <[email protected]> Co-authored-by: Mend Renovate <[email protected]> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
The generator use the current year to generate copyright headers, so there are multiple tests failing when a new year comes. The general fix is to introduce an environment variable `TEST_CURRENT_YEAR` so that we can override it in tests. See below for the exact fix for each scenario: - Java generator golden unit tests - [Override it with Maven](https://github.com/googleapis/sdk-platform-java/blob/9ac79fc6c856a0b71111e28e2f69eeb0c01b4fc9/gapic-generator-java/pom.xml#L326-L328). - Java generator golden integration tests - Updated the golden files. These tests are generated from Bazel rules. Bazel builds are pretty hermetic and I couldn't find a way to override the environment variable. This is because the Bazel rule `java_gapic_library` [calls the generator](https://github.com/googleapis/sdk-platform-java/blob/b43f77c66d93d2423744d0f6d6a0a2a53a06e6d9/rules_java_gapic/java_gapic.bzl#L224-L235) through `proto_custom_library` which does not pass any environment variables. - Python hermetic build scripts unit tests. - Override it with [mocks](https://github.com/googleapis/sdk-platform-java/blob/9ac79fc6c856a0b71111e28e2f69eeb0c01b4fc9/hermetic_build/library_generation/tests/owlbot/java_unit_tests.py#L176). This requires a small refactoring in java.py. - Hermetic build scripts integration tests. - Changed these tests to non-required for now. These tests use a [hardcoded generator version](https://github.com/googleapis/sdk-platform-java/blob/b43f77c66d93d2423744d0f6d6a0a2a53a06e6d9/.cloudbuild/library_generation/cloudbuild-library-generation-integration-test.yaml#L69-L74) that does not recognize the environment variable. Once the generator is released, we can update the generator version and override the environment variable in CloudBuild yamls. - SpringCodeGen unit tests. - Once the generator is released, we can override the same environment variable with Maven in spring-cloud-gcp. Separately, updated zlib version in Bazel build because there is a known incompatibility between old zlib library and the latest macOS version. fixes: #3547 --------- Co-authored-by: cloud-java-bot <[email protected]>





The generator use the current year to generate copyright headers, so there are multiple tests failing when a new year comes. The general fix is to introduce an environment variable
TEST_CURRENT_YEARso that we can override it in tests. See below for the exact fix for each scenario:java_gapic_librarycalls the generator throughproto_custom_librarywhich does not pass any environment variables.Separately, updated zlib version in Bazel build because there is a known incompatibility between old zlib library and the latest macOS version.
fixes: #3547