Skip to content

Commit edcb4c6

Browse files
committed
feat(59649): add support for code coverage for ci-cd-kotlin.yml path
1 parent 15b56b5 commit edcb4c6

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

.github/workflows/ci-cd-kotlin.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
required: true
77
DOCKER_PASSWORD:
88
required: true
9+
CODECOV_TOKEN:
10+
required: false
911
inputs:
1012
uploadJarArtifact:
1113
required: false
@@ -21,9 +23,14 @@ on:
2123
required: false
2224
type: boolean
2325
default: false
26+
codeCoverageEnabled:
27+
required: false
28+
type: boolean
29+
default: false
2430

2531
env:
2632
IMAGE_NAME_MIXED_CASE: "${{ github.repository }}"
33+
JACOCO_REPORTS: "**/build/reports/jacoco/test/jacocoTestReport.xml,**/build/reports/jacoco/jacoco.xml"
2734

2835
jobs:
2936
build-check-test-push:
@@ -49,7 +56,23 @@ jobs:
4956
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5057

5158
- name: Run tests
52-
run: ./gradlew test
59+
env:
60+
CODE_COVERAGE_ENABLED: ${{ inputs.codeCoverageEnabled }}
61+
run: |
62+
if [[ "${CODE_COVERAGE_ENABLED}" == "true" ]]; then
63+
./gradlew test jacocoTestReport
64+
else
65+
./gradlew test
66+
fi
67+
68+
- name: Upload coverage reports to Codecov
69+
if: ${{ inputs.codeCoverageEnabled }}
70+
uses: codecov/codecov-action@v5
71+
with:
72+
token: ${{ secrets.CODECOV_TOKEN }}
73+
files: ${{ env.JACOCO_REPORTS }}
74+
fail_ci_if_error: true
75+
verbose: true
5376

5477
- name: Upload .jar artifact
5578
if: ${{ inputs.uploadJarArtifact }}
@@ -115,4 +138,4 @@ jobs:
115138
context: .
116139
push: ${{ env.PERFORM_RELEASE }}
117140
tags: ${{ steps.meta.outputs.tags }}
118-
labels: ${{ steps.meta.outputs.labels }}
141+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)