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

GHRepository.createCheckRun #753

Merged
merged 27 commits into from
Mar 30, 2020
Merged

GHRepository.createCheckRun #753

merged 27 commits into from
Mar 30, 2020

Conversation

jglick
Copy link
Contributor

@jglick jglick commented Mar 25, 2020

Description

Continues #723 & #740 to create a check run. Partially addresses #520.

I am leery of building this on top of #724, which I can barely understand but anyway does not feel appropriate here since for example a GHCheckRun is not a complete model object: it has an Output nested object with an annotationsCount & annotationsUrl but there is not currently any separate model for the actual annotation data. Some sort of builder pattern is needed, but I find the style used here (inspired by GHPullRequestReviewBuilder) more intuitive and straightforward and it is clear what Java method actually corresponds to the REST call.

Before submitting a PR:

  • Push your changes to a branch other than master. Create your PR from that branch.
  • Add JavaDocs and other comments
  • Write tests that run and pass in CI. See CONTRIBUTING.md for details on how to capture snapshot data.
  • Run mvn -D enable-ci clean install site locally. This may reformat your code, commit those changes. If this command doesn't succeed, your change will not pass CI.

@XiongKezhi
Copy link
Contributor

Do we also need another updateCheckRun method for this here? They are almost the same except for the URL and request method.

@jglick
Copy link
Contributor Author

jglick commented Mar 25, 2020

Do we also need another updateCheckRun method

Yes, could be added as well. AFAICT it is not a top priority since “creating” a run with the same name as an existing one effectively overwrites it.

@jglick jglick marked this pull request as ready for review March 26, 2020 20:44
@jglick jglick mentioned this pull request Mar 26, 2020
4 tasks
}

/**
* Drafts an action section.
Copy link
Member

Choose a reason for hiding this comment

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

Add links to the pertinent GitHub docs, such as https://developer.github.com/v3/checks/runs/#actions-object.

Copy link
Member

Choose a reason for hiding this comment

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

There's a maximum of three actions allowed. But the GitHub docs do not make it clear what happens when actions are exceeded. We should at least mention the limit here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As elsewhere, I think it is pointless to even mention these sorts of limitations in Javadoc here, as the limits could be changed at any time and the code in this repository would become stale and misleading. (For example, some fields accept quite arbitrary-seeming lengths such as 20 characters.) It is the caller’s responsibility to follow GitHub’s current limits, and deal with whatever errors result if those are exceeded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(The exception being the 50 annotation limit, since that has a documented and tested solution—adding annotations in batches of 50 or less—which can be implemented in the library.)

Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

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

Coming along really well.

@jglick jglick requested a review from bitwiseman March 27, 2020 18:14
@jglick
Copy link
Contributor Author

jglick commented Mar 27, 2020

I suppose unrelated flake:

java.lang.AssertionError: 
if header instance expires but queried instance is valid, ratelimit() uses it without asking server
Expected: not sameInstance(<GHRateLimit {core {remaining=4897, limit=5000, resetDate=Fri Mar 27 18:17:03 GMT 2020}search {remaining=999999, limit=1000000, resetDate=Fri Mar 27 19:17:00 GMT 2020}graphql {remaining=999999, limit=1000000, resetDate=Fri Mar 27 19:17:00 GMT 2020}integrationManifest {remaining=999999, limit=1000000, resetDate=Fri Mar 27 19:17:00 GMT 2020}}>)
     but: was <GHRateLimit {core {remaining=4897, limit=5000, resetDate=Fri Mar 27 18:17:03 GMT 2020}search {remaining=999999, limit=1000000, resetDate=Fri Mar 27 19:17:00 GMT 2020}graphql {remaining=999999, limit=1000000, resetDate=Fri Mar 27 19:17:00 GMT 2020}integrationManifest {remaining=999999, limit=1000000, resetDate=Fri Mar 27 19:17:00 GMT 2020}}>
	at org.kohsuke.github.AbstractGitHubWireMockTest.assertThat(AbstractGitHubWireMockTest.java:261)
	at org.kohsuke.github.GHRateLimitTest.executeExpirationTest(GHRateLimitTest.java:417)
	at org.kohsuke.github.GHRateLimitTest.testGitHubRateLimitExpirationServerFiveMinutesAhead(GHRateLimitTest.java:343)

Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

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

We're discussing the design of parts of the API.

Copy link
Contributor Author

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Can also look into regenerating all WireMock data files to use the new filename convention.

@jglick jglick requested a review from bitwiseman March 30, 2020 19:06
@jglick
Copy link
Contributor Author

jglick commented Mar 30, 2020

BTW you need to revisit tests from #595, which have flaked twice in this PR’s builds. Deleting Thread.sleep calls causes test failures, which is a “bad code smell”.

Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

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

Thanks, Jesse!

@bitwiseman bitwiseman merged commit dd55e8a into hub4j:master Mar 30, 2020
@jglick jglick deleted the createCheckRun branch March 30, 2020 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants