Skip to content

Commit

Permalink
Add use_coverage() function
Browse files Browse the repository at this point in the history
To add codecov.io or coveralls.io to a project, also deprecate
`use_coveralls()`.

Closes r-lib#818
  • Loading branch information
jimhester committed May 29, 2015
1 parent 2cca68d commit 0840e0b
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 31 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -123,6 +123,7 @@ export(update_packages)
export(use_appveyor)
export(use_build_ignore)
export(use_code_of_conduct)
export(use_coverage)
export(use_coveralls)
export(use_cran_badge)
export(use_cran_comments)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Expand Up @@ -3,6 +3,8 @@
* Fix use of `uses_git()` in `use_readme_rmd()` (#793).

* `build_vignettes()` gains dependencies argument (#825, @krlmlr).
* Add `use_coverage()` function to add codecov.io or coveralls.io to a project,
deprecate `use_coveralls()` (@jimhester, #822, #818).

# devtools 1.8.0

Expand Down
65 changes: 48 additions & 17 deletions R/infrastructure.R
Expand Up @@ -169,11 +169,20 @@ use_travis <- function(pkg = ".") {
invisible(TRUE)
}

#' @rdname infrastructure
#' @rdname devtools-deprecated
#' @section \code{use_coveralls}:
#' Add coveralls to basic travis template to a package.
#' @export
use_coveralls <- function(pkg = ".") {
.Deprecated("use_coverage(type = \"coveralls\")")
use_coverage(pkg, type = "coveralls")
}

#' @rdname infrastructure
#' @section \code{use_coverage}:
#' Add test code coverage to basic travis template to a package.
#' @export
use_coverage <- function(pkg = ".", type = c("codecov", "coveralls")) {
pkg <- as.package(pkg)

path <- file.path(pkg$path, ".travis.yml")
Expand All @@ -183,22 +192,44 @@ use_coveralls <- function(pkg = ".") {

travis_content <- readLines(file.path(pkg$path, ".travis.yml"))

if (any(grepl("coveralls()", travis_content))) {
stop("coveralls information already added to .travis.yml", call. = FALSE)
}

gh <- github_info(pkg$path)
message("Adding coveralls information into .travis.yml for ", pkg$package, ". Next: \n",
" * Turn on coveralls for this repo at https://coveralls.io/repos/new\n",
" * Add a coveralls shield to your README.md:\n",
"[![Coverage Status]",
"(https://img.shields.io/coveralls/", gh$username, "/", gh$repo, ".svg)]",
"(https://coveralls.io/r/", gh$username, "/", gh$repo, "?branch=master)\n",
" * Add the following to .travis.yml:\n",
"r_github_packages:\n",
" - jimhester/covr\n",
"after_success:\n",
" - Rscript -e 'library(covr);coveralls()'")
type <- match.arg(type)

switch(type,
codecov = {
if (any(grepl("codecov", travis_content))) {
stop("codecov information already added to .travis.yml", call. = FALSE)
}

gh <- github_info(pkg$path)
message("Adding codecov information into .travis.yml for ", pkg$package, ". Next: \n",
"[![Coverage Status]",
"(https://img.shields.io/codecov/c/github/", gh$username, "/", gh$repo, "/master.svg)]",
"(https://codecov.io/github/", gh$username, "/", gh$repo, "?branch=master)\n",
" * Add the following to .travis.yml:\n",
"r_github_packages:\n",
" - jimhester/covr\n",
"after_success:\n",
" - Rscript -e 'covr::codecov()'")
},

coveralls = {
if (any(grepl("coveralls", travis_content))) {
stop("coveralls information already added to .travis.yml", call. = FALSE)
}

gh <- github_info(pkg$path)
message("Adding coveralls information into .travis.yml for ", pkg$package, ". Next: \n",
" * Turn on coveralls for this repo at https://coveralls.io/repos/new\n",
" * Add a coveralls shield to your README.md:\n",
"[![Coverage Status]",
"(https://img.shields.io/coveralls/", gh$username, "/", gh$repo, ".svg)]",
"(https://coveralls.io/r/", gh$username, "/", gh$repo, "?branch=master)\n",
" * Add the following to .travis.yml:\n",
"r_github_packages:\n",
" - jimhester/covr\n",
"after_success:\n",
" - Rscript -e 'covr::coveralls()'")
})

invisible(TRUE)
}
Expand Down
7 changes: 7 additions & 0 deletions R/zzz.r
Expand Up @@ -32,6 +32,13 @@
#' @name devtools
NULL

#' Deprecated Functions
#'
#' These functions are Deprecated in this release of devtools, they will be
#' marked as Defunct and removed in a future version.
#' @name devtools-deprecated
NULL

.onLoad <- function(libname, pkgname) {
op <- options()
op.devtools <- list(
Expand Down
8 changes: 4 additions & 4 deletions man/infrastructure.Rd
Expand Up @@ -7,7 +7,7 @@
\alias{infrastructure}
\alias{use_appveyor}
\alias{use_code_of_conduct}
\alias{use_coveralls}
\alias{use_coverage}
\alias{use_cran_badge}
\alias{use_cran_comments}
\alias{use_package_doc}
Expand All @@ -32,7 +32,7 @@ use_rcpp(pkg = ".")

use_travis(pkg = ".")

use_coveralls(pkg = ".")
use_coverage(pkg = ".", type = c("codecov", "coveralls"))

use_appveyor(pkg = ".")

Expand Down Expand Up @@ -95,9 +95,9 @@ Add basic travis template to a package. Also adds \code{.travis.yml} to
\code{.Rbuildignore} so it isn't included in the built package.
}

\section{\code{use_coveralls}}{
\section{\code{use_coverage}}{

Add coveralls to basic travis template to a package.
Add test code coverage to basic travis template to a package.
}

\section{\code{use_appveyor}}{
Expand Down
3 changes: 1 addition & 2 deletions man/use_build_ignore.Rd
Expand Up @@ -33,8 +33,7 @@ Other infrastructure: \code{\link{add_rstudio_project}},
\code{\link{add_travis}}, \code{\link{add_travis}},
\code{\link{infrastructure}}, \code{\link{use_appveyor}},
\code{\link{use_code_of_conduct}},
\code{\link{use_coveralls}},
\code{\link{use_cran_badge}},
\code{\link{use_coverage}}, \code{\link{use_cran_badge}},
\code{\link{use_cran_comments}},
\code{\link{use_package_doc}}, \code{\link{use_rcpp}},
\code{\link{use_revdep}}, \code{\link{use_rstudio}},
Expand Down
3 changes: 1 addition & 2 deletions man/use_data.Rd
Expand Up @@ -47,8 +47,7 @@ Other infrastructure: \code{\link{add_build_ignore}},
\code{\link{add_travis}}, \code{\link{add_travis}},
\code{\link{infrastructure}}, \code{\link{use_appveyor}},
\code{\link{use_code_of_conduct}},
\code{\link{use_coveralls}},
\code{\link{use_cran_badge}},
\code{\link{use_coverage}}, \code{\link{use_cran_badge}},
\code{\link{use_cran_comments}},
\code{\link{use_package_doc}}, \code{\link{use_rcpp}},
\code{\link{use_revdep}}, \code{\link{use_rstudio}},
Expand Down
3 changes: 1 addition & 2 deletions man/use_data_raw.Rd
Expand Up @@ -23,8 +23,7 @@ Other infrastructure: \code{\link{add_build_ignore}},
\code{\link{add_travis}}, \code{\link{add_travis}},
\code{\link{infrastructure}}, \code{\link{use_appveyor}},
\code{\link{use_code_of_conduct}},
\code{\link{use_coveralls}},
\code{\link{use_cran_badge}},
\code{\link{use_coverage}}, \code{\link{use_cran_badge}},
\code{\link{use_cran_comments}},
\code{\link{use_package_doc}}, \code{\link{use_rcpp}},
\code{\link{use_revdep}}, \code{\link{use_rstudio}},
Expand Down
3 changes: 1 addition & 2 deletions man/use_package.Rd
Expand Up @@ -36,8 +36,7 @@ Other infrastructure: \code{\link{add_build_ignore}},
\code{\link{add_travis}}, \code{\link{add_travis}},
\code{\link{infrastructure}}, \code{\link{use_appveyor}},
\code{\link{use_code_of_conduct}},
\code{\link{use_coveralls}},
\code{\link{use_cran_badge}},
\code{\link{use_coverage}}, \code{\link{use_cran_badge}},
\code{\link{use_cran_comments}},
\code{\link{use_package_doc}}, \code{\link{use_rcpp}},
\code{\link{use_revdep}}, \code{\link{use_rstudio}},
Expand Down
3 changes: 1 addition & 2 deletions man/use_readme_rmd.Rd
Expand Up @@ -30,8 +30,7 @@ Other infrastructure: \code{\link{add_build_ignore}},
\code{\link{add_travis}}, \code{\link{add_travis}},
\code{\link{infrastructure}}, \code{\link{use_appveyor}},
\code{\link{use_code_of_conduct}},
\code{\link{use_coveralls}},
\code{\link{use_cran_badge}},
\code{\link{use_coverage}}, \code{\link{use_cran_badge}},
\code{\link{use_cran_comments}},
\code{\link{use_package_doc}}, \code{\link{use_rcpp}},
\code{\link{use_revdep}}, \code{\link{use_rstudio}},
Expand Down

0 comments on commit 0840e0b

Please sign in to comment.