name: test-coverage

on:
  push:
    branches: [main]
    paths: [ 'R/**', 'tests/**', '.github/workflows/cov.yml' ]
  pull_request:
    branches: [main]
    paths: [ 'R/**', 'tests/**', '.github/workflows/cov.yml' ]

jobs:
  test-coverage:
    runs-on: ubuntu-latest

    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: covr

      - name: Test coverage
        run: covr::codecov()
        shell: Rscript {0}
