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: write samples to file (pt3) #980

Merged
merged 21 commits into from
Apr 28, 2022
Merged

feat: write samples to file (pt3) #980

merged 21 commits into from
Apr 28, 2022

Conversation

eaball35
Copy link
Contributor

@eaball35 eaball35 commented Apr 5, 2022

go/java-sample-gen - see 'Post gapic-generator-java' section

Can easily include/not include generated samples - plan to roll out to a few before rolling out everywhere. This change won't automatically start generating samples in repos. To do so:

  • googleapis libs BUILD.bazels 'java_gapic_assembly_gradle_pkg' needs to include ":lib_java_gapic_samples" in deps
  • need to update repos OwlBot.yaml to copy 'samples/snippets/generated'

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Apr 5, 2022
@snippet-bot
Copy link

snippet-bot bot commented Apr 5, 2022

Here is the summary of possible violations 😱

There are 221 possible violations for not having product prefix.

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

@eaball35 eaball35 marked this pull request as ready for review April 15, 2022 02:19
@eaball35 eaball35 requested review from a team as code owners April 15, 2022 02:19
@eaball35 eaball35 requested a review from blakeli0 April 15, 2022 20:43
@@ -186,6 +188,40 @@ public static List<GapicClass> generateTestClasses(GapicContext context) {
return clazzes;
}

@VisibleForTesting
static List<GapicClass> composeSamples(List<GapicClass> clazzes, String protoPackage) {
Copy link
Collaborator

@blakeli0 blakeli0 Apr 26, 2022

Choose a reason for hiding this comment

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

This method is basically adding region tags and headers to all samples in all classes, which should probably be renamed as well. But before you do that, I have a basic question regarding why we want to do it here after samples are already mostly composed? The package info is already in the context which is passes into generateServiceClasses, so potentially we should be able to generate a full Sample in previous steps right?

Copy link
Contributor Author

@eaball35 eaball35 Apr 26, 2022

Choose a reason for hiding this comment

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

Before this step, we can generate an inline sample but not an "executable" one because inline format doesn't need a proper region tag or license. Looking at composeServiceClasses called in Generator before Writer I could parse shortname/version out before or start of composeServiceClasses() and keep passing these details around when creating Samples or I can add these details before writing the files as I'm doing. I already am iterating over the samples to add the license header here and these details aren't needed before this step.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, it's unfortunate these info are not easily accessible and you have to pass them around. I have some refactoring ideas but should definitely not be the scope of this PR. For now, can you please rename this method to make more readable/precise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense and I agree it's not ideal, assuming the behaviors won't change I can test this out overall and refactor in parallel.

done, I renamed to make more readable

@eaball35 eaball35 requested a review from blakeli0 April 26, 2022 21:24
@blakeli0
Copy link
Collaborator

Overall looks really good. Just have one additional comment that is not directly related to this PR, can you please add more comments/Javadoc to the new model classes you added in pt1 and pt2? Especially Sample.java and RegionTag.java? I know not every model class have Javadocs currently and I should've done a better job in reviewing those earlier as well, but they would benefit new people in our team greatly.

@eaball35 eaball35 closed this Apr 27, 2022
@eaball35 eaball35 reopened this Apr 27, 2022
@sonarcloud
Copy link

sonarcloud bot commented Apr 27, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 12 Code Smells

24.3% 24.3% Coverage
0.0% 0.0% Duplication

@eaball35 eaball35 merged commit 04a6665 into main Apr 28, 2022
@eaball35 eaball35 deleted the samplegen3 branch April 28, 2022 16:49
suztomo pushed a commit that referenced this pull request Dec 16, 2022
* feat: write to files

* test: update test scripts

* test: goldens

* feat: sample src jar

* feat: package tar with samples

* refactor: sample class and file names should match

* test: unit goldens

* test: golden IT

* refactor: keep samples seperate from gapic jar

* test: ComposerTest

* formatting

* fix test

* refactor: updateSample naming

* refactor: include cause with GapicWriterException

* ignore test files in snippetbot check

* update composeSamples name

* include javadoc comments

* formatting
suztomo pushed a commit that referenced this pull request Mar 21, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [org.easymock:easymock](http://easymock.org) ([source](https://togithub.com/easymock/easymock)) | `4.3` -> `5.0.1` | [![age](https://badges.renovateapi.com/packages/maven/org.easymock:easymock/5.0.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.easymock:easymock/5.0.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.easymock:easymock/5.0.1/compatibility-slim/4.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.easymock:easymock/5.0.1/confidence-slim/4.3)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - 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 [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMzcuMCIsInVwZGF0ZWRJblZlciI6IjMyLjI0MS4xMSJ9-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants