Skip to content

Commit

Permalink
Create coverage-local.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmafelix authored Mar 20, 2024
1 parent 5523c82 commit 9f6840b
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/coverage-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Add this line

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
Rscript -e "writeLines(covr::coverage_to_list()$totalcoverage, '${{ runner.temp }}/package/local_cov.Rout'"
shell: Rscript {0}

- name: Get Values
id: get-values
shell: bash
run: |
COV=$(echo '${{ runner.temp }}/package/local_conv.Rout')
echo "coverage=$COV" >> $GITHUB_OUTPUT
- name: Checkout gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages

- name: Create Badges
shell: bash
run: |
npm i -g badgen-cli
export COV=${{ steps.get-values.outputs.coverage }}
COLOR=$(node -p '+process.env.COV >= 95 ? `green` : `orange`')
mkdir -p badges
badgen -j coverage -s $COV% -c $COLOR > badges/coverage.svg
- name: Deploy Badges
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Update badges [skip ci]"
branch: gh-pages
skip_fetch: true
skip_checkout: true

# Without this, will get Error:
# Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/coverage-badge-action/coverage-badge-action/action.yml'.
# Did you forget to run actions/checkout before running your local action?
- name: Checkout Back
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}

0 comments on commit 9f6840b

Please sign in to comment.