Add kover and gh action for coverage #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: verify | |
on: | |
pull_request: | |
env: | |
JDK_VERSION: 21 | |
GRADLE_OPTS: -Dorg.gradle.daemon=false | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
name: Build and Run Tests | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
checks: write | |
pull-requests: write | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up JDK ${{ env.JDK_VERSION }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: '${{ env.JDK_VERSION }}' | |
cache: 'gradle' | |
- name: Build and Run Tests | |
run: ./gradlew test koverXmlReport | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: success() || failure() # always run even if the previous step fails | |
with: | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
- name: Publish Kover Report | |
uses: madrapps/[email protected] | |
if: success() || failure() # always run even if the previous step fails | |
with: | |
paths: | | |
${{ github.workspace }}/build/reports/kover/report.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
min-coverage-overall: 50 | |
min-coverage-changed-files: 60 | |
- name: Coverage verify | |
run: ./gradlew koverVerify | |
- name: Read merge.err | |
if: failure() | |
id: readmergeerr | |
run: | | |
cat build/reports/kover/merge.err | |
- name: Fail PR if coverage verify fails | |
if: failure() | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
// read stdout from readmerge | |
const readmergeerr = steps.readmergeerr.outputs.stdout | |
core.setOutput('summary', 'Rule violated: lines covered ' + readmergeerr) | |
detekt: | |
name: Detekt | |
runs-on: ubuntu-latest | |
permissions: | |
# required for all workflows | |
security-events: write | |
checks: write | |
# only required for workflows in private repositories | |
actions: read | |
contents: read | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up JDK ${{ env.JDK_VERSION }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'adopt' | |
java-version: '${{ env.JDK_VERSION }}' | |
cache: 'gradle' | |
- name: Run Detekt | |
run: ./gradlew detekt | |
- name: Publish Detekt Report | |
uses: jwgmeligmeyling/checkstyle-github-action@master | |
if: success() || failure() # always run even if the previous step fails | |
with: | |
path: 'build/reports/detekt/merge.xml' |