lockedata / starters

R Package πŸ“¦ for initializing projects for various R activities :nut_and_bolt:
https://itsalocke.com/starters/
GNU General Public License v3.0
124 stars 16 forks source link

Add retries for repo creation #115

Closed maelle closed 5 years ago

maelle commented 5 years ago

cf #108 #109

maelle commented 5 years ago

I am about to add a test with mocking, for now I had removed my GITHUB_PAT and obtained

> folder <- tempdir()
> starters::createPackageProject("coolcool", 
+                                folder = folder,
+                                external_setup = list(
+                                  git_service = "GitHub",
+                                  login = "maelle",
+                                  private = FALSE,
+                                  protocol = "ssh",
+                                  ci_activation = "travis"
+                                ))
βœ” Setting active project to '/home/maelle/Documents/locke_data/starters'
βœ” Setting active project to '/tmp/Rtmpaso4Pa/coolcool'
βœ” Creating 'R/'
βœ” Creating 'man/'
βœ” Writing 'DESCRIPTION'
Package: coolcool
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R (parsed):
    * MaΓ«lle Salmon [cre, aut] (0000-0002-2815-0399)
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
βœ” Writing 'NAMESPACE'
βœ” Writing 'coolcool.Rproj'
βœ” Adding '.Rproj.user' to '.gitignore'
βœ” Adding '^coolcool\\.Rproj$', '^\\.Rproj\\.user$' to '.Rbuildignore'
βœ” Setting active project to '<no active project>'
βœ” Setting active project to '/tmp/Rtmpaso4Pa/coolcool'
βœ” Writing 'CODE_OF_CONDUCT.md'
βœ” Adding '^CODE_OF_CONDUCT\\.md$' to '.Rbuildignore'
● Don't forget to describe the code of conduct in your README:
  Please note that the 'coolcool' project is released with a
  [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
  By contributing to this project, you agree to abide by its terms.
  [Copied to clipboard]
βœ” Writing 'LICENSE.md'
βœ” Adding '^LICENSE\\.md$' to '.Rbuildignore'
βœ” Writing 'LICENSE'
βœ” Writing 'R/coolcool-package.R'
βœ” Writing 'README.Rmd'
βœ” Adding Project Status: WIP - Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. badge to 'README.Rmd'
● Re-knit 'README.Rmd'
βœ” Adding 'testthat' to Suggests field in DESCRIPTION
βœ” Creating 'tests/testthat/'
βœ” Writing 'tests/testthat.R'
βœ” Adding 'knitr' to Suggests field in DESCRIPTION
βœ” Setting VignetteBuilder field in DESCRIPTION to 'knitr'
βœ” Adding 'inst/doc' to '.gitignore'
βœ” Creating 'vignettes/'
βœ” Adding '*.html', '*.R' to 'vignettes/.gitignore'
βœ” Adding 'rmarkdown' to Suggests field in DESCRIPTION
βœ” Writing 'vignettes/coolcool.Rmd'
● Modify 'vignettes/coolcool.Rmd'
βœ” Initialising Git repo
βœ” Adding '.Rhistory', '.RData' to '.gitignore'
There are 12 files uncommited files:
* '.gitignore'
* '.Rbuildignore'
* 'CODE_OF_CONDUCT.md'
* 'coolcool.Rproj'
* 'DESCRIPTION'
* 'LICENSE'
* 'LICENSE.md'
* 'NAMESPACE'
* 'R/'
* 'README.Rmd'
* 'tests/'
* 'vignettes/'
Is it ok to commit them?

1: Absolutely not
2: Definitely
3: Nope

Selection: 2
βœ” Adding files
βœ” Commit with message 'First commit of this sublime project, gee!'
βœ” Writing 'NEWS.md'
Trying to create GitHub repo, try 1
Trying to create GitHub repo, try 2
Trying to create GitHub repo, try 3
Trying to create GitHub repo, try 4
Trying to create GitHub repo, try 5
Error: GitHub repo creation failed.
Oops! An error was found and the `coolcool` directory was deleted
βœ” Setting active project to '/home/maelle/Documents/locke_data/starters'

which looks fine.

codecov-io commented 5 years ago

Codecov Report

Merging #115 into master will decrease coverage by 1.18%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #115      +/-   ##
==========================================
- Coverage    61.6%   60.42%   -1.19%     
==========================================
  Files          12       12              
  Lines         560      571      +11     
==========================================
  Hits          345      345              
- Misses        215      226      +11
Impacted Files Coverage Ξ”
R/github.R 29.09% <0%> (-7.28%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update f328160...a8f91f5. Read the comment docs.

codecov-io commented 5 years ago

Codecov Report

Merging #115 into master will decrease coverage by 1.5%. The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #115      +/-   ##
=========================================
- Coverage    61.6%   60.1%   -1.51%     
=========================================
  Files          12      12              
  Lines         560     574      +14     
=========================================
  Hits          345     345              
- Misses        215     229      +14
Impacted Files Coverage Ξ”
R/github.R 34.04% <0%> (-2.33%) :arrow_down:
R/utils.R 47.05% <0%> (-9.09%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update f022353...926afd3. Read the comment docs.

maelle commented 5 years ago

What do you mean? That two tests test it?

stephlocke commented 5 years ago

The same code from the function appears in the test file and there's no obvious expect_ with it image

maelle commented 5 years ago

Ah not sure how to create a function for this. What would its argument be?

In the test, it's indeed not a test, it's code for deleting the GitHub repo that was created during testing.

maelle commented 5 years ago

I'll try to work on such a function, passing hmmm gh arguments to it.

maelle commented 5 years ago

@stephlocke is it better with the new function? :-)

stephlocke commented 5 years ago

It's a definite improvement but I expect to see an expect_*() - if the gh stuff fails then you have a stop, the test process errors, it doesn't report an error as it should do.

Essentially:

ok <- gh_retry(quoted_expression)

  if (!ok){
    stop("GitHub repo deletion failed.")
  }

Should be like:

expect_true(gh_retry(quoted_expression))
maelle commented 5 years ago

@stephlocke ok to merge now?