diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4980dc29..d3986369 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -53,7 +53,7 @@ jobs: matrix: include: - language: java-kotlin - build-mode: autobuild # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too. + build-mode: manual # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' # Use `c-cpp` to analyze code written in C, C++ or both # Use 'java-kotlin' to analyze code written in Java, Kotlin or both @@ -91,15 +91,12 @@ jobs: # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - if: matrix.build-mode == 'manual' - run: | - echo 'If you are using a "manual" build mode for one or more of the' \ - 'languages you are analyzing, replace this with the commands to build' \ - 'your code, for example:' - echo ' make bootstrap' - echo ' make release' - exit 1 + name: Build with Gradle and generate JaCoCo coverage report + run: ./gradlew check --configuration-cache --parallel - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v4 with: category: "/language:${{matrix.language}}" + upload: always + coverage-report: build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml diff --git a/build.gradle.kts b/build.gradle.kts index 38469267..d6c533a3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,6 +39,28 @@ subprojects { } } +val coverageVerification = tasks.register("testCodeCoverageVerification") { + dependsOn(tasks.named("testCodeCoverageReport")) + violationRules { + rule { + limit { + counter = "INSTRUCTION" + minimum = "0.90".toBigDecimal() + } + } + } + executionData( + fileTree(layout.buildDirectory.dir("jacoco")).matching { include("**/*.exec") } + ) + classDirectories.setFrom( + subprojects.map { p -> fileTree("${p.projectDir}/build/classes/java/main") } + ) + sourceDirectories.setFrom( + subprojects.map { p -> fileTree("${p.projectDir}/src/main/java") } + ) +} + tasks.check { dependsOn(tasks.named("testCodeCoverageReport")) + dependsOn(coverageVerification) } \ No newline at end of file