-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing new JMF Jacoco solution #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tmikula-dev
wants to merge
3
commits into
master
Choose a base branch
from
feature/157-adopt-JMF
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+208
−146
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,24 +14,65 @@ | |
| # limitations under the License. | ||
| # | ||
|
|
||
| name: JaCoCo Report | ||
| name: CI JaCoCo Report | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ master ] | ||
| types: [ opened, edited, synchronize, reopened ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: jacoco-report-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| scalaLong: 2.13.11 | ||
| scalaShort: 2.13 | ||
| coverage-overall: 57.0 | ||
| coverage-changed-files: 80.0 | ||
| check-overall-coverages: true | ||
| # hint: "group thresholds" are in format: 'overall*changed-files-average*per-changed-file' | ||
| REPORT_GROUPS: | | ||
| - name: faDbCore | ||
| paths: | ||
| - '**/core/target/**/jacoco-report/jacoco.xml' | ||
| thresholds: '61*80*0' | ||
| - name: faDBDoobie | ||
| paths: | ||
| - '**/doobie/target/**/jacoco-report/jacoco.xml' | ||
| thresholds: '67*80*0' | ||
| - name: faDBSlick | ||
| paths: | ||
| - '**/slick/target/**/jacoco-report/jacoco.xml' | ||
| thresholds: '39*80*0' | ||
|
|
||
| jobs: | ||
| build-test-and-measure: | ||
| name: Build, Test and Measure | ||
| detect: | ||
| name: Detect Changed Files | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 2 | ||
| outputs: | ||
| scala_changed: ${{ steps.filter.outputs.scala }} | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
| - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d | ||
| id: filter | ||
| with: | ||
| token: "" | ||
| filters: | | ||
| scala: | ||
| - '**/*.scala' | ||
| - '!project/**' | ||
|
|
||
| jacoco-report: | ||
| name: JaCoCo Report | ||
| needs: detect | ||
| if: needs.detect.outputs.scala_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| services: | ||
| postgres: | ||
|
|
@@ -52,6 +93,7 @@ jobs: | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Scala | ||
| uses: olafurpg/setup-scala@32ffa16635ff8f19cc21ea253a987f0fdf29844c | ||
|
|
@@ -63,107 +105,27 @@ jobs: | |
|
|
||
| - name: Build and run tests | ||
| continue-on-error: true | ||
| id: jacocorun | ||
| run: sbt ++${{env.scalaLong}} jacoco | ||
|
|
||
| - name: Add coverage to PR (core) | ||
| if: steps.jacocorun.outcome == 'success' | ||
| id: jacoco-core | ||
| uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 | ||
| with: | ||
| paths: ${{ github.workspace }}/core/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| min-coverage-overall: ${{ env.coverage-overall }} | ||
| min-coverage-changed-files: ${{ env.coverage-changed-files }} | ||
| title: JaCoCo `core` module code coverage report - scala ${{ env.scalaLong }} | ||
| update-comment: true | ||
| run: sbt jacoco | ||
|
|
||
| - name: Add coverage to PR (doobie) | ||
| if: steps.jacocorun.outcome == 'success' | ||
| id: jacoco-doobie | ||
| uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 | ||
| with: | ||
| paths: ${{ github.workspace }}/doobie/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| min-coverage-overall: ${{ env.coverage-overall }} | ||
| min-coverage-changed-files: ${{ env.coverage-changed-files }} | ||
| title: JaCoCo `doobie` module code coverage report - scala ${{ env.scalaLong }} | ||
| update-comment: true | ||
| python-version: '3.14' | ||
|
|
||
| - name: Add coverage to PR (slick) | ||
| if: steps.jacocorun.outcome == 'success' | ||
| id: jacoco-slick | ||
| uses: madrapps/jacoco-report@50d3aff4548aa991e6753342d9ba291084e63848 | ||
| - name: Add JaCoCo Report in PR comments | ||
| uses: MoranaApps/jacoco-report@5b6495430e6bb5fde0a6b7dd348fc8afc3aa86db | ||
| with: | ||
| paths: ${{ github.workspace }}/slick/target/scala-${{ env.scalaShort }}/jacoco/report/jacoco.xml | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| min-coverage-overall: ${{env.coverage-overall }} | ||
| min-coverage-changed-files: ${{ env.coverage-changed-files }} | ||
| title: JaCoCo `slick` module code coverage report - scala ${{ env.scalaLong }} | ||
| update-comment: true | ||
|
|
||
| - name: Get the Coverage info | ||
| if: steps.jacocorun.outcome == 'success' | ||
| run: | | ||
| echo "Total `core` module coverage ${{ steps.jacoco-core.outputs.coverage-overall }}" | ||
| echo "Changed Files coverage ${{ steps.jacoco-core.outputs.coverage-changed-files }}" | ||
| echo "Total `doobie` module coverage ${{ steps.jacoco-doobie.outputs.coverage-overall }}" | ||
| echo "Changed Files coverage ${{ steps.jacoco-doobie.outputs.coverage-changed-files }}" | ||
| echo "Total `slick` module coverage ${{ steps.jacoco-slick.outputs.coverage-overall }}" | ||
| echo "Changed Files coverage ${{ steps.jacoco-slick.outputs.coverage-changed-files }}" | ||
|
|
||
| - name: Fail PR if changed files coverage is less than ${{ env.coverage-changed-files }}% | ||
| if: steps.jacocorun.outcome == 'success' | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 | ||
| with: | ||
| script: | | ||
| const coverageCheckFailed = | ||
| Number('${{ steps.jacoco-core.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') || | ||
| Number('${{ steps.jacoco-doobie.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}') || | ||
| Number('${{ steps.jacoco-slick.outputs.coverage-changed-files }}') < Number('${{ env.coverage-changed-files }}'); | ||
| if (coverageCheckFailed) { | ||
| core.setFailed('Changed files coverage is less than ${{ env.coverage-changed-files }}%!'); | ||
| } | ||
|
|
||
| - name: Fail PR if overall files coverage is less than ${{ env.coverage-overall }}% | ||
| if: ${{ (steps.jacocorun.outcome == 'success') && (env.check-overall-coverages == 'true') }} | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 | ||
| with: | ||
| script: | | ||
| const coverageCheckFailed = | ||
| Number('${{ steps.jacoco-core.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') || | ||
| Number('${{ steps.jacoco-doobie.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}') || | ||
| Number('${{ steps.jacoco-slick.outputs.coverage-overall }}') < Number('${{ env.coverage-overall }}'); | ||
| if (coverageCheckFailed) { | ||
| core.setFailed('Overall coverage is less than ${{ env.coverage-overall }}%!'); | ||
| } | ||
|
|
||
| - name: Edit JaCoCo comments on build failure | ||
| if: steps.jacocorun.outcome != 'success' | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 | ||
| with: | ||
| script: | | ||
| const issue_number = context.issue.number; | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const jacocoReportRegExp = /^### JaCoCo .* code coverage report .*/; | ||
|
|
||
| const comments = await github.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| }); | ||
|
|
||
| for (const comment of comments.data) { | ||
| const lines = comment.body.split('\n'); | ||
| if (lines.length > 0 && jacocoReportRegExp.test(lines[0])) { | ||
| await github.rest.issues.updateComment({ | ||
| owner, | ||
| repo, | ||
| comment_id: comment.id, | ||
| body: lines[0] + "\n\n### Build Failed", | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| core.setFailed('JaCoCo test coverage report generation failed, and related PR comments were updated.'); | ||
| global-thresholds: '0*80' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I would use current global value as start point. |
||
| report-thresholds-default: '0*0*0' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I would use the lowest report group value for 1st position then 80*60. |
||
| skip-unchanged: 'true' | ||
| evaluate-unchanged: 'false' | ||
| report-groups: ${{ env.REPORT_GROUPS }} | ||
|
|
||
| noop: | ||
| name: No Operation | ||
| needs: detect | ||
| if: needs.detect.outputs.scala_changed != 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo "No changes in Scala related files — passing." | ||
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 0? I would suggest 60%
It give space and now there is the eay how to filter out no coverable methods.