-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make action independent of github-autograding.
- Loading branch information
Showing
6 changed files
with
242 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/edu/hm/hafner/grading/github/GitHubAnnotationsBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package edu.hm.hafner.grading.github; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import edu.hm.hafner.grading.CommentBuilder; | ||
|
||
import org.kohsuke.github.GHCheckRun.AnnotationLevel; | ||
import org.kohsuke.github.GHCheckRunBuilder.Annotation; | ||
import org.kohsuke.github.GHCheckRunBuilder.Output; | ||
|
||
/** | ||
* Creates GitHub annotations for static analysis warnings, for lines with missing coverage, and for lines with | ||
* survived mutations. | ||
* | ||
* @author Ullrich Hafner | ||
*/ | ||
class GitHubAnnotationsBuilder extends CommentBuilder { | ||
private static final String GITHUB_WORKSPACE_REL = "/github/workspace/./"; | ||
private static final String GITHUB_WORKSPACE_ABS = "/github/workspace/"; | ||
|
||
private final Output output; | ||
|
||
GitHubAnnotationsBuilder(final Output output, final String prefix) { | ||
super(prefix, GITHUB_WORKSPACE_REL, GITHUB_WORKSPACE_ABS); | ||
|
||
this.output = output; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("checkstyle:ParameterNumber") | ||
protected void createComment(final CommentType commentType, final String relativePath, | ||
final int lineStart, final int lineEnd, | ||
final String message, final String title, | ||
final int columnStart, final int columnEnd, | ||
final String details) { | ||
Annotation annotation = new Annotation(relativePath, | ||
lineStart, lineEnd, AnnotationLevel.WARNING, message).withTitle(title); | ||
|
||
if (lineStart == lineEnd) { | ||
annotation.withStartColumn(columnStart).withEndColumn(columnEnd); | ||
} | ||
if (StringUtils.isNotBlank(details)) { | ||
annotation.withRawDetails(details); | ||
} | ||
|
||
output.add(annotation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters