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

Use latest version of autograding-model #337

Merged
merged 4 commits into from
Apr 3, 2024
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
87 changes: 0 additions & 87 deletions .github/workflows/autograding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,90 +35,3 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
pr-number: ${{ steps.pr.outputs.number }}
checks-name: 'Quality Checks'
config: >
{
"tests": {
"tools": [
{
"id": "test",
"name": "Unittests",
"pattern": "**/target/*-reports/TEST*.xml"
}
],
"name": "JUnit",
"passedImpact": 0,
"skippedImpact": -1,
"failureImpact": -5,
"maxScore": 100
},
"analysis": {
"name": "Warnings",
"id": "warnings",
"tools": [
{
"id": "checkstyle",
"name": "CheckStyle",
"pattern": "**/target/checkstyle-result.xml"
},
{
"id": "pmd",
"name": "PMD",
"pattern": "**/target/pmd.xml"
},
{
"id": "error-prone",
"name": "Error Prone",
"pattern": "**/maven.log"
},
{
"id": "spotbugs",
"name": "SpotBugs",
"sourcePath": "src/main/java",
"pattern": "**/target/spotbugsXml.xml"
}

],
"errorImpact": -1,
"highImpact": -1,
"normalImpact": -1,
"lowImpact": -1,
"maxScore": 100
},
"coverage": [
{
"tools": [
{
"id": "jacoco",
"name": "Line Coverage",
"metric": "line",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
},
{
"id": "jacoco",
"name": "Branch Coverage",
"metric": "branch",
"sourcePath": "src/main/java",
"pattern": "**/target/site/jacoco/jacoco.xml"
}
],
"name": "JaCoCo",
"maxScore": 100,
"missedPercentageImpact": -1
},
{
"tools": [
{
"id": "pit",
"name": "Mutation Coverage",
"metric": "mutation",
"sourcePath": "src/main/java",
"pattern": "**/target/pit-reports/mutations.xml"
}
],
"name": "PIT",
"maxScore": 100,
"missedPercentageImpact": -1
}
]
}
97 changes: 0 additions & 97 deletions .github/workflows/dogfood.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,103 +144,6 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
checks-name: "Autograding GitHub Action"
config: >
{
"tests": {
"tools": [
{
"id": "test",
"name": "Unittests",
"pattern": "**/target/*-reports/TEST*.xml"
}
],
"name": "JUnit",
"passedImpact": 0,
"skippedImpact": -1,
"failureImpact": -5,
"maxScore": 100
},
"analysis": [
{
"name": "Style",
"id": "style",
"tools": [
{
"id": "checkstyle",
"name": "CheckStyle",
"pattern": "**/target/checkstyle-result.xml"
},
{
"id": "pmd",
"name": "PMD",
"pattern": "**/target/pmd.xml"
}
],
"errorImpact": 1,
"highImpact": 2,
"normalImpact": 3,
"lowImpact": 4,
"maxScore": 100
},
{
"name": "Bugs",
"id": "bugs",
"icon": "bug",
"tools": [
{
"id": "spotbugs",
"name": "SpotBugs",
"sourcePath": "src/main/java",
"pattern": "**/target/spotbugsXml.xml"
}
],
"errorImpact": -11,
"highImpact": -12,
"normalImpact": -13,
"lowImpact": -14,
"maxScore": 100
}
],
"coverage": [
{
"tools": [
{
"id": "jacoco",
"sourcePath": "src/main/java",
"name": "Line Coverage",
"metric": "line",
"pattern": "**/target/site/jacoco/jacoco.xml"
},
{
"id": "jacoco",
"sourcePath": "src/main/java",
"name": "Branch Coverage",
"metric": "branch",
"pattern": "**/target/site/jacoco/jacoco.xml"
}
],
"name": "JaCoCo",
"maxScore": 100,
"coveredPercentageImpact": 1,
"missedPercentageImpact": -1
},
{
"tools": [
{
"id": "pit",
"name": "Mutation Coverage",
"metric": "mutation",
"sourcePath": "src/main/java",
"pattern": "**/target/pit-reports/mutations.xml"
}
],
"name": "PIT",
"maxScore": 100,
"coveredPercentageImpact": 1,
"missedPercentageImpact": -1
}
]
}
- name: Write metrics to GitHub output
id: metrics
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- .github/workflows/sync-labels.yml

jobs:
snyc-labels:
sync-labels:
name: Sync labels
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ This action can be configured using the following parameters (see example above)
- ``pr-number: ${{ steps.pr.outputs.number }}``: optional number of the pull request. If not set, then just the checks will be published but not a pull request comment.
- ``checks-name: "Name of checks"``: optional name of GitHub checks (overwrites the default: "Autograding result").
- ``skip-annotations: true``: Optional flag to skip the creation of annotations (for warnings and missed coverage).
- ``max-warning-comments: <number>``: Optional parameter to limit the number of warning comments at specific lines. By default, all line comments are created.
- ``max-coverage-comments: <number>``: Optional parameter to limit the number of coverage comments at specific lines. By default, all line comments are created.

## Metrics Configuration

Expand Down
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@ inputs:
skip-annotations:
description: "Skip the creation of annotations (for warnings and missed coverage) if not empty"
required: false
max-warning-annotations:
description: "Limit the number of warning annotations at specific lines. By default, all annotations are created."
required: false
max-coverage-annotations:
description: "Limit the number of coverage annotations at specific lines. By default, all annotations are created."
required: false

