Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address ropensci review #213

Merged
merged 51 commits into from
Jan 15, 2020
Merged

Address ropensci review #213

merged 51 commits into from
Jan 15, 2020

Conversation

pat-s
Copy link
Member

@pat-s pat-s commented Jan 7, 2020

ropensci/software-review#305 (comment)

  • mention the difference between .com and .org -> new vignette "org-vs-com")

  • indeed, perhaps the default R_TRAVIS should be .com given the current changes to travis? -> changed in {travis}

  • During travis::travis_sync() the API token is pasted in the console and (although deleted form history) is still visible in the console. Could this be avoided in any way? -> done when refactoring {travis}

  • return early if do_* and step_* functions are called interactively

  • error and suggest to call use_tic() first when running dsl_init() in a repo without a tic.R

  • Make it possible to pass the endpoint arg from {travis} funs to use_tic()

  • README updates

  • all examples are not \dontrun because dsl_init() only works within a project


Because of

https://github.com/ropenscilabs/tic/blob/834b30f0c63b004015154bfb94fd8c30b18cb5c8/R/stage.R#L35-L45

I had to move {usethis} from suggests to imports. Otherwise {usethis} is missing as it is not yet installed in the "install" step as a dep when being called in tic::prepare_stages().

I would like to avoid this actually but we are using quite a bit of {usethis} internally all over the place and maybe we should just have it in imports.

@pat-s pat-s requested a review from krlmlr January 8, 2020 11:58
@krlmlr
Copy link
Collaborator

krlmlr commented Jan 12, 2020

I resolved conflicts and tentatively undid the code changes. We can discuss.

This is what a call to do_bookdown() looks like now:

tic::do_bookdown()
#> Using TRAVIS_DEPLOY_KEY env var as the private key name for SSH deployment.
#> ✓ Creating a blank tic stage configuration
#> ℹ tic configuration
#> ── install ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stage ──
#> ▶ step_install_deps(repos = repo_default())
#> ── deploy ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stage ──
#> ▶ step_build_bookdown()

Created on 2020-01-12 by the reprex package (v0.3.0)

We can add a note that points to ?tic::use_tic here.

Testing for interactive code is brittle: users might want to run tic::run_all_stages() in their interactive session.

I also don't think that {tic} should unconditionally require a DESCRIPTION. Rather it's the responsibility of the steps to check that a file is available, and err appropriately. Perhaps in their "prepare" step? (The "troubleshooting" section needs to mention prepare_all_stages() I think.)

Perhaps we should link more prominently to the "troubleshooting" section, to assist first time users? Or move "troubleshooting: local runs" to the "Get started" document?

@krlmlr
Copy link
Collaborator

krlmlr commented Jan 12, 2020

Regarding proj_get(): Again, I think tic can expect to find a tic.R and everything else in its working directory, at least on the CI system. What motivated the change here?

@krlmlr
Copy link
Collaborator

krlmlr commented Jan 12, 2020

Currently:

tic::do_bookdown()
#> Using TRAVIS_DEPLOY_KEY env var as the private key name for SSH deployment.
#> ✓ Creating a clean tic stage configuration
#> ℹ See `?tic::dsl_get` for details
#> 
#> ── tic configuration ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
#> ── install ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stage ──
#> ▶ step_install_deps(repos = repo_default())
#> ── deploy ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── stage ──
#> ▶ step_build_bookdown()

Created on 2020-01-12 by the reprex package (v0.3.0)

The help page explains what's going on, pointing to the tic.R file and the vignette.

Checking DESCRIPTION in steps that need it. Added prepare_all_stages() to troubleshooting. Added one more link to troubleshooting.

@krlmlr
Copy link
Collaborator

krlmlr commented Jan 12, 2020

@pat-s: I can't request your review. Could you please take a look?

@pat-s
Copy link
Member Author

pat-s commented Jan 13, 2020

Regarding proj_get(): Again, I think tic can expect to find a tic.R and everything else in its working directory, at least on the CI system. What motivated the change here?

The motivation came from the ropensci review where Anna tried calling some tic functions on a new repo without a tic.R file - i.e. no run of use_tic() as the first action.

This is what a call to do_bookdown() looks like now:

Should we expand the message something like: "We detected you are running XYZ interactively, which is not supported. See ?tic::dsl_get for details."?

I think we have room to improve the documentation on how to use {tic} interactively even though we have https://docs.ropensci.org/tic/articles/advanced.html#emulating-a-ci-run-locally already:

  • mention to not call steps/macros standalone
  • use tic::run_stage("<stage>") or tic::run_all_stages()

This would have helped Anna in her review I assume. We should also prominently link such a resource in interactive calls to macros/steps like the one above. What do you think?

@@ -4,17 +4,22 @@ LocalCI <- R6Class(

public = list(
get_branch = function() {
system2("git", "rev-parse --abbrev-ref HEAD", stdout = TRUE)
suppressWarnings(system2("git", "rev-parse --abbrev-ref HEAD", stdout = TRUE))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment what we are suppressing here?

Comment on lines +16 to +22
tryCatch(
{
remote <- gh::gh_tree_remote()
paste0(remote$username, "/", remote$repo)
},
error = ""
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What motivated this tryCatch?

@@ -23,7 +28,7 @@ LocalCI <- R6Class(
NULL
},
get_commit = function() {
git2r::revparse_single(revision = "HEAD")$sha
tryCatch(git2r::revparse_single(revision = "HEAD")$sha, error = "")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What motivated this tryCatch?

@@ -9,6 +9,9 @@ InstallDeps <- R6Class(
},

prepare = function() {
if (!file.exists("DESCRIPTION")) {
stopc("No DESCRIPTION file found. The step_install_deps step and the do_package_checks macro are only available for packages.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently like to format error messages as

cli_alert_danger("<extended descriptive message>")
stopc("No DESCRIPTION file found.")

The advantage is that you can wrap the extended description and also use cli formatting in it. The plain message in the stop call is then just to state the main reason of the error.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rlang conditions are better here, see ?rlang::cnd_body . Here I'm using the pattern you're suggesting, for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks promising.

@pat-s pat-s changed the title Address ropensci review Address ropensci review Jan 15, 2020
@pat-s pat-s merged commit a699f22 into master Jan 15, 2020
@pat-s pat-s deleted the ropensci-review branch January 15, 2020 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use_tic(): Ensure that a DESCRIPTION file is present
2 participants