r-lib / covr

Test coverage reports for R
https://covr.r-lib.org
Other
335 stars 115 forks source link

covr::coveralls() from github actions? #457

Open dblodgett-usgs opened 3 years ago

dblodgett-usgs commented 3 years ago

I consistently get:

 Error in covr::coveralls() : 
  Failed to upload coverage data. Reply by Coveralls: Couldn't find a repository matching this job.

Has anyone been able to get coveralls() working from github actions with this function? Possibly a way to pass parameters to make it work without any code modification? I've not been able to find any examples.

Scanning the code for covr::coveralls(), it appears that it is pretty specific to a travis-ci and possibly jenkins based CI environment. I'm having no luck getting it working and really like to maintain my history in coveralls if that's possible.

It seems like there are two options -- 1) add github-actions logic to covr::coveralls() or 2) write a file that would be compatible with the coveralls action.

I think #442 is more or less calling for (2)?

I'm not versed in LCOV -- how far is the output of this: from being an LCOV file? https://github.com/r-lib/covr/blob/master/R/coveralls.R#L43

jimhester commented 3 years ago

Are you supplying an explicit repo_token and service_name to covr::coveralls()?

dblodgett-usgs commented 3 years ago

Tried repo_token, but it wasn't clear what the service_name should be. Am I missing some documentation on that?

dblodgett-usgs commented 3 years ago

Tested with service_name = github-actions which is what appears in some googling .. no dice. https://github.com/dblodgett-usgs/nhdplusTools/runs/1455018761

jefferis commented 3 years ago

@dblodgett-usgs did you get anywhere with this in the end? I am in the same boat with a coveralls history. Thanks!

dblodgett-usgs commented 3 years ago

No. I just switched to codecov and moved on. https://github.com/USGS-R/nhdplusTools/blob/master/.github/workflows/R-CMD-check.yaml#L76

jefferis commented 3 years ago

OK! Thanks for confirming.

adigherman commented 3 years ago

I got this working (finally).

Workflow steps:

helgasoft commented 2 years ago

@adigherman, WOW, hats off - master stroke! 👑 The only thing I struggled with was the token. Coveralls have two types of tokens - api and repo. What worked for me was the API token. 1) generated it from https://coveralls.io/account under "PERSONAL API TOKENS" 2) in GitHub > Secrets > created a New repository secret called 'COVERALLS_API' 3) placed COVERALLS_API in the YAML env section like so:

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      COVERALLS_TOKEN: ${{ secrets.COVERALLS_API }}

4) In YAML I added your code just as it is.

Thank you for the time spent on this tip!

daattali commented 1 year ago

Another vote to having some documentation about how to use coveralls in github actions. This package explicitly mentions that it works for codecov AND coveralls, and the README says to use usethis::use_github_action("test-coverage") but it doesn't say anything about the fact that this line will only use codecov and how it can be modified to use coveralls instead.

daattali commented 1 year ago

I can confirm that in order to get coveralls working in a GitHub Action, the following steps worked for me (in a private repository, so this should work for anyone):

daattali commented 1 year ago

@helgasoft @adigherman when you used coveralls with github actions, did you get the badge to work? I'm getting "unknown" in the badge, and I suspect it potentially could be because of sending it as "jenkins" and not grabbing the right branch or something similar.

helgasoft commented 1 year ago

yes, badge is working. with YAML file to look at.

daattali commented 1 year ago

Ah you found out the secret ingredient, that I just figured out myself after looking at coveralls documentation. "CI_BRANCH" envvar is required. So you hardcoded it in, which works for us as a one-off, but {covr} really should make this work better. I'll open up an issue to resolve this so that people don't need to manipulate their environments so much.