Skip to content
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

chore(java): add a note in README for migrated split repos #1687

Merged
merged 34 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4365858
chore: [java] add readme for migrated split repos
suztomo Oct 31, 2022
fc1aadf
fix tag
suztomo Oct 31, 2022
77a1b11
chore: removed irrelevant empty lines
suztomo Oct 31, 2022
ce7621f
reverted empty line deletion
suztomo Oct 31, 2022
ae8bd3c
remove unnecessary spaces
suztomo Oct 31, 2022
d8e5406
remove unnecessary new line
suztomo Oct 31, 2022
b0fc6ba
format
suztomo Oct 31, 2022
bdfc641
whitespace
suztomo Oct 31, 2022
87fabb2
whitespace
suztomo Oct 31, 2022
b77e482
format
suztomo Nov 1, 2022
58e06e3
issue templates
suztomo Nov 1, 2022
a110ba9
treatment for monorepo
suztomo Nov 1, 2022
e7df66d
negate in jinja2
suztomo Nov 1, 2022
bcc42fe
Merge remote-tracking branch 'origin/master' into java_monorepo_migra…
suztomo Nov 1, 2022
1b6809b
monorepo variable comment
suztomo Nov 1, 2022
a866416
split_repo flag
suztomo Nov 1, 2022
3668884
revert reature request template
suztomo Nov 1, 2022
4b61704
templating
suztomo Nov 1, 2022
812da6c
syntax fix
suztomo Nov 1, 2022
3007c14
format issue
suztomo Nov 1, 2022
e958b53
Merge remote-tracking branch 'origin/master' into java_monorepo_migra…
suztomo Nov 1, 2022
0b03d61
chore: remove my username
suztomo Nov 1, 2022
0e78ac7
refactor: created migrated_split_repo variable
suztomo Nov 1, 2022
f589e1d
format
suztomo Nov 1, 2022
3d1ed74
readme
suztomo Nov 1, 2022
1da3731
Merge branch 'master' into java_monorepo_migration_note
chingor13 Nov 1, 2022
106300a
Merge remote-tracking branch 'origin/master' into java_monorepo_migra…
suztomo Nov 2, 2022
89707ad
not to pass environment variable
suztomo Nov 2, 2022
c0716f4
get for dictionary
suztomo Nov 2, 2022
ba906ef
keyerror
suztomo Nov 2, 2022
b3946d4
negate monorepo
suztomo Nov 2, 2022
305dde4
Merge branch 'master' into java_monorepo_migration_note
suztomo Nov 4, 2022
528c020
Merge branch 'master' into java_monorepo_migration_note
suztomo Nov 4, 2022
f394051
Merge branch 'master' into java_monorepo_migration_note
suztomo Nov 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docker/owlbot/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,38 @@ docker run --rm -v $(pwd):/workspace --user "$(id -u):$(id -g)" gcr.io/repo-auto

### Building the image

#### Local Docker

From the root of the synthtool repository, run:

```bash
synthtool$ docker build -f docker/owlbot/java/Dockerfile .
...
Removing intermediate container e6d071e39d1b
---> a7d7e0c80b00
Successfully built a7d7e0c80b00
```

"a7d7e0c80b00" is the ID of the container image build. Try running the
postprocessor image with a target repository.
Here is an example with java-aiplatform repository below:

```bash
java-aiplatform$ git checkout -b test_postprocessor origin/main
branch 'test_postprocessor' set up to track 'origin/main'.
Switched to a new branch 'test_postprocessor'
java-aiplatform$ docker run --rm -v $(pwd):/workspace a7d7e0c80b00
...
Reformatting source...
...done
java-aiplatform$ git diff
... (shows the generated file differences) ...
```

This manual confirmation identifies syntax errors in Python scripts and the
templates.

#### Cloud Build
This image is built via Cloud Build. From the root of this repository, run:

