generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from stenjo/227-feattest-coverage-add-coverag…
…e-in-pr-and-compare-with-main feat(test-coverage): add coverage in pr and compare with main
- Loading branch information
Showing
4 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -87,12 +87,13 @@ jobs: | |
shell: /usr/bin/bash -e {0} | ||
|
||
- name: Add formatted table to PR comment | ||
uses: GrantBirki/[email protected] | ||
continue-on-error: true | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
comment-id: ${{ github.event.comment.id }} | ||
edit-mode: replace | ||
file: stryker-report.md | ||
message-path: stryker-report.md | ||
update-only: false | ||
refresh-message-position: true | ||
allow-repeats: false | ||
message-id: 'add-pr-stryker-comment-${{ github.event.pull_request.number }}' | ||
|
||
- name: Deploy HTML Report to GitHub Pages | ||
env: | ||
|
This file contains 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,6 +14,9 @@ jobs: | |
# unit tests | ||
units: | ||
runs-on: ubuntu-latest | ||
env: | ||
covGistPrefix: 'https://gist.githubusercontent.com/stenjo/9ce1ad7d8e9db99796e782b244eefa4a/raw/f52cd85b82dd774ba0ce9d052f7ff2be505ea2d0' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
|
@@ -48,6 +51,7 @@ jobs: | |
echo "Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}" | ||
echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}" | ||
echo "Summary HTML - ${{ steps.coverageComment.outputs.summaryHtml }}" | ||
mv coverage/coverage-summary.json . | ||
- name: Create the Badge | ||
uses: schneegans/[email protected] | ||
|
@@ -61,6 +65,37 @@ jobs: | |
color: ${{ steps.coverageComment.outputs.color }} | ||
namedLogo: jest | ||
|
||
- name: Gist Sync File | ||
uses: danielmcconville/[email protected] | ||
if: steps.branch-name.outputs.current_branch == 'main' | ||
with: | ||
gistPat: ${{ secrets.GIST_AUTH_TOKEN }} | ||
action: update | ||
filename: coverage-summary.json | ||
gistId: 9ce1ad7d8e9db99796e782b244eefa4a | ||
|
||
- name: Get coverage Gist | ||
if: steps.branch-name.outputs.current_branch != 'main' | ||
run: | | ||
curl -o main-coverage.json ${{ env.covGistPrefix }}/coverage-summary.json | ||
function diff { diff="$(echo "$2" - "$1" | bc -l | sed -e 's/^\./0./' -e 's/^-\./-0./')"; echo "$diff"; } | ||
current=$(jq .total.lines.pct coverage-summary.json) | ||
main=$(jq .total.lines.pct main-coverage.json) | ||
pctLineChange=$(diff "$main" "$current") | ||
echo '**Code Coverage change**' > coverage.md | ||
echo 'This PR changes coverage by' "$pctLineChange" '%' >> coverage.md | ||
echo 'Component coverage will change from ' "$main"'% to ' "$current"'%.' >> coverage.md | ||
echo "$(<coverage.md)" | ||
- name: Add PR Comment with coverage diff | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message-path: coverage.md | ||
update-only: false | ||
refresh-message-position: true | ||
allow-repeats: false | ||
message-id: 'add-pr-diff-comment-${{ github.event.pull_request.number }}' | ||
|
||
# test action works running from the graph | ||
test: | ||
runs-on: ubuntu-latest | ||
|
This file contains 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 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