Use codecov for tests coverage info

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2024-01-10 13:33:25 -08:00
parent 90e58b7b9f
commit dd07aefac5
1 changed files with 10 additions and 23 deletions

View File

@ -1,6 +1,6 @@
name: Coverage name: Coverage
on: on:
pull_request_target: pull_request:
jobs: jobs:
coverage: coverage:
@ -37,34 +37,21 @@ jobs:
grcov . \ grcov . \
--source-dir . \ --source-dir . \
--binary-path ./target/debug/ \ --binary-path ./target/debug/ \
--branch --ignore-not-existing \ --branch \
--output-types html,markdown \ --ignore-not-existing \
--output-types markdown,lcov \
--keep-only 'crates/*' \ --keep-only 'crates/*' \
--output-path ./target/coverage/ --output-path ./target/coverage/
- uses: actions/upload-artifact@v4 - name: Upload coverage data
uses: codecov/codecov-action@v3
with: with:
name: coverage token: ${{ secrets.CODECOV_TOKEN }}
path: target/coverage/html/ flags: unittests
if-no-files-found: error files: ./target/coverage/lcov
verbose: true
- name: Publish job summary - name: Publish job summary
run: | run: |
echo "# Coverage" >> $GITHUB_STEP_SUMMARY echo "# Coverage" >> $GITHUB_STEP_SUMMARY
cat target/coverage/markdown.md >> $GITHUB_STEP_SUMMARY cat target/coverage/markdown.md >> $GITHUB_STEP_SUMMARY
- run: echo "coverage=$(cat target/coverage/markdown.md | grep 'Total coverage')" >> $GITHUB_OUTPUT
id: coverage
- name: Create commit status
uses: actions/github-script@v7
if: success()
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: 'success',
description: '${{ steps.coverage.outputs.coverage }}',
})