-
Notifications
You must be signed in to change notification settings - Fork 54
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: generate showcase using docker image #3568
base: main
Are you sure you want to change the base?
Changes from all commits
f61c630
99c711f
7c0ed51
0328d96
c1d1696
bb28ae6
85201ee
cad57f6
bfc9bba
b4aa910
779d011
d29ce8c
334384a
66e7366
f0a7d53
072ee70
0214666
2f47daa
3063dab
e1c270a
1514dd7
6476131
4880451
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
googleapis_commitish: 3cef095370b3176f67542e527ffde81e019df091 | ||
# the libraries are ordered with respect to library name, which is | ||
# java-{library.library_name} or java-{library.api-shortname} when | ||
# library.library_name is not defined. | ||
# the libraries are ordered with respect to library name, which defaults to | ||
# {library.folder_name} or java-{library.library_name} or | ||
# java-{library.api-shortname} in sequence (i.e. if first is None, then try second and so on). | ||
libraries: | ||
- api_shortname: showcase | ||
folder_name: showcase # prevents java-showcase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel it is probably too much effort to introduce a new argument |
||
excluded_poms: gapic-showcase-bom | ||
name_pretty: Showcase | ||
api_description: Showcase module | ||
product_documentation: https://cloud.google.com/dummy | ||
distribution_name: com.google.cloud:gapic-showcase | ||
library_type: OTHER | ||
GAPICs: | ||
- proto_path: schema/google/showcase/v1beta1 | ||
- api_shortname: common-protos | ||
name_pretty: Common Protos | ||
product_documentation: https://github.com/googleapis/api-common-protos | ||
|
@@ -14,18 +24,18 @@ libraries: | |
excluded_poms: "proto-google-common-protos-bom,proto-google-common-protos" | ||
library_type: OTHER | ||
GAPICs: | ||
- proto_path: google/api | ||
- proto_path: google/apps/card/v1 | ||
- proto_path: google/cloud | ||
- proto_path: google/cloud/audit | ||
- proto_path: google/cloud/location | ||
- proto_path: google/geo/type | ||
- proto_path: google/logging/type | ||
- proto_path: google/longrunning | ||
- proto_path: google/rpc | ||
- proto_path: google/rpc/context | ||
- proto_path: google/shopping/type | ||
- proto_path: google/type | ||
- proto_path: google/api | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change intended? |
||
- proto_path: google/apps/card/v1 | ||
- proto_path: google/cloud | ||
- proto_path: google/cloud/audit | ||
- proto_path: google/cloud/location | ||
- proto_path: google/geo/type | ||
- proto_path: google/logging/type | ||
- proto_path: google/longrunning | ||
- proto_path: google/rpc | ||
- proto_path: google/rpc/context | ||
- proto_path: google/shopping/type | ||
- proto_path: google/type | ||
- api_shortname: iam | ||
name_pretty: IAM | ||
product_documentation: https://cloud.google.com/iam | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,24 +19,32 @@ | |
proto_library_pattern = r""" | ||
proto_library_with_info\( | ||
(.*?) | ||
\) | ||
\\?[\nn]\) | ||
""" | ||
gapic_pattern = r""" | ||
java_gapic_library\( | ||
(.*?) | ||
\) | ||
\\?[\nn]\) | ||
""" | ||
assembly_pattern = r""" | ||
java_gapic_assembly_gradle_pkg\( | ||
(.*?) | ||
\) | ||
\\?[\nn]\) | ||
""" | ||
# match a line which the first character is "#". | ||
comment_pattern = r"^\s*\#+" | ||
pattern_to_proto = { | ||
r"//google/cloud:common_resources_proto": "google/cloud/common_resources.proto", | ||
r"//google/cloud/location:location_proto": "google/cloud/location/locations.proto", | ||
r"//google/iam/v1:iam_policy_proto": "google/iam/v1/iam_policy.proto", | ||
# This pattern ignores api definitions that externally reference other repos. | ||
# For example: @googleapis_repo//google/cloud/... | ||
pattern_proto_library_to_additional_protos = { | ||
r".*//google/cloud:common_resources_proto": "google/cloud/common_resources.proto", | ||
r".*//google/cloud/location:location_proto": "google/cloud/location/locations.proto", | ||
r".*//google/iam/v1:iam_policy_proto": "google/iam/v1/iam_policy.proto", | ||
} | ||
# This is a special case for showcase, where the additional protos | ||
# are not declared in the gapic library instead | ||
pattern_gapic_library_to_additional_protos = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mind elaborating on why we need this special case? |
||
r".*//google/cloud/location:location_java_proto": "google/cloud/location/locations.proto", | ||
r".*//google/iam/v1:iam_java_proto": "google/iam/v1/iam_policy.proto", | ||
} | ||
transport_pattern = r"transport = \"(.*?)\"" | ||
rest_pattern = r"rest_numeric_enums = True" | ||
|
@@ -108,9 +116,8 @@ def parse_build_str(build_str: str, versioned_path: str) -> GapicInputs: | |
proto_library_pattern, re.DOTALL | re.VERBOSE | ||
).findall(build_str) | ||
additional_protos = "" | ||
if len(proto_library_target) > 0: | ||
additional_protos = __parse_additional_protos(proto_library_target[0]) | ||
gapic_target = re.compile(gapic_pattern, re.DOTALL | re.VERBOSE).findall(build_str) | ||
additional_protos = __parse_additional_protos(proto_library_target, gapic_target) | ||
assembly_target = re.compile(assembly_pattern, re.DOTALL | re.VERBOSE).findall( | ||
build_str | ||
) | ||
|
@@ -140,19 +147,42 @@ def parse_build_str(build_str: str, versioned_path: str) -> GapicInputs: | |
) | ||
|
||
|
||
def __parse_additional_protos(proto_library_target: str) -> str: | ||
res = [" "] | ||
lines = proto_library_target.split("\n") | ||
for line in lines: | ||
def __get_lines_without_comments(target: list[str]): | ||
""" | ||
skips comment lines | ||
""" | ||
if len(target) == 0: | ||
return [] | ||
result = [] | ||
for line in target[0].split("\n"): | ||
if len(re.findall(comment_pattern, line)) != 0: | ||
# skip a line which the first charactor is "#" since it's | ||
# skip lines whose first character is "#" since it's | ||
# a comment. | ||
continue | ||
for pattern in pattern_to_proto: | ||
result.append(line) | ||
return result | ||
|
||
|
||
def __parse_additional_protos( | ||
proto_library_target: list[str], gapic_library_target: list[str] | ||
) -> str: | ||
res = [" "] | ||
lines = __get_lines_without_comments(proto_library_target) | ||
# first, parse the proto library definition | ||
for line in lines: | ||
for pattern in pattern_proto_library_to_additional_protos: | ||
if len(re.findall(pattern, line)) == 0: | ||
continue | ||
res.append(pattern_proto_library_to_additional_protos[pattern]) | ||
# then, parse the gapic library definition | ||
lines = __get_lines_without_comments(gapic_library_target) | ||
for line in lines: | ||
for pattern in pattern_gapic_library_to_additional_protos: | ||
if len(re.findall(pattern, line)) == 0: | ||
continue | ||
res.append(pattern_to_proto[pattern]) | ||
return " ".join(res) | ||
res.append(pattern_gapic_library_to_additional_protos[pattern]) | ||
# finally, return the additional protos without duplicates | ||
return " ".join(list(dict.fromkeys(res))) | ||
|
||
|
||
def __parse_transport(gapic_target: str) -> str: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
java_gapic_library( | ||
deps = [ | ||
"//google/cloud/location:location_java_proto", | ||
"//google/iam/v1:iam_java_proto" | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
proto_library_with_info( | ||
# this comment should not indicate an end of a pattern match ) | ||
deps = [ | ||
"//google/cloud/location:location_proto", | ||
] | ||
) | ||
|
||
java_gapic_library( | ||
# this comment should not indicate an end of a pattern match ) | ||
deps = [ | ||
"//google/iam/v1:iam_java_proto" | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
deep-remove-regex: | ||
- "/showcase/grpc-gapic-showcase-v1beta1/src" | ||
- "/showcase/proto-gapic-showcase-v1beta1/src" | ||
- "/showcase/gapic-showcase/src" | ||
- "/showcase/samples/snippets/generated" | ||
|
||
deep-preserve-regex: | ||
- "/showcase/gapic-showcase/src/test" | ||
|
||
deep-copy-regex: | ||
- source: "/schema/google/showcase/(v.*)/.*-java/proto-.*/src" | ||
dest: "/owl-bot-staging/showcase/$1/proto-gapic-showcase-$1/src" | ||
- source: "/schema/google/showcase/(v.*)/.*-java/grpc-.*/src" | ||
dest: "/owl-bot-staging/showcase/$1/grpc-gapic-showcase-$1/src" | ||
- source: "/schema/google/showcase/(v.*)/.*-java/gapic-.*/src" | ||
dest: "/owl-bot-staging/showcase/$1/gapic-showcase/src" | ||
- source: "/schema/google/showcase/(v.*)/.*-java/samples/snippets/generated" | ||
dest: "/owl-bot-staging/showcase/$1/samples/snippets/generated" | ||
|
||
api-name: showcase |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"api_shortname": "showcase", | ||
"name_pretty": "Showcase", | ||
"product_documentation": "https://cloud.google.com/dummy", | ||
"api_description": "Showcase module", | ||
"client_documentation": "https://cloud.google.com/java/docs/reference/gapic-showcase/latest/overview", | ||
"release_level": "preview", | ||
"transport": "both", | ||
"language": "java", | ||
"repo": "googleapis/sdk-platform-java", | ||
"repo_short": "java-showcase", | ||
"distribution_name": "com.google.cloud:gapic-showcase", | ||
"library_type": "OTHER", | ||
"requires_billing": true, | ||
"excluded_poms": "gapic-showcase-bom" | ||
} |
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.
We probably do want to generate showcase automatically? For example, if we update protoc version in the docker image, we do want the showcase module to be updated.