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

Code Coverage update #1022

Merged
merged 1 commit into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 10 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<okio.version>2.5.0</okio.version>
<spotless-maven-plugin.goal>apply</spotless-maven-plugin.goal>
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
<jacoco.coverage.target.bundle.method>0.60</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.25</jacoco.coverage.target.class.method>
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
<jacoco.coverage.target.class.method>0.50</jacoco.coverage.target.class.method>
<!-- For non-ci builds we'd like the build to still complete if jacoco metrics aren't met. -->
<jacoco.haltOnFailure>false</jacoco.haltOnFailure>
<jjwt.suite.version>0.11.2</jjwt.suite.version>
Expand Down Expand Up @@ -153,59 +153,39 @@
<!-- Sample only -->
<exclude>org.kohsuke.github.example.*</exclude>

<!-- No methods -->
<exclude>org.kohsuke.github.internal.Previews</exclude>

<!-- Deprecated -->
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
<exclude>org.kohsuke.github.EnforcementLevel</exclude>
<exclude>org.kohsuke.github.GHPerson.1</exclude>

<!-- These fail coverage on windows because tests are disabled -->
<exclude>org.kohsuke.github.GHAsset</exclude>
<exclude>org.kohsuke.github.GHReleaseBuilder</exclude>
<exclude>org.kohsuke.github.GHRelease</exclude>
<!-- TODO: Some coverage, but more needed -->
<exclude>org.kohsuke.github.GHPullRequestReviewBuilder.DraftReviewComment</exclude>
<exclude>org.kohsuke.github.GHIssue.PullRequest</exclude>
<exclude>org.kohsuke.github.GHCommitSearchBuilder</exclude>
<exclude>org.kohsuke.github.GHRepositorySearchBuilder</exclude>
<exclude>org.kohsuke.github.GHUserSearchBuilder</exclude>

<!-- TODO: These still need test coverage -->
<exclude>org.kohsuke.github.GHBranchProtection.RequiredSignatures</exclude>
<exclude>org.kohsuke.github.GHBranchProtectionBuilder.Restrictions</exclude>
<exclude>org.kohsuke.github.GHBranchProtection.Restrictions</exclude>
<exclude>org.kohsuke.github.GHCommentAuthorAssociation</exclude>
<exclude>org.kohsuke.github.GHCommitBuilder.UserInfo</exclude>
<exclude>org.kohsuke.github.GHCommitState</exclude>
<exclude>org.kohsuke.github.GHCompare.Commit</exclude>
<exclude>org.kohsuke.github.GHCompare.InnerCommit</exclude>
<exclude>org.kohsuke.github.GHCompare.Status</exclude>
<exclude>org.kohsuke.github.GHCompare.Tree</exclude>
<exclude>org.kohsuke.github.GHCompare.User</exclude>
<exclude>org.kohsuke.github.GHCompare</exclude>
<exclude>org.kohsuke.github.GHDeployKey</exclude>
<exclude>org.kohsuke.github.GHDeploymentStatusBuilder</exclude>
<exclude>org.kohsuke.github.GHDirection</exclude>
<exclude>org.kohsuke.github.GHEmail</exclude>
<exclude>org.kohsuke.github.GHEventPayload.Ping</exclude>
<exclude>org.kohsuke.github.GHEventPayload.Release</exclude>
<exclude>org.kohsuke.github.GHException</exclude>
<exclude>org.kohsuke.github.GHHook</exclude>
<exclude>org.kohsuke.github.GHHooks.OrgContext</exclude>
<exclude>org.kohsuke.github.GHInvitation</exclude>
<exclude>org.kohsuke.github.GHMilestoneState</exclude>
<exclude>org.kohsuke.github.GHOrgHook</exclude>
<exclude>org.kohsuke.github.GHProject.ProjectStateFilter</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Authorship</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Commit</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.CommitPointer</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail.Tree</exclude>
<exclude>org.kohsuke.github.GHPullRequestCommitDetail</exclude>
<exclude>org.kohsuke.github.GHPullRequestFileDetail</exclude>
<exclude>org.kohsuke.github.GHPullRequestQueryBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHReleaseUpdater</exclude>
<exclude>org.kohsuke.github.GHRepository.ForkSort</exclude>
<exclude>org.kohsuke.github.GHRequestedAction</exclude>
<exclude>org.kohsuke.github.GHStargazer</exclude>
<exclude>org.kohsuke.github.GHTagObject</exclude>
<exclude>org.kohsuke.github.GHTeam.Role</exclude>
<exclude>org.kohsuke.github.GHUserSearchBuilder.Sort</exclude>
<exclude>org.kohsuke.github.GHVerifiedKey</exclude>
</excludes>
</rule>
Expand Down Expand Up @@ -592,6 +572,8 @@
</os>
</activation>
<properties>
<!-- Only fail code coverage on non-windows machines -->
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
Comment on lines +575 to +576
Copy link
Member Author

Choose a reason for hiding this comment

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

Rather than exclude some classes from measurement due to tests not running on windows, don't run coverage on windows.

<spotless-maven-plugin.goal>check</spotless-maven-plugin.goal>
</properties>
</profile>
Expand All @@ -602,9 +584,6 @@
<name>enable-ci</name>
</property>
</activation>
<properties>
<jacoco.haltOnFailure>true</jacoco.haltOnFailure>
</properties>
<build>
<plugins>
<plugin>
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/org/kohsuke/github/GHPullRequestReviewComment.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,20 @@ public URL getHtmlUrl() {
* @return the api route
*/
protected String getApiRoute() {
return "/repos/" + owner.getRepository().getFullName() + "/pulls/comments/" + getId();
return getApiRoute(false);
}

/**
* Gets api route.
*
* @param includePullNumber
* if true, includes the owning pull request's number in the route.
*
* @return the api route
*/
protected String getApiRoute(boolean includePullNumber) {
return "/repos/" + owner.getRepository().getFullName() + "/pulls"
+ (includePullNumber ? "/" + owner.getNumber() : "") + "/comments/" + getId();
}

/**
Expand Down Expand Up @@ -192,8 +205,7 @@ public GHPullRequestReviewComment reply(String body) throws IOException {
return owner.root.createRequest()
.method("POST")
.with("body", body)
.with("in_reply_to", getId())
.withUrlPath(getApiRoute() + "/comments")
.withUrlPath(getApiRoute(true) + "/replies")
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only real product change. Bug fixed!

.fetch(GHPullRequestReviewComment.class)
.wrapUp(owner);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/kohsuke/github/GitHubInteractiveObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ abstract class GitHubInteractiveObject {
GitHubInteractiveObject(GitHub root) {
this.root = root;
}

GitHub getRoot() {
return root;
}
Comment on lines +23 to +26
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this internal method for tests to use, in preparation changing root to private.

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ private GHAppInstallation getAppInstallationWithToken(String jwtToken) throws IO
.findFirst()
.get();

appInstallation
.setRoot(getGitHubBuilder().withAppInstallationToken(appInstallation.createToken().create().getToken())
.withEndpoint(mockGitHub.apiServer().baseUrl())
.build());
// TODO: this is odd
// appInstallation
// .setRoot(getGitHubBuilder().withAppInstallationToken(appInstallation.createToken().create().getToken())
// .withEndpoint(mockGitHub.apiServer().baseUrl())
// .build());

return appInstallation;
}
Expand Down
Loading