Skip to content

Commit

Permalink
build: Add a job summary to the pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebz committed Oct 23, 2024
1 parent d4b98c2 commit 2e65a8e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
run: ./gradlew build publishToMavenLocal

- name: Run zpa-checks integration tests
run: ./gradlew :zpa-checks:integrationTest
run: |
./gradlew :zpa-checks:integrationTest
cat zpa-checks/build/integrationTest/progress-summary.md >> $GITHUB_STEP_SUMMARY
- name: Build custom rules example
run: ./gradlew build -p plsql-custom-rules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.fasterxml.jackson.core.util.DefaultIndenter
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.fail
import org.sonar.plsqlopen.checks.CheckList
Expand Down Expand Up @@ -244,6 +245,39 @@ class PlSqlRulingTest {
)
}
}

summary.add(SummaryItem(project, files.size, issues.filter { it.check is ParsingErrorCheck }.size))
}

companion object {
private val summary = mutableListOf<SummaryItem>()

@AfterAll
@JvmStatic
fun writeSummary() {
val output = File("build/integrationTest/progress-summary.md")
output.parentFile.mkdirs()
output.writeText("| Project | Files | Parsing Errors | % Success | Status |\n| --- | --- | --- | --- | --- |\n")

for (item in summary.sortedWith(compareByDescending<SummaryItem> { it.parsingErrors }.thenBy { it.name })) {
val successPercentage = ((item.files - item.parsingErrors).toDouble() / item.files) * 100
val status = if (item.parsingErrors > 0) "" else ""
output.appendText(
"| ${item.name} | ${item.files} | ${item.parsingErrors} | ${
String.format(
"%.2f",
successPercentage
)
}% | $status |\n"
)
}
}
}

data class SummaryItem(
val name: String,
val files: Int,
val parsingErrors: Int,
)

}

0 comments on commit 2e65a8e

Please sign in to comment.