Skip to content

Commit

Permalink
Merge pull request #307 from uhafner/markdown
Browse files Browse the repository at this point in the history
Improve markdown content
  • Loading branch information
uhafner authored Dec 15, 2023
2 parents 9845a2a + 42e29c9 commit efb1906
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<jib-maven-plugin.version>3.4.0</jib-maven-plugin.version>
<testcontainers.version>1.19.3</testcontainers.version>

<autograding-model.version>3.15.0</autograding-model.version>
<autograding-model.version>3.16.0</autograding-model.version>
<analysis-model.version>11.13.0</analysis-model.version>
<coverage-model.version>0.36.0</coverage-model.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ protected void publishGradingResult(final AggregatedScore score, final FilteredL

var errors = createErrorMessageMarkdown(log);

addComment(score,
results.getHeader(), results.getTextSummary(score),
addComment(score, results.getTextSummary(score, getChecksName()),
results.getMarkdownDetails(score) + errors,
results.getMarkdownSummary(score, ":mortar_board: " + getChecksName()) + errors,
results.getMarkdownSummary(score, getChecksName()) + errors,
errors.isBlank() ? Conclusion.SUCCESS : Conclusion.FAILURE, log);

try {
Expand Down Expand Up @@ -98,8 +97,7 @@ String createEnvironmentVariables(final AggregatedScore score, final FilteredLog
protected void publishError(final AggregatedScore score, final FilteredLog log, final Throwable exception) {
var results = new GradingReport();

addComment(score,
results.getHeader(), results.getTextSummary(score),
addComment(score, results.getTextSummary(score, getChecksName()),
results.getMarkdownErrors(score, exception),
results.getMarkdownErrors(score, exception),
Conclusion.FAILURE, log);
Expand All @@ -112,46 +110,48 @@ private String getChecksName() {
}

private void addComment(final AggregatedScore score,
final String header, final String summary, final String comment, final String prComment,
final String textSummary, final String markdownDetails, final String markdownSummary,
final Conclusion conclusion, final FilteredLog log) {
var repository = getEnv("GITHUB_REPOSITORY", log);
if (repository.isBlank()) {
log.logError("No GITHUB_REPOSITORY defined - skipping");
try {
var repository = getEnv("GITHUB_REPOSITORY", log);
if (repository.isBlank()) {

Check warning on line 117 in src/main/java/edu/hm/hafner/grading/github/GitHubAutoGradingRunner.java

View workflow job for this annotation

GitHub Actions / Autograding GitHub Action

Partially covered line

Line 117 is only partially covered, one branch is missing
log.logError("No GITHUB_REPOSITORY defined - skipping");

return;
}
String oAuthToken = getEnv("GITHUB_TOKEN", log);
if (oAuthToken.isBlank()) {
log.logError("No valid GITHUB_TOKEN found - skipping");
return;

Check warning on line 120 in src/main/java/edu/hm/hafner/grading/github/GitHubAutoGradingRunner.java

View workflow job for this annotation

GitHub Actions / Autograding GitHub Action

Not covered lines

Lines 118-120 are not covered by tests
}
String oAuthToken = getEnv("GITHUB_TOKEN", log);
if (oAuthToken.isBlank()) {

Check warning on line 123 in src/main/java/edu/hm/hafner/grading/github/GitHubAutoGradingRunner.java

View workflow job for this annotation

GitHub Actions / Autograding GitHub Action

Partially covered line

Line 123 is only partially covered, one branch is missing
log.logError("No valid GITHUB_TOKEN found - skipping");

return;
}
return;
}

try {
String sha = getEnv("GITHUB_SHA", log);

GitHub github = new GitHubBuilder().withAppInstallationToken(oAuthToken).build();
GHCheckRunBuilder check = github.getRepository(repository)
.createCheckRun(getChecksName(), sha)
.withStatus(Status.COMPLETED)
.withStartedAt(Date.from(Instant.now()))
.withConclusion(conclusion);

Output output = new Output(header, summary).withText(comment);
Output output = new Output(textSummary, markdownSummary).withText(markdownDetails);

if (getEnv("SKIP_ANNOTATIONS", log).isEmpty()) {
var annotationBuilder = new GitHubAnnotationsBuilder(output, computeAbsolutePathPrefixToRemove(log));
annotationBuilder.createAnnotations(score);
}

check.add(output);
GHCheckRun run = check.create();

GHCheckRun run = check.create();
log.logInfo("Successfully created check " + run);

var prNumber = getEnv("PR_NUMBER", log);
if (!prNumber.isBlank()) { // optional PR comment
github.getRepository(repository)
.getPullRequest(Integer.parseInt(prNumber))
.comment(prComment + addCheckLink(run));
.comment(markdownSummary + addCheckLink(run));
log.logInfo("Successfully commented PR#" + prNumber);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void shouldGradeInDockerContainer() throws TimeoutException, IOException {
"=> Style Score: 6 of 100",
"-> SpotBugs Total: 1 warnings",
"=> Bugs Score: 86 of 100",
"Total score - 138 of 500 (unit tests: 10/100, code coverage: 20/100, mutation coverage: 16/100, analysis: 92/200)"});
"Autograding score - 138 of 500"});

container.copyFileFromContainer("/github/workspace/metrics.env", LOCAL_METRICS_FILE);
assertThat(Files.readString(Path.of(LOCAL_METRICS_FILE)))
Expand Down Expand Up @@ -183,7 +183,7 @@ void shouldUseDefaultConfiguration() throws TimeoutException {
"=> Style Score: 98 of 100",
"-> SpotBugs Total: 1 warnings",
"=> Bugs Score: 97 of 100",
"Total score - 313 of 500 (unit tests: 100/100, code coverage: 10/100, mutation coverage: 8/100, analysis: 195/200)"});
"Autograding score - 313 of 500"});
}
}

Expand Down Expand Up @@ -212,7 +212,7 @@ void shouldShowErrors() throws TimeoutException {
"=> Style Score: 100 of 100",
"-> SpotBugs Total: 0 warnings",
"=> Bugs Score: 100 of 100",
"Total score - 300 of 500 (unit tests: 100/100, code coverage: 0/100, mutation coverage: 0/100, analysis: 200/200)"});
"Autograding score - 300 of 500"});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void shouldGradeWithConfigurationFromEnvironment() {
"=> Style Score: 100 of 100",
"-> SpotBugs Total: 1 warnings",
"=> Bugs Score: 86 of 100",
"Total score - 322 of 500 (unit tests: 100/100, code coverage: 20/100, mutation coverage: 16/100, analysis: 186/200)"});
"Autograding score - 322 of 500"});
}

private static final String CONFIGURATION_WRONG_PATHS = """
Expand Down Expand Up @@ -253,7 +253,7 @@ void shouldShowErrors() {
"=> Style Score: 0 of 100",
"-> SpotBugs Total: 0 warnings",
"=> Bugs Score: 100 of 100",
"Total score - 200 of 500 (unit tests: 100/100, code coverage: 0/100, mutation coverage: 0/100, analysis: 100/200)"});
"Autograding score - 200 of 500"});
}

private String runAutoGrading() {
Expand Down

0 comments on commit efb1906

Please sign in to comment.