Skip to content

Commit

Permalink
test(meta): Add test coverage report (#4790)
Browse files Browse the repository at this point in the history
* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add test coverage report

* Add name to test coverage report
  • Loading branch information
hartra344 committed May 7, 2024
1 parent 6411b8a commit fcb6bfb
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 6 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/coverage-report.yml
@@ -0,0 +1,56 @@
name: Generate Coverage Report

on:
# push:
# branches: [coverageReport]
pull_request:
branches: [main, dev/*, hotfix/*]
jobs:
pr-coverage:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: 'Checkout Github Action'
uses: actions/checkout@master

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 20.x

- uses: pnpm/action-setup@v3
with:
version: 8
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- run: pnpm turbo run test:lib --cache-dir=.turbo -- --changed origin/main
- run: npx cobertura-merge-globby -o coverage.xml --files="**/cobertura-coverage.xml"
- name: Generate Coverage Report
uses: clearlyip/code-coverage-report-action@v4
id: code_coverage_report_action
with:
#Location of the generate coverage file
filename: 'coverage.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}
badge: true
fail_on_negative_difference: true
artifact_download_workflow_names: 'base-coverage'
- name: Add Coverage PR Comment
#Make sure the report was generated and that the event is actually a pull request, run if failed or success
uses: marocchino/sticky-pull-request-comment@v2
if: steps.code_coverage_report_action.outputs.file != '' && github.event_name == 'pull_request' && (success() || failure())
with:
recreate: true
path: code-coverage-results.md
2 changes: 2 additions & 0 deletions coverage.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions merge-lcov.sh
@@ -0,0 +1,10 @@
#!/bin/bash

files=`find ./ -name lcov.info`
args=""
for f in $files; do
prefix=`echo $f | sed -e s/coverage.lcov.info// | sed -e s#^\./##`
echo "fixing paths in $f"
sed -i.bak "s#^SF\:src#SF\:${prefix}src#g" $f
args="$args -a $f"
done
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -44,6 +44,7 @@
"jsdom": "^24.0.0",
"jsonc-eslint-parser": "^2.4.0",
"just-pnpm": "^1.0.2",
"lcov-result-merger": "^5.0.0",
"lint-staged": "^15.2.2",
"react-test-renderer": "^18.2.0",
"replace-in-file": "^7.1.0",
Expand Down
24 changes: 18 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fcb6bfb

Please sign in to comment.