```bash
Expand All @@ -32,3 +64,21 @@ To rebuild the golden test fixtures:
1. Delete the `golden` directory.
2. Copy the `input` directory recursively to `golden`
3. [Run the latest owlbot image](#running-locally) against the `golden` directory.

### Lint error

When you modify Python scripts, you may encounter lint errors
Kokoro build:

```
nox > black --check synthtool tests
would reformat synthtool/languages/java.py

Oh no! 💥 💔 💥
1 file would be reformatted, 78 files would be left unchanged.
```

In this case, install [nox](https://nox.thea.codes/en/stable/) and run
`nox -s lint` to reproduce the lint problems and `black synthtool` applies
the suggested formatting.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ name: Bug report
about: Create a report to help us improve

---

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

**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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ name: Feature request
about: Suggest an idea for this library

---

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

**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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env_vars: {

env_vars: {
key: "ENABLE_FLAKYBOT"
value: "true"
value: {% if migrated_split_repo %}"false"{% else %}"true"{% endif %}
}

env_vars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env_vars: {

env_vars: {
key: "ENABLE_FLAKYBOT"
value: "true"
value: {% if migrated_split_repo %}"false"{% else %}"true"{% endif %}
}

env_vars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ env_vars: {

env_vars: {
key: "ENABLE_FLAKYBOT"
value: "true"
value: {% if migrated_split_repo %}"false"{% else %}"true"{% endif %}
}
9 changes: 8 additions & 1 deletion synthtool/gcp/templates/java_library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ Java idiomatic client for [{{metadata['repo']['name_pretty']}}][product-docs].
> Note: This client is a work-in-progress, and may occasionally
> make backwards-incompatible changes.
{% endif %}

{% if migrated_split_repo %}
:bus: In October 2022, this library has moved to
[google-cloud-java/{{ metadata['repo']['repo_short'] }}](
https://github.com/googleapis/google-cloud-java/tree/main/{{ metadata['repo']['repo_short'] }}).
This repository will be archived in the future.
Future releases will appear in the new repository (https://github.com/googleapis/google-cloud-java/releases).
The Maven artifact coordinates (`{{ group_id }}:{{ artifact_id }}`) remain the same.
{% endif %}
## Quickstart

{% if 'snippets' in metadata and metadata['snippets'][metadata['repo']['api_shortname'] + '_install_with_bom'] -%}
Expand Down
6 changes: 4 additions & 2 deletions synthtool/gcp/templates/java_library/renovate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"extends": [
{% if migrated_split_repo %}{
"enabled": false,
{% else %}{
{% endif %} "extends": [
":separateMajorReleases",
":combinePatchMinorReleases",
":ignoreUnstable",
Expand Down
32 changes: 31 additions & 1 deletion synthtool/languages/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,37 @@ def common_templates(
excludes (List[str], optional): List of template paths to ignore
**kwargs: Additional options for CommonTemplates.java_library()
"""
kwargs["metadata"] = _common_template_metadata()
metadata = _common_template_metadata()
kwargs["metadata"] = metadata

# Generate flat to tell this repository is a split repo that have migrated
# to monorepo. The owlbot.py in the monorepo sets monorepo=True.
monorepo = kwargs.get("monorepo", False)
split_repo = not monorepo
repo_metadata = metadata["repo"]
repo_short = repo_metadata["repo_short"]
# Special libraries that are not GAPIC_AUTO but in the monorepo
special_libs_in_monorepo = [
"java-translate",
"java-dns",
"java-notification",
"java-resourcemanager",
]
kwargs["migrated_split_repo"] = split_repo and (
repo_metadata["library_type"] == "GAPIC_AUTO"
or (repo_short and repo_short in special_libs_in_monorepo)
)
logger.info(
"monorepo: {}, split_repo: {}, library_type: {},"
" repo_short: {}, migrated_split_repo: {}".format(
monorepo,
split_repo,
repo_metadata["library_type"],
repo_short,
kwargs["migrated_split_repo"],
)
)

templates = gcp.CommonTemplates(template_path=template_path).java_library(**kwargs)

# skip README generation on Kokoro (autosynth)
Expand Down