Skip to content

Commit

Permalink
feat: Custom code coverage summary title (#31)
Browse files Browse the repository at this point in the history
Closes #30
  • Loading branch information
cicdguy authored Oct 18, 2023
1 parent 36a0fea commit e9f4411
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,31 @@ jobs:
diff: false
diff-branch: main
diff-storage: _xml_coverage_reports
coverage-summary-title: "Code Coverage Summary (test-branch.xml)"
- path: test-missing-lines.xml
threshold: 50
fail: false
publish: true
diff: false
diff-branch: main
diff-storage: _xml_coverage_reports
coverage-summary-title: "Code Coverage Summary (test-missing-lines.xml)"
- path: test-no-branch.xml
threshold: 90
fail: true
publish: true
diff: true
diff-branch: main
diff-storage: _xml_coverage_reports_1
coverage-summary-title: "Code Coverage Summary (test-no-branch.xml)"
- path: test-python.xml
threshold: 90
fail: false
publish: false
diff: true
diff-branch: main
diff-storage: _xml_coverage_reports_2
coverage-summary-title: "Code Coverage Summary (test-python.xml)"
steps:
- name: Checkout Code 🛎
uses: actions/checkout@v3
Expand All @@ -59,3 +63,4 @@ jobs:
diff: ${{ matrix.reports.diff }}
diff-branch: ${{ matrix.reports.diff-branch }}
diff-storage: ${{ matrix.reports.diff-storage }}
coverage-summary-title: ${{ matrix.reports.coverage-summary-title}}
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ Insights Engineering

_Default_: `_xml_coverage_reports`

* `coverage-summary-title`:

_Description_: Title for the code coverage summary in the Pull Request comment.

_Required_: `false`

_Default_: `Code Coverage Summary`

* `coverage-reduction-failure`:

_Description_: Fail the action if code coverage decreased compared to the `diff-branch` is decreased.
Expand Down Expand Up @@ -177,6 +185,9 @@ jobs:
# `diff-branch` are stored.
# Branch is created if it doesn't already exist'.
diff-storage: _xml_coverage_reports
# A custom title that can be added to the code
# coverage summary in the PR comment.
coverage-summary-title: "Code Coverage Summary"
```
An example of the output of the action can be seen below:
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ inputs:
description: Branch where coverage reports are stored for diff purposes.
required: false
default: _xml_coverage_reports
coverage-summary-title:
description: Title for the code coverage summary in the Pull Request comment.
required: false
default: "Code Coverage Summary"
coverage-reduction-failure:
description: Fail the action if code coverage decreased compared to the `diff-branch` is decreased.
required: false
Expand Down Expand Up @@ -224,7 +228,7 @@ runs:
echo -e "🧪 Test coverage: ${{ steps.coverage_percent.outputs.coverage_total }}%\n\n" > .coverage-output.final
}
fi
echo -e "## Code Coverage Summary\n" >> .coverage-output.final
echo -e "## ${{ inputs.coverage-summary-title }}\n" >> .coverage-output.final
if [[ "${{ inputs.togglable-report }}" == "true" ]]
then {
echo -e "<details>\n\n" >> .coverage-output.final
Expand Down

0 comments on commit e9f4411

Please sign in to comment.