|
1 | 1 | # Coverage build - gather artifacts from other builds and merge them into a single report |
2 | 2 | name: Coverage |
3 | 3 |
|
4 | | -on: workflow_call |
| 4 | +on: |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + trigger: |
| 8 | + description: Type of workflow trigger |
| 9 | + type: string |
| 10 | + required: false |
5 | 11 |
|
6 | 12 | permissions: |
7 | 13 | contents: read |
@@ -34,16 +40,33 @@ jobs: |
34 | 40 |
|
35 | 41 | - name: Compute coverage |
36 | 42 | working-directory: ${{env.COVERAGE_DIR}} |
| 43 | + id: coverage |
37 | 44 | run: | |
38 | 45 | echo "DIR: $(pwd)" && ls -al |
39 | 46 | ../scripts/coverage/merge_coverage_files.sh exports-coverage total_coverage |
40 | 47 | genhtml --no-function-coverage -o html_report total_coverage 2>&1 | tee output.txt |
41 | 48 | mkdir coverage_report |
42 | 49 | mv html_report ./coverage_report/ |
43 | 50 | tail -n2 output.txt >> $GITHUB_STEP_SUMMARY |
| 51 | + echo "COV_OUT=$(tail -n1 output.txt | grep -oP "lines[.]+: [\d.]+%" | cut -d ' ' -f2 | tr -d '%')" >> $GITHUB_OUTPUT |
44 | 52 |
|
45 | 53 | - name: Upload coverage report |
46 | 54 | uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 |
47 | 55 | with: |
48 | 56 | name: coverage_html_report |
49 | 57 | path: coverage/coverage_report |
| 58 | + |
| 59 | + # preview of the badge: https://gist.github.com/bb-ur/3f66c77d7035df39aa75dda8a2ac75b3 |
| 60 | + # Only update the badge on push (event is passed only for total coverage) |
| 61 | + - name: Update coverity badge |
| 62 | + if: ${{ success() && inputs.trigger == 'push' }} |
| 63 | + uses: Schneegans/dynamic-badges-action@e9a478b16159b4d31420099ba146cdc50f134483 # v1.7.0 |
| 64 | + with: |
| 65 | + auth: ${{ secrets.BB_GIST_TOKEN }} |
| 66 | + gistID: 3f66c77d7035df39aa75dda8a2ac75b3 |
| 67 | + filename: umf_coverage_badge.svg |
| 68 | + label: Coverage |
| 69 | + message: ${{ steps.coverage.outputs.COV_OUT }}% |
| 70 | + valColorRange: ${{ steps.coverage.outputs.COV_OUT }} |
| 71 | + minColorRange: 50 # <= this value = color: red |
| 72 | + maxColorRange: 90 # >= this value = color: green |
0 commit comments