Skip to content

Commit d4b2916

Browse files
suztomochingor13
andauthored
chore(java): add a note in README for migrated split repos (#1687)
* chore(java): add a note in README for migrated split repos Disable renovate bot and flaky bot for split repositories that have moved to the Java monorepo. The Java monorepo will pass the "monorepo=True" parameter to java.common_templates method in its owlbot.py files so that the migration note will not appear in the README in the monorepo. Co-authored-by: Jeff Ching <chingor@google.com>
1 parent e4969d0 commit d4b2916

File tree

9 files changed

+108
-9
lines changed

9 files changed

+108
-9
lines changed

docker/owlbot/java/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,38 @@ docker run --rm -v $(pwd):/workspace --user "$(id -u):$(id -g)" gcr.io/repo-auto
1919

2020
### Building the image
2121

22+
#### Local Docker
23+
24+
From the root of the synthtool repository, run:
25+
26+
```bash
27+
synthtool$ docker build -f docker/owlbot/java/Dockerfile .
28+
...
29+
Removing intermediate container e6d071e39d1b
30+
---> a7d7e0c80b00
31+
Successfully built a7d7e0c80b00
32+
```
33+
34+
"a7d7e0c80b00" is the ID of the container image build. Try running the
35+
postprocessor image with a target repository.
36+
Here is an example with java-aiplatform repository below:
37+
38+
```bash
39+
java-aiplatform$ git checkout -b test_postprocessor origin/main
40+
branch 'test_postprocessor' set up to track 'origin/main'.
41+
Switched to a new branch 'test_postprocessor'
42+
java-aiplatform$ docker run --rm -v $(pwd):/workspace a7d7e0c80b00
43+
...
44+
Reformatting source...
45+
...done
46+
java-aiplatform$ git diff
47+
... (shows the generated file differences) ...
48+
```
49+
50+
This manual confirmation identifies syntax errors in Python scripts and the
51+
templates.
52+
53+
#### Cloud Build
2254
This image is built via Cloud Build. From the root of this repository, run:
2355

2456
```bash
@@ -32,3 +64,21 @@ To rebuild the golden test fixtures:
3264
1. Delete the `golden` directory.
3365
2. Copy the `input` directory recursively to `golden`
3466
3. [Run the latest owlbot image](#running-locally) against the `golden` directory.
67+
68+
### Lint error
69+
70+
When you modify Python scripts, you may encounter lint errors
71+
Kokoro build:
72+
73+
```
74+
nox > black --check synthtool tests
75+
would reformat synthtool/languages/java.py
76+
77+
Oh no! 💥 💔 💥
78+
1 file would be reformatted, 78 files would be left unchanged.
79+
```
80+
81+
In this case, install [nox](https://nox.thea.codes/en/stable/) and run
82+
`nox -s lint` to reproduce the lint problems and `black synthtool` applies
83+
the suggested formatting.
84+

synthtool/gcp/templates/java_library/.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name: Bug report
33
about: Create a report to help us improve
44

55
---
6-
6+
{% if migrated_split_repo %}
7+
:bus: This library has moved to
8+
[google-cloud-java/{{ metadata['repo']['repo_short'] }}](
9+
https://github.com/googleapis/google-cloud-java/tree/main/{{ metadata['repo']['repo_short'] }}).
10+
This repository will be archived in the future.
11+
{% endif %}
712
Thanks for stopping by to let us know something could be better!
813

914
**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

synthtool/gcp/templates/java_library/.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ name: Feature request
33
about: Suggest an idea for this library
44

55
---
6-
6+
{% if migrated_split_repo %}
7+
:bus: This library has moved to
8+
[google-cloud-java/{{ metadata['repo']['repo_short'] }}](
9+
https://github.com/googleapis/google-cloud-java/tree/main/{{ metadata['repo']['repo_short'] }}).
10+
This repository will be archived in the future.
11+
{% endif %}
712
Thanks for stopping by to let us know something could be better!
813

914
**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.

synthtool/gcp/templates/java_library/.kokoro/nightly/integration.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env_vars: {
2323

2424
env_vars: {
2525
key: "ENABLE_FLAKYBOT"
26-
value: "true"
26+
value: {% if migrated_split_repo %}"false"{% else %}"true"{% endif %}
2727
}
2828

2929
env_vars: {

synthtool/gcp/templates/java_library/.kokoro/nightly/java11-integration.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ env_vars: {
2323

2424
env_vars: {
2525
key: "ENABLE_FLAKYBOT"
26-
value: "true"
26+
value: {% if migrated_split_repo %}"false"{% else %}"true"{% endif %}
2727
}
2828

2929
env_vars: {

synthtool/gcp/templates/java_library/.kokoro/nightly/samples.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ env_vars: {
3434

3535
env_vars: {
3636
key: "ENABLE_FLAKYBOT"
37-
value: "true"
37+
value: {% if migrated_split_repo %}"false"{% else %}"true"{% endif %}
3838
}

synthtool/gcp/templates/java_library/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ Java idiomatic client for [{{metadata['repo']['name_pretty']}}][product-docs].
1717
> Note: This client is a work-in-progress, and may occasionally
1818
> make backwards-incompatible changes.
1919
{% endif %}
20-
20+
{% if migrated_split_repo %}
21+
:bus: In October 2022, this library has moved to
22+
[google-cloud-java/{{ metadata['repo']['repo_short'] }}](
23+
https://github.com/googleapis/google-cloud-java/tree/main/{{ metadata['repo']['repo_short'] }}).
24+
This repository will be archived in the future.
25+
Future releases will appear in the new repository (https://github.com/googleapis/google-cloud-java/releases).
26+
The Maven artifact coordinates (`{{ group_id }}:{{ artifact_id }}`) remain the same.
27+
{% endif %}
2128
## Quickstart
2229

2330
{% if 'snippets' in metadata and metadata['snippets'][metadata['repo']['api_shortname'] + '_install_with_bom'] -%}

synthtool/gcp/templates/java_library/renovate.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
{
2-
"extends": [
1+
{% if migrated_split_repo %}{
2+
"enabled": false,
3+
{% else %}{
4+
{% endif %} "extends": [
35
":separateMajorReleases",
46
":combinePatchMinorReleases",
57
":ignoreUnstable",

synthtool/languages/java.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,37 @@ def common_templates(
484484
excludes (List[str], optional): List of template paths to ignore
485485
**kwargs: Additional options for CommonTemplates.java_library()
486486
"""
487-
kwargs["metadata"] = _common_template_metadata()
487+
metadata = _common_template_metadata()
488+
kwargs["metadata"] = metadata
489+
490+
# Generate flat to tell this repository is a split repo that have migrated
491+
# to monorepo. The owlbot.py in the monorepo sets monorepo=True.
492+
monorepo = kwargs.get("monorepo", False)
493+
split_repo = not monorepo
494+
repo_metadata = metadata["repo"]
495+
repo_short = repo_metadata["repo_short"]
496+
# Special libraries that are not GAPIC_AUTO but in the monorepo
497+
special_libs_in_monorepo = [
498+
"java-translate",
499+
"java-dns",
500+
"java-notification",
501+
"java-resourcemanager",
502+
]
503+
kwargs["migrated_split_repo"] = split_repo and (
504+
repo_metadata["library_type"] == "GAPIC_AUTO"
505+
or (repo_short and repo_short in special_libs_in_monorepo)
506+
)
507+
logger.info(
508+
"monorepo: {}, split_repo: {}, library_type: {},"
509+
" repo_short: {}, migrated_split_repo: {}".format(
510+
monorepo,
511+
split_repo,
512+
repo_metadata["library_type"],
513+
repo_short,
514+
kwargs["migrated_split_repo"],
515+
)
516+
)
517+
488518
templates = gcp.CommonTemplates(template_path=template_path).java_library(**kwargs)
489519

490520
# skip README generation on Kokoro (autosynth)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy