Skip to content

Commit

Permalink
Add code coverage measuring
Browse files Browse the repository at this point in the history
  • Loading branch information
danie1k committed Apr 14, 2022
1 parent 78ede2e commit 72236f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
args: kcov --include-path src/ codecov/ ./test/bats/bin/bats test/
- uses: actions/upload-artifact@v3
with:
name: code-coverage-report-${GITHUB_RUN_ID}
name: raw-code-coverage-report
path: codecov/

coverage:
Expand All @@ -36,22 +36,15 @@ jobs:
steps:
- uses: actions/download-artifact@v3
with:
name: code-coverage-report-${GITHUB_RUN_ID}
name: raw-code-coverage-report
path: codecov/
# https://github.com/particleflux/kcov-bats-circleci-codeclimate/blob/master/.circleci/config.yml
- run: |
xml="$(ls -1 codecov/bats*/cobertura.xml | head -1)"
json="$(ls -1 codecov/bats*/coverage.json | head -1)"
# removing trailing slash in cobertura <source>
# this works around an issue with the codeclimate formatter
sed -r "s#<source>(.+)/</source>#<source>\1</source>#" "$xml" > cobertura_tmp.xml
# make paths relative
sed -r "s#/github/workspace##" cobertura_tmp.xml > cobertura.xml
sed -r "s#/github/workspace##" "$json" > coverage.json
_re='s#"bats"#"src"#;s#/github/workspace/##;s#<source>(.+)/</source>#<source>/github/workspace/</source>#'
sed -r "$_re" "$(ls -1 codecov/bats*/cobertura.xml | head -1)" > coverage.xml
- uses: codecov/codecov-action@v2
# https://github.com/SimonKagstrom/kcov/blob/master/doc/codecov.md
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./cobertura.xml,./coverage.json
files: ./coverage.xml
fail_ci_if_error: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Lint](https://github.com/danie1k/rsync-backup/actions/workflows/lint.yml/badge.svg)](https://github.com/danie1k/rsync-backup/actions/workflows/lint.yml)
[![Test](https://github.com/danie1k/rsync-backup/actions/workflows/test.yml/badge.svg)](https://github.com/danie1k/rsync-backup/actions/workflows/test.yml)
[![Code Coverage](https://codecov.io/gh/danie1k/rsync-backup/branch/master/graph/badge.svg?token=07IXMZ0DWO)](https://codecov.io/gh/danie1k/rsync-backup)
[![MIT License](https://img.shields.io/github/license/danie1k/rsync-backup)](https://github.com/danie1k/rsync-backup/blob/master/LICENSE)

# rsync-backup
Expand Down

0 comments on commit 72236f2

Please sign in to comment.