runs:
using: 'docker'
image: 'docker://uhafner/autograding-github-action:3.18.0'
image: 'docker://uhafner/autograding-github-action:3.19.0-SNAPSHOT'
env:
CONFIG: ${{ inputs.config }}
CHECKS_NAME: ${{ inputs.checks-name }}
PR_NUMBER: ${{ inputs.pr-number }}
GITHUB_TOKEN: ${{ inputs.github-token }}
SKIP_ANNOTATIONS: ${{ inputs.skip-annotations }}
MAX_WARNING_ANNOTATIONS: ${{ inputs.max-warning-annotations }}
MAX_COVERAGE_ANNOTATIONS: ${{ inputs.max-coverage-annotations }}

branding:
icon: check-square
Expand Down
4 changes: 2 additions & 2 deletions doc/dependency-graph.puml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rectangle "jackson-databind\n\n2.17.0" as com_fasterxml_jackson_core_jackson_dat
rectangle "jackson-annotations\n\n2.17.0" as com_fasterxml_jackson_core_jackson_annotations_jar
rectangle "jackson-core\n\n2.17.0" as com_fasterxml_jackson_core_jackson_core_jar
rectangle "byte-buddy\n\n1.14.12" as net_bytebuddy_byte_buddy_jar
rectangle "autograding-github-action\n\n3.18.0" as edu_hm_hafner_autograding_github_action_jar
rectangle "autograding-github-action\n\n3.19.0-SNAPSHOT" as edu_hm_hafner_autograding_github_action_jar
rectangle "github-api\n\n1.320" as org_kohsuke_github_api_jar
rectangle "spotbugs-annotations\n\n4.8.3" as com_github_spotbugs_spotbugs_annotations_jar
rectangle "error_prone_annotations\n\n2.25.0" as com_google_errorprone_error_prone_annotations_jar
Expand Down Expand Up @@ -101,4 +101,4 @@ edu_hm_hafner_autograding_github_action_jar -[#000000]-> edu_hm_hafner_codingsty
edu_hm_hafner_autograding_github_action_jar -[#000000]-> org_apache_commons_commons_lang3_jar
edu_hm_hafner_autograding_github_action_jar -[#000000]-> commons_io_commons_io_jar
edu_hm_hafner_autograding_github_action_jar -[#000000]-> net_bytebuddy_byte_buddy_jar
@enduml
@enduml
17 changes: 4 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle-pom</artifactId>
<version>3.44.0</version>
<version>4.3.0</version>
<relativePath />
</parent>

<groupId>edu.hm.hafner</groupId>
<artifactId>autograding-github-action</artifactId>
<version>3.18.0</version>
<version>3.19.0-SNAPSHOT</version>
<packaging>jar</packaging>

<scm>
Expand All @@ -30,7 +30,7 @@
<jib-maven-plugin.version>3.4.1</jib-maven-plugin.version>
<testcontainers.version>1.19.7</testcontainers.version>

<autograding-model.version>3.25.0</autograding-model.version>
<autograding-model.version>3.28.0</autograding-model.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -139,15 +139,6 @@
<goals>
<goal>build</goal>
</goals>
<configuration>
<to>
<image>docker.io/uhafner/autograding-github-action:${docker-image-tag}</image>
<auth>
<username>${env.DOCKER_IO_USERNAME}</username>
<password>${env.DOCKER_IO_PASSWORD}</password>
</auth>
</to>
</configuration>
</execution>
</executions>
<configuration>
Expand All @@ -159,7 +150,7 @@
</auth>
</to>
<from>
<image>maven:3.9.5-eclipse-temurin-21-alpine</image>
<image>maven:3.9.6-eclipse-temurin-21-alpine</image>
</from>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.commons.lang3.StringUtils;

import edu.hm.hafner.grading.CommentBuilder;
import edu.hm.hafner.util.FilteredLog;

import org.kohsuke.github.GHCheckRun.AnnotationLevel;
import org.kohsuke.github.GHCheckRunBuilder.Annotation;
Expand All @@ -19,11 +20,46 @@ class GitHubAnnotationsBuilder extends CommentBuilder {
private static final String GITHUB_WORKSPACE_ABS = "/github/workspace/";

private final Output output;
private final FilteredLog log;
private final int maxWarningComments;
private final int maxCoverageComments;

GitHubAnnotationsBuilder(final Output output, final String prefix) {
GitHubAnnotationsBuilder(final Output output, final String prefix, final FilteredLog log) {
super(prefix, GITHUB_WORKSPACE_REL, GITHUB_WORKSPACE_ABS);

this.output = output;
this.log = log;

maxWarningComments = getIntegerEnvironment("MAX_WARNING_ANNOTATIONS");
log.logInfo(">>>> MAX_WARNING_ANNOTATIONS: %d", getMaxWarningComments());

maxCoverageComments = getIntegerEnvironment("MAX_COVERAGE_ANNOTATIONS");
log.logInfo(">>>> MAX_COVERAGE_ANNOTATIONS: %d", getMaxCoverageComments());
}

@Override
protected int getMaxWarningComments() {
return maxWarningComments;
}

@Override
protected int getMaxCoverageComments() {
return maxCoverageComments;
}

private int getIntegerEnvironment(final String key) {
try {
return Integer.parseInt(getEnv(key));
}
catch (NumberFormatException exception) {
log.logError(">>>> Error: no integer value");

return Integer.MAX_VALUE;
}
}

private String getEnv(final String name) {
return StringUtils.defaultString(System.getenv(name));
}

@Override
Expand All @@ -32,7 +68,7 @@ protected void createComment(final CommentType commentType, final String relativ
final int lineStart, final int lineEnd,
final String message, final String title,
final int columnStart, final int columnEnd,
final String details) {
final String details, final String markDownDetails) {
Annotation annotation = new Annotation(relativePath,
lineStart, lineEnd, AnnotationLevel.WARNING, message).withTitle(title);

Expand Down
Loading