diff --git a/action.yml b/action.yml index 2cce959..c9ba406 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,9 @@ inputs: show-headers: description: "Show headers for each subsection in the summary (if not set, headers are hidden)" required: false + enable-logging: + description: "If set, then logging of the Checks Output JSON parameters is enabled. By default, logging is disabled." + required: false max-warning-annotations: description: "Limit the number of warning annotations at specific lines. By default, all annotations are created." required: false @@ -42,6 +45,7 @@ runs: GITHUB_API_URL: ${{ inputs.github-api-url }} SKIP_ANNOTATIONS: ${{ inputs.skip-annotations }} SHOW_HEADERS: ${{ inputs.show-headers }} + ENABLE_LOGGING: ${{ inputs.enable-logging }} MAX_WARNING_ANNOTATIONS: ${{ inputs.max-warning-annotations }} MAX_COVERAGE_ANNOTATIONS: ${{ inputs.max-coverage-annotations }} diff --git a/src/main/java/edu/hm/hafner/grading/github/QualityMonitor.java b/src/main/java/edu/hm/hafner/grading/github/QualityMonitor.java index 7cec8a0..bdb7313 100644 --- a/src/main/java/edu/hm/hafner/grading/github/QualityMonitor.java +++ b/src/main/java/edu/hm/hafner/grading/github/QualityMonitor.java @@ -2,6 +2,12 @@ import org.apache.commons.lang3.StringUtils; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.json.JsonMapper; + import edu.hm.hafner.grading.AggregatedScore; import edu.hm.hafner.grading.AutoGradingRunner; import edu.hm.hafner.grading.GradingReport; @@ -144,6 +150,18 @@ private void addComment(final AggregatedScore score, final String textSummary, check.add(output); + if (!getEnv("ENABLE_LOGGING", log).isEmpty()) { + var mapper = JsonMapper.builder().configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true).build() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(SerializationFeature.INDENT_OUTPUT, true); + try { + log.logInfo("Output JSON parameters:%n%s", mapper.writeValueAsString(output)); + } + catch (JsonProcessingException exception) { + // ignore + } + } + var checksResult = createChecksRun(log, check); var prNumber = getEnv("PR_NUMBER", log);