Skip to content

Commit

Permalink
Merge branch 'master' into feature/release-args
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Müller committed Mar 7, 2016
2 parents a996424 + b6a23be commit 16a880d
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 28 deletions.
33 changes: 24 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
## Contributing to devtools

The goal of this guide is to help you contributing to devtools as quickly and easily. The guide is divided into two main pieces:
The goal of this guide is to help you contribute to devtools as quickly and as easily possible. The guide is divided into two main pieces:

1. Filing a bug report or feature request in an issue.
1. Suggesting a change via a pull request.

## Issues

Before you file an issue:

1. Check that you're using the latest version of devtools. It's quite
possible that the problem you're experiencing has already been fixed.

1. Spend a few minutes looking at the existing issues. It's possible that
your issue has already been filed. But it's almost always better to open
a new issue instead of commenting on an existing issue. The only exception
is that you are confident that your issue is identical to an existing
problem, and your contribution will help us better understand the general
case. It's generally a bad idea to comment on a closed issue or a commit.
Those comments don't show up in the issue tracker and are easily misplaced.

When filing an issue, the most important thing is to include a minimal reproducible example so that we can quickly verify the problem, and then figure out how to fix it. There are three things you need to include to make your example reproducible: required packages, data, code.

1. **Packages** should be loaded at the top of the script, so it's easy to
Expand Down Expand Up @@ -41,16 +54,12 @@ When filing an issue, the most important thing is to include a minimal reproduci
and ```` ``` ```` so it's syntax highlighted (which makes it easier to
read).

1. Check that you've actually made a reproducible example by starting up a
fresh R session and pasting your code in.

It's almost always better to open a new issue instead of commenting on an existing issue. The only exception is that you are confident that the two issues are examples of the same underlying phenomenon, and your contribution will help us better understand the general cases. It's generally a bad idea to comment on a closed issue or a commit. Those comments don't show up in the issue tracker and are easily misplaced.
1. Check that you've actually made a reproducible example by using
the [reprex package](https://github.com/jennybc/reprex).

## Pull requests

I understand that it's frustrating that I will ignore your PR for months, and then request a whole bunch on changes within a short time period. Don't worry - if your PR doesn't make it for this release, it will for the next one.

* Your pull request will be easiest for me to read if you use a common
* Your pull request will be easiest for us to read if you use a common
style: <http://r-pkgs.had.co.nz/r.html#style>. Please pay particular
attention to whitespace.

Expand All @@ -59,6 +68,10 @@ I understand that it's frustrating that I will ignore your PR for months, and th
Please don't add headings like "bug fix" or "new features" - these are
added during the release process.

* If you can, also write a test. Testing devtools is particularly difficult
because most devtools functions are called for their side-effects, but do
the best you can.

* If you're adding new parameters or a new function, you'll also need
to document them with [roxygen2](http://r-pkgs.had.co.nz/man.html).
Make sure to re-run `devtools::document()` on the code before submitting.
Expand All @@ -73,11 +86,13 @@ A pull request is a process, and unless you're a practiced contributor it's unli

1. We'll take a closer look at the code and give you feedback.

1. You respond to our feedback, update the pull request and add a comment like
1. You respond to our feedback, update the pull request and add a comment
like "PTAL" (please take a look). Adding the comment is important,
otherwise we don't get any notification that your pull request is
ready for review.

Don't worry if your pull request isn't perfect. It's a learning process and we'll be hand to help you out.

It can be frustrating that your PR is ignored for months, and then we request a whole bunch on changes within a short time period. Don't worry - if your PR doesn't make it for this release, it will for the next one.

[markdown]: https://help.github.com/articles/basic-writing-and-formatting-syntax/
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export(use_news_md)
export(use_package)
export(use_package_doc)
export(use_rcpp)
export(use_readme_md)
export(use_readme_rmd)
export(use_revdep)
export(use_rstudio)
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
to allow passing `args = "--compact-vignettes=both"` for packages with
heavy PDF vignettes (@krlmlr, #1077).

* `revdep_check()` outputs a status message giving elapsed and estimated
remaining time every 10 packages.

* `revdep_check()` is can now be resumed after a failure - this should be a
big time saver if something goes unexpected wrong in the middle of the checks.
You can resume a partial check with `revdep_check_resume()` or blow away the
Expand Down Expand Up @@ -41,7 +44,7 @@
* Deprecated `use_coveralls()`, `add_rstudio_project()`,
`add_test_infrastructure()`, and `add_travis()` have been removed.

* `revdep_check_save_summary()` now creates `index.md` to save one level
* `revdep_check_save_summary()` now creates `README.md` to save one level
of clicking in github.

* `use_coverage()` now adds covr to suggests, rather than recommending you
Expand Down
13 changes: 9 additions & 4 deletions R/build-dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ has_src <- function(pkg = ".") {
file.exists(src_path)
}

has_latex <- function() {
nzchar(Sys.which("pdflatex"))
}

check_build_tools <- function(pkg = ".") {
if (!has_src(pkg)) {
return(TRUE)
Expand All @@ -30,3 +26,12 @@ check_build_tools <- function(pkg = ".") {
}
}

has_latex <- function(verbose = FALSE) {
has <- nzchar(Sys.which("pdflatex"))
if (!has && verbose) {
message("pdflatex not found! Not building PDF manual or vignettes.\n",
"If you are planning to release this package, please run a check with ",
"manual and vignettes beforehand.\n")
}
has
}
5 changes: 1 addition & 4 deletions R/build.r
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ build <- function(pkg = ".", path = NULL, binary = FALSE, vignettes = TRUE,
} else {
args <- c(args, "--no-resave-data")

if (manual && !has_latex()) {
message("pdflatex not found! Not building PDF manual or vignettes.\n",
"If you are planning to release this package, please run a check with ",
"manual and vignettes beforehand.\n")
if (manual && !has_latex(verbose = TRUE)) {
manual <- FALSE
}

Expand Down
21 changes: 21 additions & 0 deletions R/check-cran.r
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ check_cran <- function(pkgs, libpath = file.path(tempdir(), "R-lib"),
}

rule("Checking packages") # --------------------------------------------------
check_start <- Sys.time()
pkg_names <- format(pkgs)
check_pkg <- function(i) {
start_time <- Sys.time()
Expand All @@ -93,6 +94,8 @@ check_cran <- function(pkgs, libpath = file.path(tempdir(), "R-lib"),
end_time <- Sys.time()

message("Checked ", pkg_names[i], ": ", summarise_check_results(res, colour = TRUE))
status_update(i, length(pkgs), check_start)

elapsed_time <- as.numeric(end_time - start_time, units = "secs")
writeLines(
sprintf("%d %s %.1f", i, pkgs[i], elapsed_time),
Expand All @@ -115,3 +118,21 @@ check_cran <- function(pkgs, libpath = file.path(tempdir(), "R-lib"),
invisible(check_dir)
})
}

status_update <- function(i, n, start_time) {
if (i %% 10 != 0)
return()

hm <- function(x) {
sprintf("%02i:%02i", x %/% 3600, x %% 3600 %/% 60)
}

elapsed <- as.numeric(Sys.time() - start_time, units = "secs")
estimated <- elapsed / i * (n - i)

msg <- sprintf(
"Checked %i/%i. Elapsed %s. Remaining ~%s",
i, n, hm(elapsed), hm(estimated)
)
message(msg)
}
2 changes: 1 addition & 1 deletion R/compile-dll.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
compile_dll <- function(pkg = ".", quiet = FALSE) {
pkg <- as.package(pkg)

old <- withr::with_envvar(compiler_flags(TRUE), {
old <- withr_with_envvar(compiler_flags(TRUE), {

if (!needs_compile(pkg)) return(invisible())
compile_rcpp_attributes(pkg)
Expand Down
7 changes: 4 additions & 3 deletions R/infrastructure.R
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ use_readme_rmd <- function(pkg = ".") {
invisible(TRUE)
}

#' @export
#' @rdname use_readme_rmd
use_readme_md <- function(pkg = ".") {
pkg <- as.package(pkg)
Expand Down Expand Up @@ -654,7 +655,7 @@ use_template <- function(template, save_as = template, data = list(),

path <- file.path(pkg$path, save_as)
if (!can_overwrite(path)) {
stop("`", path, "` already exists.", call. = FALSE)
stop("`", save_as, "` already exists.", call. = FALSE)
}

template_path <- system.file("templates", template, package = "devtools",
Expand All @@ -666,12 +667,12 @@ use_template <- function(template, save_as = template, data = list(),

if (ignore) {
message("* Adding `", save_as, "` to `.Rbuildignore`.")
use_build_ignore(path, pkg = pkg)
use_build_ignore(save_as, pkg = pkg)
}

if (open) {
message("* Modify `", save_as, "`.")
open_in_rstudio(path)
open_in_rstudio(save_as)
}

invisible(TRUE)
Expand Down
6 changes: 2 additions & 4 deletions R/load-code.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ load_code <- function(pkg = ".") {
}
on.exit(cleanup())

withr::with_dir(file.path(pkg$path), source_many(paths, env))
withr_with_dir(file.path(pkg$path), source_many(paths, env))
success <- TRUE

invisible(r_files)
Expand All @@ -41,7 +41,7 @@ find_code <- function(pkg = ".") {
path_r <- file.path(pkg$path, "R")

code_paths <- dir(path_r, "\\.[Rrq]$", full.names = TRUE)
r_files <- withr::with_collate("C", sort(code_paths))
r_files <- withr_with_collate("C", sort(code_paths))

if (!is.null(pkg$collate)) {
collate <- file.path(path_r, parse_collate(pkg$collate))
Expand All @@ -62,5 +62,3 @@ find_code <- function(pkg = ".") {
}
r_files
}


2 changes: 1 addition & 1 deletion R/revdep-summarise.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ revdep_check_save_summary <- function(pkg = ".") {
pkg <- as.package(pkg)

md <- revdep_check_summary_md(pkg)
writeLines(md, file.path(pkg$path, "revdep", "index.md"))
writeLines(md, file.path(pkg$path, "revdep", "README.md"))
}

revdep_check_summary_md <- function(pkg) {
Expand Down
8 changes: 8 additions & 0 deletions R/zzz.r
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,13 @@ NULL
toset <- !(names(op.devtools) %in% names(op))
if(any(toset)) options(op.devtools[toset])

# These withr functions are used in load_all() so need to exist in the
# devtools namespace so the withr namespace is not prematurly loaded by `::`
# during a load_all() call
env <- asNamespace(pkgname)
assign("withr_with_dir", withr::with_dir, envir = env)
assign("withr_with_collate", withr::with_collate, envir = env)
assign("withr_with_envvar", withr::with_envvar, envir = env)

invisible()
}
3 changes: 2 additions & 1 deletion inst/templates/travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: r
language: R
sudo: false
cache: packages

0 comments on commit 16a880d

Please sign in to comment.