Skip to content

Commit edf46f4

Browse files
authored
Merge branch 'main' into renovate/googleapis-java-cloud-bom-digest
2 parents 3730dcd + 76a7b38 commit edf46f4

29 files changed

+293
-207
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ target/
2424
# library generation
2525
**/output/
2626
**/googleapis
27-
library_generation/test/**/golden*/
2827
library_generation/test/resources/test_monorepo_postprocessing/
2928
**/*egg-info/
3029
**/build/

java-shared-dependencies/third-party-dependencies/pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<google.cloud.opentelemetry.version>0.27.0</google.cloud.opentelemetry.version>
4141
<j2objc-annotations.version>3.0.0</j2objc-annotations.version>
4242
<opentelemetry.version>1.36.0</opentelemetry.version>
43+
<opentelemetry-grpc-instrumentation.version>2.1.0-alpha</opentelemetry-grpc-instrumentation.version>
4344
<flogger.version>0.8</flogger.version>
4445
<arrow.version>15.0.1</arrow.version>
4546
</properties>
@@ -126,6 +127,11 @@
126127
<artifactId>commons-codec</artifactId>
127128
<version>${codec.version}</version>
128129
</dependency>
130+
<dependency>
131+
<groupId>io.opentelemetry.instrumentation</groupId>
132+
<artifactId>opentelemetry-grpc-1.6</artifactId>
133+
<version>${opentelemetry-grpc-instrumentation.version}</version>
134+
</dependency>
129135

130136
<!-- TODO: replace with opencensus-bom when available -->
131137
<dependency>
@@ -190,4 +196,4 @@
190196
</dependency>
191197
</dependencies>
192198
</dependencyManagement>
193-
</project>
199+
</project>

library_generation/README.md

+30-24
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,24 @@ of versions.txt.
5555
For each module (e.g. `google-cloud-java/java-asset`), the following files/folders
5656
will be created/modified:
5757

58-
| Name | Notes |
59-
|:----------------------------|:-------------------------------------------------------------------------|
60-
| google-*/ | Source code generated by gapic-generator-java |
61-
| google-*/pom.xml | Only be generated if it does not exist |
62-
| grpc-*/ | Source code generated by grpc generator, one per each version |
63-
| grpc-*/pom.xml | Only be generated if it does not exist |
64-
| proto-*/ | Source code generated by Protobuf default compiler, one per each version |
65-
| proto-*/pom.xml | Only be generated if it does not exist |
66-
| samples/snippets/generated/ | Only be generated if `include_samples` is set to true |
67-
| google-*-bom/pom.xml | Library BOM, only be generated if it does not exist |
68-
| pom.xml | Library parent BOM, only be generated if it does not exist |
69-
| .repo-metadata.json | Always generated from inputs |
70-
| .OwlBot.yaml | Only be generated from a template if it does not exist |
71-
| owlbot.py | Only be generated from a template if it does not exist |
72-
| README.md | Always generated from inputs |
73-
| gapic-libraries-bom/pom.xml | Always generated from inputs |
74-
| pom.xml (repo root dir) | Always generated from inputs |
75-
| versions.txt | New entries will be added if they don’t exist |
58+
| Name | Notes |
59+
|:------------------------------------|:-------------------------------------------------------------------------|
60+
| google-*/ | Source code generated by gapic-generator-java |
61+
| google-*/pom.xml | Only be generated if it does not exist |
62+
| grpc-*/ | Source code generated by grpc generator, one per each version |
63+
| grpc-*/pom.xml | Only be generated if it does not exist |
64+
| proto-*/ | Source code generated by Protobuf default compiler, one per each version |
65+
| proto-*/pom.xml | Only be generated if it does not exist |
66+
| samples/snippets/generated/ | Only be generated if `include_samples` is set to true |
67+
| google-*-bom/pom.xml | Library BOM, only be generated if it does not exist |
68+
| pom.xml | Library parent BOM, only be generated if it does not exist |
69+
| .repo-metadata.json | Always generated from inputs |
70+
| .OwlBot-hermetic.yaml | Only be generated from a template if it does not exist |
71+
| owlbot.py | Only be generated from a template if it does not exist |
72+
| README.md | Always generated from inputs |
73+
| gapic-libraries-bom/pom.xml | Always generated from inputs |
74+
| pom.xml (repo root dir) | Always generated from inputs |
75+
| versions.txt | New entries will be added if they don’t exist |
7676

