Nate
Nate

Reputation: 10671

How to run covr::codecov() for a R package on Travis CI

I am trying to add Codecov support via library(covr) to my personal R package sesh.

When I check locally the coverage tests run and report without incident:

covr::package_coverage()
sesh Coverage: 68.75%
R/executeDevtoolDocument.R: 0.00%
R/sesh.R: 69.23%

But when it runs on Travis it encounters an error for missing token:

$ Rscript -e 'covr::codecov()'
Error in if (nzchar(token)) { : argument is of length zero 
Calls: <Anonymous>
Execution halted

The R CMD check runs successfully on Travis.

The contents of my .travis.yml:

language: R

matrix:
  include:
  - r: release
    after_success: Rscript -e 'covr::codecov()'

r_github_packages:
  - r-lib/covr

And a link to the most recent Travis report.

I have tried to faithfully follow the covr README for getting set up. And the README says Travis is supported without needing CODECOV_TOKEN, so I have not tried to pass one yet.

What am I missing here?

Upvotes: 2

Views: 409

Answers (2)

Nate
Nate

Reputation: 10671

Adding the repository upload token to codecov.yml avoids the error and successfully runs the coverage report.

codecov:
  token: a1c53d1f-266f-47bc-bb23-3b3d67c57b2d

The token is found in the 'Settings(tab) >>> General(sidebar)' menu on the Codecov page for the repo (which is only visible once you are logged in).

Upvotes: 0

kangaroo_cliff
kangaroo_cliff

Reputation: 6222

Following is my .travis.yml

language: r

cache: packages

script:
- R CMD build .
- R CMD check *tar.gz

r_github_packages:
  - r-lib/covr

after_success:
  - Rscript -e 'covr::codecov()'

Upvotes: 2

Related Questions