|
7 | 7 | env: |
8 | 8 | scalaLong: 2.12.18 |
9 | 9 | scalaShort: "2.12" |
10 | | - coverage-overall: 0.0 |
11 | | - coverage-changed-files: 0.0 |
12 | | - check-overall-coverages: true |
| 10 | + coverage-overall: 80.0 |
| 11 | + coverage-changed-files: 80.0 |
| 12 | + coverage-per-changed-file: 0.0 |
13 | 13 |
|
14 | 14 | jobs: |
15 | 15 | build-test-and-measure: |
@@ -54,68 +54,82 @@ jobs: |
54 | 54 | id: jacocorun |
55 | 55 | run: sbt jacoco |
56 | 56 |
|
57 | | - - name: Add coverage to PR |
58 | | - if: steps.jacocorun.outcome == 'success' |
59 | | - id: jacoco-balta |
60 | | - uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 |
| 57 | + - name: Check coverage thresholds and add reports in PR comments |
| 58 | + id: jacoco |
| 59 | + uses: MoranaApps/jacoco-report@v2 |
61 | 60 | with: |
62 | | - paths: ${{ github.workspace }}/balta/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml |
63 | | - token: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + token: '${{ secrets.GITHUB_TOKEN }}' |
| 62 | + paths: | |
| 63 | + balta/target/**/jacoco/report/jacoco.xml |
| 64 | + sensitivity: "detail" |
| 65 | + comment-mode: 'single' |
64 | 66 | min-coverage-overall: ${{ env.coverage-overall }} |
65 | 67 | min-coverage-changed-files: ${{ env.coverage-changed-files }} |
66 | | - title: JaCoCo 'balta' module code coverage report - scala ${{ env.scalaLong }} |
67 | | - update-comment: true |
68 | | - - name: Get the Coverage info |
69 | | - if: steps.jacocorun.outcome == 'success' |
70 | | - run: | |
71 | | - echo "Total 'balta' module coverage ${{ steps.jacoco-balta.outputs.coverage-overall }}" |
72 | | - echo "Changed Files coverage ${{ steps.jacoco-balta.outputs.coverage-changed-files }}" |
73 | | - - name: Fail PR if changed files coverage is less than ${{ env.coverage-changed-files }}% |
74 | | - if: steps.jacocorun.outcome == 'success' |
75 | | - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd |
76 | | - with: |
77 | | - script: | |
78 | | - const coverageCheckFailed = |
79 | | - Number('${{ steps.jacoco-balta.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') |
80 | | - if (coverageCheckFailed) { |
81 | | - core.setFailed('Changed files coverage is less than ${{ env.coverage-changed-files }}%!'); |
82 | | - } |
83 | | - - name: Fail PR if overall files coverage is less than ${{ env.coverage-overall }}% |
84 | | - if: ${{ (steps.jacocorun.outcome == 'success') && (env.check-overall-coverages == 'true') }} |
85 | | - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd |
86 | | - with: |
87 | | - script: | |
88 | | - const coverageCheckFailed = |
89 | | - Number('${{ steps.jacoco-balta.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}'); |
90 | | - if (coverageCheckFailed) { |
91 | | - core.setFailed('Overall coverage is less than ${{ env.coverage-overall }}%!'); |
92 | | - } |
93 | | - - name: Edit JaCoCo comments on build failure |
94 | | - if: steps.jacocorun.outcome != 'success' |
95 | | - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd |
96 | | - with: |
97 | | - script: | |
98 | | - const issue_number = context.issue.number; |
99 | | - const owner = context.repo.owner; |
100 | | - const repo = context.repo.repo; |
101 | | - const jacocoReportRegExp = /^### JaCoCo .* code coverage report .*/; |
| 68 | + min-coverage-per-changed-file: ${{ env.coverage-per-changed-file }} |
| 69 | + skip-unchanged: false |
| 70 | + |
| 71 | + # - name: Add coverage to PR |
| 72 | + # if: steps.jacocorun.outcome == 'success' |
| 73 | + # id: jacoco-balta |
| 74 | + # uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 |
| 75 | + # with: |
| 76 | + # paths: ${{ github.workspace }}/balta/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml |
| 77 | + # token: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + # min-coverage-overall: ${{ env.coverage-overall }} |
| 79 | + # min-coverage-changed-files: ${{ env.coverage-changed-files }} |
| 80 | + # title: JaCoCo 'balta' module code coverage report - scala ${{ env.scalaLong }} |
| 81 | + # update-comment: true |
| 82 | + # - name: Get the Coverage info |
| 83 | + # if: steps.jacocorun.outcome == 'success' |
| 84 | + # run: | |
| 85 | + # echo "Total 'balta' module coverage ${{ steps.jacoco-balta.outputs.coverage-overall }}" |
| 86 | + # echo "Changed Files coverage ${{ steps.jacoco-balta.outputs.coverage-changed-files }}" |
| 87 | + # - name: Fail PR if changed files coverage is less than ${{ env.coverage-changed-files }}% |
| 88 | + # if: steps.jacocorun.outcome == 'success' |
| 89 | + # uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd |
| 90 | + # with: |
| 91 | + # script: | |
| 92 | + # const coverageCheckFailed = |
| 93 | + # Number('${{ steps.jacoco-balta.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') |
| 94 | + # if (coverageCheckFailed) { |
| 95 | + # core.setFailed('Changed files coverage is less than ${{ env.coverage-changed-files }}%!'); |
| 96 | + # } |
| 97 | + # - name: Fail PR if overall files coverage is less than ${{ env.coverage-overall }}% |
| 98 | + # if: ${{ (steps.jacocorun.outcome == 'success') && (env.check-overall-coverages == 'true') }} |
| 99 | + # uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd |
| 100 | + # with: |
| 101 | + # script: | |
| 102 | + # const coverageCheckFailed = |
| 103 | + # Number('${{ steps.jacoco-balta.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}'); |
| 104 | + # if (coverageCheckFailed) { |
| 105 | + # core.setFailed('Overall coverage is less than ${{ env.coverage-overall }}%!'); |
| 106 | + # } |
| 107 | + # - name: Edit JaCoCo comments on build failure |
| 108 | + # if: steps.jacocorun.outcome != 'success' |
| 109 | + # uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd |
| 110 | + # with: |
| 111 | + # script: | |
| 112 | + # const issue_number = context.issue.number; |
| 113 | + # const owner = context.repo.owner; |
| 114 | + # const repo = context.repo.repo; |
| 115 | + # const jacocoReportRegExp = /^### JaCoCo .* code coverage report .*/; |
102 | 116 |
|
103 | | - const comments = await github.rest.issues.listComments({ |
104 | | - owner, |
105 | | - repo, |
106 | | - issue_number, |
107 | | - }); |
| 117 | + # const comments = await github.rest.issues.listComments({ |
| 118 | + # owner, |
| 119 | + # repo, |
| 120 | + # issue_number, |
| 121 | + # }); |
108 | 122 |
|
109 | | - for (const comment of comments.data) { |
110 | | - const lines = comment.body.split('\n'); |
111 | | - if (lines.length > 0 && jacocoReportRegExp.test(lines[0])) { |
112 | | - await github.rest.issues.updateComment({ |
113 | | - owner, |
114 | | - repo, |
115 | | - comment_id: comment.id, |
116 | | - body: lines[0] + "\n\n### Build Failed", |
117 | | - }); |
118 | | - } |
119 | | - } |
| 123 | + # for (const comment of comments.data) { |
| 124 | + # const lines = comment.body.split('\n'); |
| 125 | + # if (lines.length > 0 && jacocoReportRegExp.test(lines[0])) { |
| 126 | + # await github.rest.issues.updateComment({ |
| 127 | + # owner, |
| 128 | + # repo, |
| 129 | + # comment_id: comment.id, |
| 130 | + # body: lines[0] + "\n\n### Build Failed", |
| 131 | + # }); |
| 132 | + # } |
| 133 | + # } |
120 | 134 |
|
121 | | - core.setFailed('JaCoCo test coverage report generation failed, and related PR comments were updated.'); |
| 135 | + # core.setFailed('JaCoCo test coverage report generation failed, and related PR comments were updated.'); |
0 commit comments