rostools / prodigenr

Project directory generator R package
http://rostools.github.io/prodigenr
Other
43 stars 13 forks source link

Add Travis build for macOS #103

Closed jdblischak closed 5 years ago

jdblischak commented 6 years ago

xref: #100

I updated the Travis configuration to run 3 separate builds:

  1. Release version of R on Linux (this is the current default)
  2. Devel version of R on Linux (to anticipate any issues with submission to CRAN)
  3. Release version of R on macOS

Furthermore, covr::codecov is only run for the first build.

Something strange is going on though. The builds should be failing because the the user.name and user.email have not been set, but the builds on my fork still passed!

https://travis-ci.org/jdblischak/prodigenr/builds/425341573

I realized that use_git() doesn't throw an error during R CMD check because it only tries to commit the files if interactive() is TRUE. I also updated the check introduced in commit 12f4c0ffa8d9c70dfe02f86faac0d4c1c0672613 to throw a warning of either user.name or user.email is not set. However, for some reason during the Travis build the warning is not triggered, even though I can trigger it locally by temporarily deleting my .gitconfig file and running devtools::test().

https://codecov.io/gh/jdblischak/prodigenr/src/travis-osx/R/setup_project.R#L41

Any idea what is going on?

lwjohnst86 commented 6 years ago

Wow, great PR! Thanks a lot!

As for what is going on.. I don't know. What about if you did the covr on the OSX build?

I also see you removed use_git(). This might have been causing my problem originally. What's your rationale for removing it? Do you think it would be better as another function? One point of the use_git() in the setup_project() was to get Git setup.

I also looked into whether Travis has Git config set... but it doesn't make it clear whether it does. There is an old issue discussing having git config set with some potential solutions. Maybe this would fix the problem when use_git()?

jdblischak commented 6 years ago

Wow, great PR! Thanks a lot!

Of course! Happy to help!

As for what is going on.. I don't know. What about if you did the covr on the OSX build?

I don't think that would be informative. We know the builds are behaving similarly on all the systems because they are all passing. It's better to run covr on a Linux machine because compute time is more available compared to macOS machines.

I also see you removed use_git(). This might have been causing my problem originally. What's your rationale for removing it? Do you think it would be better as another function? One point of the use_git() in the setup_project() was to get Git setup.

You called use_git() twice. Once before checking for user.name and user.email, and once after. The initial call will generate an error if the user runs it in an interactive session without user.name and user.email set:

> usethis::use_git_config()
$user.name
NULL

$user.email
NULL

> usethis::use_git()
✔ Initialising Git repo
✔ Adding files and committing
Error in default_signature(repo) : 
  Error in 'git2r_signature_default': config value 'user.name' was not found

As I mentioned above, the reason that this wasn't failing during the Travis build is that use_git() only tries to commit the files (which requires a user.name and user.email) if it is an interactive session.

https://github.com/r-lib/usethis/blob/v1.4.0/R/git.R#L23

I also looked into whether Travis has Git config set... but it doesn't make it clear whether it does. There is an old issue discussing having git config set with some potential solutions. Maybe this would fix the problem when use_git()?

It doesn't have it set. The solution is to define a user.name and user.email prior to building the package, but the tests should fail before we try to fix them. That is what I couldn't figure out.

lwjohnst86 commented 5 years ago

Erm, embarassing, I didn't see the two use_git calls... Thanks for that!

Ok, I now understand the problem that was occurring. You figured it out, thanks for that! I'll merge in :) Thanks again for the PR!

jdblischak commented 5 years ago

@lwjohnst86 It is still strange to me why the Codecov report shows that is.null(git_config$user.name) || is.null(git_config$user.email) evaluates to FALSE on Travis. But I can't think of anything obvious to try and fix that.

https://codecov.io/gh/lwjohnst86/prodigenr/src/32746b6d724e54f831fbaa4d7f60a522294f82f9/R/setup_project.R#L48

If in the future you'd like to configure Git on Travis so that your functions can run git2r::commit during the unit tests, you can add the following lines to .travis.yml:

before_install:
  - git config --global user.name "travis"
  - git config --global user.email "example@fakeemail.com"