-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: populate .repo-metadata.json
from highest version
#2890
feat: populate .repo-metadata.json
from highest version
#2890
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QQ, Don't we have .repo-metadata
golden files for our units? Maybe we can change one of these to test the proto_path sorting criteria
if len(self_dirs) != len(other_dirs): | ||
return len(self_dirs) < len(other_dirs) | ||
# otherwise, the one with higher version is smaller. | ||
return self_version > other_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit ignorant to string comparison in python. Is v2
greater than v1
because "2" has a higher ASCII value than "1"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is v2 greater than v1 because "2" has a higher ASCII value than "1"?
Yes.
I released that string comparison has a bug here: v10
is smaller than v2
. I'll change the algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -37,3 +38,29 @@ def test_get_library_returns_api_shortname(self): | |||
gapic_configs=list(), | |||
) | |||
self.assertEqual("secret", library.get_library_name()) | |||
|
|||
def test_get_sorted_gapic_configs_returns_correct_order(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a test for each of the scenario? [v1alpha1, v1], [v1, v2] etc. Because
- It would be much more readable. For example, just by reading the tests, I don't know why
v1alpha1, v1, v2, admin_v2, non_versioned, v1beta1
is sorted tov2, v1, admin_v2, v1beta1, v1alpha1, non_versioned
. - We can also easily test more scenarios. e.g. scenarios of two non versioned libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added unit tests to verify comparison result of two gapic_config
s.
I kept this test case though.
Quality Gate passed for 'gapic-generator-java-root'Issues Measures |
Quality Gate passed for 'java_showcase_integration_tests'Issues Measures |
The golden files are used in testing If we want to test generating this file with a |
🤖 I have created a release *beep* *boop* --- <details><summary>2.42.0</summary> ## [2.42.0](v2.41.0...v2.42.0) (2024-06-25) ### Features * Allow Adding Client Level Attributes to MetricsTracerFactory ([#2614](#2614)) ([f122c6f](f122c6f)) * gapic-generator-java to perform a no-op when no services are detected ([#2460](#2460)) ([c0b5646](c0b5646)) * Make Layout Parser generally available in V1 ([e508ae6](e508ae6)) * populate `.repo-metadata.json` from highest version ([#2890](#2890)) ([f587541](f587541)) * push SNAPSHOT versions of the hermetic build docker image ([#2888](#2888)) ([81df866](81df866)) ### Bug Fixes * **deps:** update the Java code generator (gapic-generator-java) to 1.2.3 ([e508ae6](e508ae6)) * Expose Gax meter name ([#2865](#2865)) ([6c5d6ce](6c5d6ce)) * Move the logic of getting systemProductName from static block to static method ([#2874](#2874)) ([536f1eb](536f1eb)) * Update default Otel Attribute from method_name to method ([#2833](#2833)) ([af10a9e](af10a9e)) ### Dependencies * update dependency com.google.auto.value:auto-value to v1.11.0 ([#2842](#2842)) ([dd27fdf](dd27fdf)) * update dependency com.google.auto.value:auto-value-annotations to v1.11.0 ([#2843](#2843)) ([bf8e67f](bf8e67f)) * update dependency com.google.cloud:grpc-gcp to v1.6.1 ([#2943](#2943)) ([9f16b40](9f16b40)) * update dependency org.checkerframework:checker-qual to v3.44.0 ([#2848](#2848)) ([7a99c50](7a99c50)) * update dependency org.easymock:easymock to v5.3.0 ([#2871](#2871)) ([c243f7d](c243f7d)) * update google api dependencies ([#2846](#2846)) ([b5ef698](b5ef698)) * update googleapis/java-cloud-bom digest to 17cc5ec ([#2882](#2882)) ([d6abd8e](d6abd8e)) * update netty dependencies to v4.1.111.final ([#2877](#2877)) ([b5f10b9](b5f10b9)) * update opentelemetry-java monorepo to v1.39.0 ([#2863](#2863)) ([9d1f3a8](9d1f3a8)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Joe Wang <joewa@google.com>
In this PR:
.repo-metadata.json
from highest stable version of proto paths.The
.repo-metadata.json
is only generated once per library and the first item in proto paths is used, so the proto paths with the highest stable version should be the first item after sorting the proto paths in the library.The method used to compare two proto paths,
a
andb
:a
andb
don't have a version, the one with lower depth is smaller.a
orb
has a version, the one with the version is smaller.a
orb
has a stable version, but not both, the one with the stable version is smaller, e.g.,google/spanner/v2
is smaller thangoogle/spanner/v3beta
.a
andb
have a non-stable version, the one with higher version is smaller, e.g.,google/spanner/v2beta1
is smaller thangoogle/spanner/v2alpha2
.a
andb
have a stable version, the one with lower depth is smaller, e.g.,google/spanner/v1
is smaller thangoogle/spanner/admin/v1
,google/spanner/v1
is smaller thangoogle/spanner/admin/v2
a
andb
have a stable version and the depth is the same, the one with higher version is smaller, e.g.,google/spanner/v2
is smaller thangoogle/spanner/v1
.Test the change:
Result:
transport
changed toboth
injava-iam/.repo-metadata.json
. This is expected since thetransport
ingoogle/iam/v2/BUILD.bazel
isgrpc+rest
. Without this change, thetransport
is parsed fromgoogle/iam/v2/BUILD.bazel
, which doesn't have ajava_gapic_library
target, thus the value isgrpc
by default.