7777
### googleapis commit history
7878

@@ -97,6 +97,7 @@ They are shared by library level parameters.
9797
| protobuf_version | No | inferred from the generator if not specified |
9898
| grpc_version | No | inferred from the generator if not specified |
9999
| googleapis-commitish | Yes | |
100+
| libraries_bom_version | Yes | |
100101
| owlbot-cli-image | Yes | |
101102
| synthtool-commitish | Yes | |
102103
| template_excludes | Yes | |
@@ -147,6 +148,7 @@ The GAPIC level parameters define how to generate a GAPIC library.
147148
gapic_generator_version: 2.34.0
148149
protobuf_version: 25.2
149150
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
151+
libraries_bom_version: 26.37.0
150152
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
151153
synthtool_commitish: 6612ab8f3afcd5e292aecd647f0fa68812c9f5b5
152154
destination_path: google-cloud-java
@@ -192,11 +194,15 @@ libraries:
192194
193195
# Local Environment Setup before running `entry_point.py`
194196

195-
1. Assuming Python 3 is installed, follow official guide from [Python.org](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) to create a virtual environment. The virtual environment can be installed to any folder, usually it is recommended to be installed under the root folder of the project(`sdk-platform-java` in this case).
196-
2. Assuming the virtual environment is installed under `sdk-platform-java`. Run the following command under the root folder of `sdk-platform-java` to install the dependencies of `library_generation`
197+
1. Assuming Python 3 is installed, follow official guide from [Python.org](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) to create a virtual environment.
198+
The virtual environment can be installed to any folder, usually it is recommended to be installed under the root folder of the project(`sdk-platform-java` in this case).
199+
2. Assuming the virtual environment is installed under `sdk-platform-java`.
200+
Run the following command under the root folder of `sdk-platform-java` to install the dependencies of `library_generation`
201+
197202
```bash
198203
python -m pip install -r library_generation/requirements.txt
199204
```
205+
200206
3. Run the following command to install `library_generation` as a module, which allows the `library_generation` module to be imported from anywhere
201207
```bash
202208
python -m pip install library_generation/
@@ -206,8 +212,8 @@ python -m pip install library_generation/
206212

207213
```bash
208214
python library_generation/entry_point.py generate \
209-
--baseline-generation-config=/path/to/baseline_config_file \
210-
--current-generation-config=/path/to/current_config_file \
215+
--baseline-generation-config-path=/path/to/baseline_config_file \
216+
--current-generation-config-path=/path/to/current_config_file \
211217
--repository-path=path/to/repository
212218
```
213219
If you run `entry_point.py` with the example [configuration](#an-example-of-generation-configuration)
@@ -231,7 +237,7 @@ $repository_path
231237
| |_samples
232238
| | |_snippets
233239
| | | |_generated
234-
| |_.OwlBot.yaml
240+
| |_.OwlBot-hermetic.yaml
235241
| |_.repo-metadata.json
236242
| |_owlbot.py
237243
| |_pom.xml
@@ -275,7 +281,7 @@ $repository_path
275281
| |_samples
276282
| | |_snippets
277283
| | | |_generated
278-
| |_.OwlBot.yaml
284+
| |_.OwlBot-hermetic.yaml
279285
| |_.repo-metadata.json
280286
| |_owlbot.py
281287
| |_pom.xml

library_generation/cli/entry_point.py

+21-18
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main(ctx):
2929

3030
@main.command()
3131
@click.option(
32-
"--baseline-generation-config",
32+
"--baseline-generation-config-path",
3333
required=False,
3434
default=None,
3535
type=str,
@@ -40,7 +40,7 @@ def main(ctx):
4040
""",
4141
)
4242
@click.option(
43-
"--current-generation-config",
43+
"--current-generation-config-path",
4444
required=False,
4545
default=None,
4646
type=str,
@@ -62,8 +62,8 @@ def main(ctx):
6262
""",
6363
)
6464
def generate(
65-
baseline_generation_config: str,
66-
current_generation_config: str,
65+
baseline_generation_config_path: str,
66+
current_generation_config_path: str,
6767
repository_path: str,
6868
):
6969
"""
@@ -87,47 +87,50 @@ def generate(
8787
The commit history, if generated, will be available in
8888
repository_path/pr_description.txt.
8989
"""
90-
default_generation_config = f"{os.getcwd()}/generation_config.yaml"
90+
default_generation_config_path = f"{os.getcwd()}/generation_config.yaml"
9191

92-
if baseline_generation_config is None and current_generation_config is None:
93-
if not os.path.isfile(default_generation_config):
92+
if (
93+
baseline_generation_config_path is None
94+
and current_generation_config_path is None
95+
):
96+
if not os.path.isfile(default_generation_config_path):
9497
raise FileNotFoundError(
95-
f"{default_generation_config} does not exist. "
98+
f"{default_generation_config_path} does not exist. "
9699
"A valid generation config has to be passed in as "
97100
"current_generation_config or exist in the current working "
98101
"directory."
99102
)
100-
current_generation_config = default_generation_config
101-
elif current_generation_config is None:
103+
current_generation_config_path = default_generation_config_path
104+
elif current_generation_config_path is None:
102105
raise FileNotFoundError(
103106
"current_generation_config is not specified when "
104107
"baseline_generation_config is specified. "
105108
"current_generation_config should be the source of truth of "
106109
"library generation."
107110
)
108111

109-
current_generation_config = os.path.abspath(current_generation_config)
112+
current_generation_config_path = os.path.abspath(current_generation_config_path)
110113
repository_path = os.path.abspath(repository_path)
111-
if not baseline_generation_config:
114+
if not baseline_generation_config_path:
112115
# Execute full generation based on current_generation_config if
113116
# baseline_generation_config is not specified.
114117
# Do not generate pull request description.
115118
generate_from_yaml(
116-
config_path=current_generation_config,
117-
config=from_yaml(current_generation_config),
119+
config_path=current_generation_config_path,
120+
config=from_yaml(current_generation_config_path),
118121
repository_path=repository_path,
119122
)
120123
return
121124

122125
# Compare two generation configs and only generate changed libraries.
123126
# Generate pull request description.
124-
baseline_generation_config = os.path.abspath(baseline_generation_config)
127+
baseline_generation_config_path = os.path.abspath(baseline_generation_config_path)
125128
config_change = compare_config(
126-
baseline_config=from_yaml(baseline_generation_config),
127-
current_config=from_yaml(current_generation_config),
129+
baseline_config=from_yaml(baseline_generation_config_path),
130+
current_config=from_yaml(current_generation_config_path),
128131
)
129132
generate_from_yaml(
130-
config_path=current_generation_config,
133+
config_path=current_generation_config_path,
131134
config=config_change.current_config,
132135
repository_path=repository_path,
133136
target_library_names=config_change.get_changed_libraries(),

library_generation/generate_composed_library.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def generate_composed_library(
7272
build_file_folder = Path(f"{output_folder}/{gapic.proto_path}").resolve()
7373
print(f"build_file_folder: {build_file_folder}")
7474
gapic_inputs = parse_build_file(build_file_folder, gapic.proto_path)
75-
# generate prerequisite files (.repo-metadata.json, .OwlBot.yaml,
75+
# generate prerequisite files (.repo-metadata.json, .OwlBot-hermetic.yaml,
7676
# owlbot.py) here because transport is parsed from BUILD.bazel,
7777
# which lives in a versioned proto_path.
7878
util.generate_prerequisite_files(

library_generation/generate_pr_description.py

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def generate_pr_descriptions(
7979
The pull request description will be generated into
8080
description_path/pr_description.txt.
8181
82+
If baseline_commit is the same as googleapis commit in the given generation
83+
config, no pr_description.txt will be generated.
84+
8285
:param config: a GenerationConfig object. The googleapis commit in this
8386
configuration is the latest commit, inclusively, from which the commit
8487
message is considered.
@@ -90,6 +93,9 @@ def generate_pr_descriptions(
9093
:param repo_url: the GitHub repository from which retrieves the commit
9194
history.
9295
"""
96+
if baseline_commit == config.googleapis_commitish:
97+
return
98+
9399
paths = config.get_proto_path_to_library_name()
94100
description = get_commit_messages(
95101
repo_url=repo_url,
@@ -126,6 +132,8 @@ def get_commit_messages(
126132
:param paths: a mapping from file paths to library_name.
127133
:param is_monorepo: whether to generate commit messages in a monorepo.
128134
:return: commit messages.
135+
:raise ValueError: if current_commit is older than or equal to
136+
baseline_commit.
129137
"""
130138
tmp_dir = "/tmp/repo"
131139
shutil.rmtree(tmp_dir, ignore_errors=True)

library_generation/model/generation_config.py

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
self,
3030
gapic_generator_version: str,
3131
googleapis_commitish: str,
32+
libraries_bom_version: str,
3233
owlbot_cli_image: str,
3334
synthtool_commitish: str,
3435
template_excludes: List[str],
@@ -38,6 +39,7 @@ def __init__(
3839
):
3940
self.gapic_generator_version = gapic_generator_version
4041
self.googleapis_commitish = googleapis_commitish
42+
self.libraris_bom_version = libraries_bom_version
4143
self.owlbot_cli_image = owlbot_cli_image
4244
self.synthtool_commitish = synthtool_commitish
4345
self.template_excludes = template_excludes
@@ -116,6 +118,7 @@ def from_yaml(path_to_yaml: str) -> GenerationConfig:
116118
grpc_version=__optional(config, "grpc_version", None),
117119
protobuf_version=__optional(config, "protobuf_version", None),
118120
googleapis_commitish=__required(config, "googleapis_commitish"),
121+
libraries_bom_version=__required(config, "libraries_bom_version"),
119122
owlbot_cli_image=__required(config, "owlbot_cli_image"),
120123
synthtool_commitish=__required(config, "synthtool_commitish"),
121124
template_excludes=__required(config, "template_excludes"),

library_generation/owlbot/bin/entrypoint.sh

+4-13
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,10 @@ set -ex
2727
scripts_root=$1
2828
versions_file=$2
2929
configuration_yaml=$3
30+
is_monorepo=$4
3031

3132

32-
# This script can be used to process HW libraries and monorepo
33-
# (google-cloud-java) libraries, which require a slightly different treatment
34-
# monorepo folders have an .OwlBot.yaml file in the module folder (e.g.
35-
# java-asset/.OwlBot.yaml), whereas HW libraries have the yaml in
36-
# `.github/.OwlBot.yaml`
37-
monorepo="false"
38-
if [[ -f "$(pwd)/.OwlBot.yaml" ]]; then
39-
monorepo="true"
40-
fi
41-
42-
if [[ "${monorepo}" == "true" ]]; then
33+
if [[ "${is_monorepo}" == "true" ]]; then
4334
mv owl-bot-staging/* temp
4435
rm -rd owl-bot-staging/
4536
mv temp owl-bot-staging
@@ -50,7 +41,7 @@ fi
5041

5142
# apply repo templates
5243
echo "Rendering templates"
53-
python3 "${scripts_root}/owlbot/src/apply_repo_templates.py" "${configuration_yaml}" "${monorepo}"
44+
python3 "${scripts_root}/owlbot/src/apply_repo_templates.py" "${configuration_yaml}" "${is_monorepo}"
5445

5546
# templates as well as retrieving files from owl-bot-staging
5647
echo "Retrieving files from owl-bot-staging directory..."
@@ -66,7 +57,7 @@ echo "...done"
6657

6758
# write or restore pom.xml files
6859
echo "Generating missing pom.xml..."
69-
python3 "${scripts_root}/owlbot/src/fix-poms.py" "${versions_file}" "${monorepo}"
60+
python3 "${scripts_root}/owlbot/src/fix-poms.py" "${versions_file}" "${is_monorepo}"
7061
echo "...done"
7162

7263
# write or restore clirr-ignored-differences.xml

library_generation/owlbot/src/apply_repo_templates.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def apply_repo_templates(configuration_yaml_path: str, monorepo: bool) -> None:
2424
excludes=config.template_excludes,
2525
template_path=Path(repo_templates_path),
2626
monorepo=monorepo,
27+
libraries_bom_version=config.libraris_bom_version,
2728
)
2829

2930

library_generation/owlbot/templates/java_library/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
4444
<dependency>
4545
<groupId>com.google.cloud</groupId>
4646
<artifactId>libraries-bom</artifactId>
47-
<version>{{ metadata['latest_bom_version'] }}</version>
47+
<version>{{ metadata['libraries_bom_version'] }}</version>
4848
<type>pom</type>
4949
<scope>import</scope>
5050
</dependency>

0 commit comments

Comments
 (0)