-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate coverage tests and use cargo-tarpaulin (#290)
Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
- Loading branch information
Showing
3 changed files
with
59 additions
and
46 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
name: "Coverage" | ||
"on": | ||
push: | ||
branches: ["main"] | ||
paths-ignore: | ||
- '**.md' | ||
- '.wordlist.txt' | ||
pull_request: | ||
paths-ignore: | ||
- '**.md' | ||
- '.wordlist.txt' | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
tests-coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install build dependencies | ||
run: bash .github/workflows/install-dependencies | ||
- name: Setup toolchain (coverage) | ||
uses: dtolnay/rust-toolchain@nightly | ||
- name: Install cargo-tarpaulin (coverage) | ||
run: cargo install cargo-tarpaulin | ||
- name: Run tests (coverage) | ||
run: cargo tarpaulin -o Json | ||
env: | ||
RUSTFLAGS: --cfg procmacro2_semver_exempt | ||
- name: Output show (coverage) | ||
run: | | ||
set -eu | ||
coverage=$(cat tarpaulin-report.json | jq .coverage | egrep -o "[0-9]{1,2}\.{1}[0-9]{2}" | sed 's/ //g') | ||
echo "COVERAGE:${coverage}" | ||
env: | ||
COV_REPORT_DIR: ${{ steps.coverage.outputs.report }} | ||
- name: Report in PR status for the current commit (coverage) | ||
if: github.ref_name != 'main' | ||
run: | | ||
set -eu | ||
total=$(cat tarpaulin-report.json | jq .coverage | egrep -o "[0-9]{1,2}\.{1}[0-9]{2}" | sed 's/ //g') | ||
echo "TOTAL:${total}" | ||
curl -s "https://sarroutbi:${GITHUB_TOKEN}@api.github.com/repos/sarroutbi/koji-retriever/statuses/${COMMIT_SHA}"\ | ||
-d "{\"state\": \"success\",\"target_url\": \"https://github.com/sarroutbi/koji-retriever/pull/${PULL_NUMBER}/checks?check_run_id=${RUN_ID}\",\"description\": \"${total}%\",\"context\": \"Measured coverage\"}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COMMIT_SHA: ${{ github.event.pull_request.head.sha }} | ||
RUN_ID: ${{ github.run_id }} | ||
PULL_NUMBER: ${{ github.event.pull_request.number }} | ||
COV_REPORT_DIR: ${{ steps.coverage.outputs.report }} |
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