Skip to content

Commit

Permalink
updates to codecov action
Browse files Browse the repository at this point in the history
addresses #122
  • Loading branch information
k-doering-NOAA committed May 30, 2024
1 parent 6fbec81 commit e9ad1ba
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/calc-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: true
inputs:
use-public-rspm:
required: false
Expand All @@ -24,9 +27,23 @@ jobs:

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

- name: Test coverage
run: covr::codecov(quiet = FALSE)
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions .github/workflows/call-calc-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ on:
jobs:
call-workflow:
uses: nmfs-fish-tools/ghactions4r/.github/workflows/calc-coverage.yml@main
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN}}
2 changes: 2 additions & 0 deletions inst/templates/call-calc-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ on: [push, pull_request]
jobs:
call-workflow:
uses: nmfs-fish-tools/ghactions4r/.github/workflows/calc-coverage.yml@main
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN}}
7 changes: 4 additions & 3 deletions vignettes/set_up.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Some workflows in `{ghactions4r}` take additional setup steps besides running th
1) Clone your R package locally.
2) In the local clone, run [ghactions4r::use_calc_coverage()](https://nmfs-fish-tools.github.io/ghactions4r/reference/use_calc_coverage.html) to generate the the github action file or any other files needed. Change the build triggers if desired.
3) Commit the files and push them up to GitHub. See if a github action runs. If it does not, try pushing to your main branch to trigger a run, if your build triggers include a run on pushing to the main branch (the default).
4) Set up an account on [codecov](https://about.codecov.io/) or [coveralls](https://coveralls.io/). For codecov, [create an account](https://docs.codecov.com/docs/github-2-getting-a-codecov-account-and-uploading-coverage#create-a-codecov-account), then install the [github app](https://docs.codecov.com/docs/github-2-getting-a-codecov-account-and-uploading-coverage#install-the-github-app-integration). For coveralls, [sign up to use OAuth through GitHub](https://coveralls.io/sign-up).
5) Try re-running your Code Coverage GitHub Action by pushing a new commit and see if your results go to the Codecov or Coveralls website. Note that if your tool is in an organization that is already using Codecov or Coveralls, you may not need to make an account.
6) Optionally, display a [code coverage status badge](https://docs.codecov.com/docs/status-badges) on your repository or make a [custom codecov.yml file](https://docs.codecov.com/docs/codecovyml-reference#coverage), if desired. The [Coveralls docs](https://docs.coveralls.io/) provide more information on custom options
4) Set up an account on [codecov](https://about.codecov.io/). For codecov, [create an account](https://docs.codecov.com/docs/github-2-getting-a-codecov-account-and-uploading-coverage#create-a-codecov-account), then install the [github app](https://docs.codecov.com/docs/github-2-getting-a-codecov-account-and-uploading-coverage#install-the-github-app-integration).
5) Add an [upload token as a secret](https://docs.codecov.com/docs/adding-the-codecov-token) to your GitHub repository. Name the secret `CODECOV_TOKEN`. Note that owner permissions are needed on GitHub to add the secret.
6) Try re-running your Code Coverage GitHub Action by pushing a new commit and see if your results go to the Codecov website. Note that if your tool is in an organization that is already using Codecov, you may not need to make an account.
7) Optionally, display a [code coverage status badge](https://docs.codecov.com/docs/status-badges) on your repository or make a [custom codecov.yml file](https://docs.codecov.com/docs/codecovyml-reference#coverage), if desired.

0 comments on commit e9ad1ba

Please sign in to comment.