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

feat: move new client script #2333

Merged
merged 47 commits into from
Jan 25, 2024
Merged

feat: move new client script #2333

merged 47 commits into from
Jan 25, 2024

Conversation

JoeWang1127
Copy link
Collaborator

@JoeWang1127 JoeWang1127 commented Jan 3, 2024

In this PR:

  • Migrate new-client.py from google-cloud-java, because we will be using new-client.py to other use cases than google-cloud-java repository, such as self-service client library generation.
  • Separate repo-level process script to library_generation/repo-level-postprocess

To verify new-client.py:

  1. pull the branch.
  2. pull the main branch of google-cloud-java.
  3. copy library_generation folder to root directory of google-cloud-java.
  4. in google-cloud-java, remove a newly added module, e.g., java-cloudquotas (PR).
  5. regenerate the module:
python library_generation/new_client/new-client.py generate --api_shortname=cloudquotas --proto-path=google/api/cloudquotas --name-pretty="Cloud Quotas API" --product-docs="https://cloud.google.com/cloudquotas/docs/" --api-description="Cloud Quotas API provides GCP service consumers with management and
    observability for resource usage, quotas, and restrictions of the services
    they consume."
  1. use git status and git diff to verify the difference.

This is part of milestone 2 of hermetic build project plan.

Note that I didn't test the script against split repositories because the main use case of this script is to generate a module in google-cloud-java.

@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Jan 3, 2024
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Jan 5, 2024
@JoeWang1127
Copy link
Collaborator Author

I don't like release managers need to specify this value. Is there a way not to specify this argument?

One option is add a release-please annotation so that the version num is the same as the latest release version.

@suztomo what do you think this idea.

@blakeli0
Copy link
Collaborator

I don't like release managers need to specify this value. Is there a way not to specify this argument?

One option is add a release-please annotation so that the version num is the same as the latest release version.

@suztomo what do you think this idea.

Also I want to note that this is a temporary solution, we will add a new section for a new client library in the generation_config.yaml in the future. So specifying a generator version looks fine to me, and I would prefer us not to optimize too much for a temporary solution if it takes more than like 30 minutes.

@suztomo
Copy link
Member

suztomo commented Jan 23, 2024

I agree that Release Please is overkill for this work. Here is the shell script to get the version:

# Temporary solution to get gapic-generator-java version until the configuration file is ready
$ V=$(curl --silent 'https://raw.githubusercontent.com/googleapis/googleapis/master/WORKSPACE' |perl -nle 'print $1 if m/_gapic_generator_java_version\s+=\s+\"(.+)\"/')
$ echo $V
2.32.0

@JoeWang1127
Copy link
Collaborator Author

I agree that Release Please is overkill for this work. Here is the shell script to get the version:

# Temporary solution to get gapic-generator-java version until the configuration file is ready
$ V=$(curl --silent 'https://raw.githubusercontent.com/googleapis/googleapis/master/WORKSPACE' |perl -nle 'print $1 if m/_gapic_generator_java_version\s+=\s+\"(.+)\"/')
$ echo $V
2.32.0

Thanks for the help.

versioned_path=versioned_proto_path,
)
repo_root_dir = Path(f"{sys.path[0]}/../../").resolve()
generator_version = subprocess.check_output(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version of generator is now parsed from WORKSPACE. This is a temporary fix so that release manager doesn't need to specify this value.

The plan is to use the version in config file later.


s.remove_staging_dirs()
{% if should_include_templates %}java.common_templates(monorepo=True, {% if template_excludes %}excludes=[
{%- for exclude in template_excludes %}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change template so that update_owlbot_postprocessor_config.sh is not needed.

templates.render(
template_name="bom_pom.xml.j2",
output_name=f"{artifact_id}-bom/pom.xml",
repo=repo_metadata["repo"],
name=name,
modules=modules,
main_module=main_module,
monorepo=monorepo,
monorepo_version=monorepo_version
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the template so that we can remove set_parent_pom.sh.

@@ -386,11 +399,12 @@ def main(versions_file, monorepo):
module=required_dependencies[path],
parent_module=parent_module,
main_module=main_module,
monorepo=monorepo,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the proto pom template to remove consolidate_config.sh.

Copy link
Member

@suztomo suztomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to see the observations that it works for shopping CSS.

@JoeWang1127
Copy link
Collaborator Author

JoeWang1127 commented Jan 24, 2024

Steps to regenerate shopping CSS:

  1. Checkout main branch of google-cloud-java and pull the latest change.
  2. Copy library_generation to google-cloud-java's root directory.
  3. Install python package:
python -m pip -r install library_generation/new_client/requirements.in
  1. Install google-cloud-java-jar-parent and google-cloud-bom-parent if they are SNAPSHOT version, since mvn fmt:format requires all parent poms are resolved.
  2. Remove shopping CSS module in google-cloud-java:
rm -rf java-shopping-css
  1. Run the generation command:
python library_generation/new_client/new-client.py generate --api_shortname="css" --proto-path="google/shopping/css" --name-pretty="CSS API" --product-docs="https://developers.google.com/comparison-shopping-services/api" --api-description="The CSS API is used to manage your CSS and control your CSS Products portfolio" --distribution-name="com.google.shopping:google-shopping-css" --destination-name=shopping-css
  1. Verify the difference: log.
    The difference of clirr-ignored-differences.xml should be fixed after cl/600749234 is propogated to google-cloud-java.

Copy link

Quality Gate Passed Quality Gate passed for 'gapic-generator-java-root'

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@suztomo
Copy link
Member

suztomo commented Jan 25, 2024

Verify the difference: log.

That looks good to me. Thank you.

@@ -477,52 +493,57 @@ def main(versions_file, monorepo):
update_bom_pom(f"{artifact_id}-bom/pom.xml", modules)
elif artifact_id+"-bom" not in excluded_poms_list:
print("creating missing bom pom.xml")
monorepo_version = __get_monorepo_version(versions_file) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may missed this in earlier reviews, can you please remind me why we need to get monorepo_version now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to generate the pom.xml in *-bom without using a repo-level post processing script (set_parent_pom.sh in this case) and run mvn fmt:format after the pom generation.

This requires to know the current version of gapic-libraries-bom and google-cloud-jar-parent, which is the same as the monorepo version.

@JoeWang1127 JoeWang1127 merged commit acdde47 into main Jan 25, 2024
46 checks passed
@JoeWang1127 JoeWang1127 deleted the feat/move-new-client-script branch January 25, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants