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: Add code request generator dumper and an ability to run generator from dumped file #765

Merged
merged 7 commits into from
Jun 16, 2021

Conversation

vam-google
Copy link
Contributor

For debugging purposes.

Usage example:

load("@gapic_generator_java//rules_java_gapic:java_gapic.bzl", "java_generator_request_dump")
java_generator_request_dump(
    name = "compute_small_request_dump",
    srcs = [":compute_small_proto_with_info"],
    transport = "rest",
)

@vam-google vam-google requested review from miraleung and a team as code owners June 11, 2021 09:09
@snippet-bot
Copy link

snippet-bot bot commented Jun 11, 2021

No region tags are edited in this PR.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 11, 2021
@codecov
Copy link

codecov bot commented Jun 11, 2021

Codecov Report

Merging #765 (4813464) into master (b7d9399) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #765   +/-   ##
=======================================
  Coverage   91.71%   91.71%           
=======================================
  Files         140      140           
  Lines       14794    14794           
  Branches     1052     1052           
=======================================
  Hits        13568    13568           
  Misses        942      942           
  Partials      284      284           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b7d9399...4813464. Read the comment docs.

Copy link
Contributor

@miraleung miraleung left a comment

Choose a reason for hiding this comment

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

I came across #767 first, so I left some comments on these files in there.

@vam-google
Copy link
Contributor Author

@miraleung The plan was to review just this one first, merge it and then I could easily merge that into the #767.

@@ -45,6 +45,34 @@ java_binary(
],
)

java_binary(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@miraleung (from #767): Nit: Can we add a summary comment above these two rules, which also indicate these are debugging tools?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are not rules, these are java_binaries used by one of the rules only. I clarified the purpose of the binaries in the comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the comments. Could we copy-paste these into the Java src files as well? Up to you whether to replace these comments with a pointer to the Java source, or leave these as they are.

Could we also add a usage example? Up to you whether that goes here or in the Java source comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
import java.io.IOException;

public class CodeGeneratorRequestDumper {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@miraleung (from #767): If we're using Main in the class names, could we append it here for consistency? Alternatively, remove Main from the other debugger's main class's name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are different things basically. The MainFromFile is literally another variation of the Main class. This, on the other hand, is a very different class, doing different thing. That is why they are named differently. And strictly speaking, this file is really very-very non-main =)

I.e. this class is not really related to Main, while the other one is.

Either way, if you have preferrence how to name these classes, please let me know and I'll rename them. For now, those were the best names I could come up with.

Copy link
Contributor

Choose a reason for hiding this comment

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

MainStandalone could be something like CodeGeneratorRequestFileToGapicMain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed

import java.io.InputStream;
import java.io.OutputStream;

public class MainFromFile {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@miraleung (from #767): Could we give this a more descriptive name, e.g. GapicToFileMain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll rename. WDYT about naming the Main class to GapicMain also?

About the GapicToFileMain class, I think that would misrepresent what this class does. Its main difference is that it reads/writes from files directly, instead of relying on protoc. I renamed it to MainStandalone (I can add Gapic in name, but in that case we would need to have that prefix in Main class as well, let me know if you want me to do that)

@vam-google
Copy link
Contributor Author

@miraleung I've migrated your comments from the other PR here. Please if anything like this happens, just let me know you prefer a PR to be rebased, so I can rebase it first and then we can continue with the review. Otherwise it generates a lot of unnecessary work for both of us (like migrating these comments).

vam-google added a commit to vam-google/gapic-generator-java that referenced this pull request Jun 14, 2021
@vam-google
Copy link
Contributor Author

@miraleung PTAL

1 similar comment
@vam-google
Copy link
Contributor Author

@miraleung PTAL

Copy link
Contributor

@miraleung miraleung left a comment

Choose a reason for hiding this comment

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

LGTM with comments addressed.

import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
import java.io.IOException;

public class CodeGeneratorRequestDumper {
Copy link
Contributor

Choose a reason for hiding this comment

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

MainStandalone could be something like CodeGeneratorRequestFileToGapicMain?

@@ -45,6 +45,34 @@ java_binary(
],
)

java_binary(
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the comments. Could we copy-paste these into the Java src files as well? Up to you whether to replace these comments with a pointer to the Java source, or leave these as they are.

Could we also add a usage example? Up to you whether that goes here or in the Java source comments.

@vam-google vam-google merged commit 4f187b1 into googleapis:master Jun 16, 2021
suztomo pushed a commit that referenced this pull request Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


### Updating meta-information for bleeding-edge SNAPSHOT release.

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
suztomo pushed a commit that referenced this pull request Mar 21, 2023
….6.0 (#765)

[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [com.google.auth:google-auth-library-bom](https://togithub.com/googleapis/google-auth-library-java) | `1.5.3` -> `1.6.0` | [![age](https://badges.renovateapi.com/packages/maven/com.google.auth:google-auth-library-bom/1.6.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.auth:google-auth-library-bom/1.6.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.auth:google-auth-library-bom/1.6.0/compatibility-slim/1.5.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.auth:google-auth-library-bom/1.6.0/confidence-slim/1.5.3)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants