diff --git a/.travis.yml b/.travis.yml index 07f107e8..bb646577 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ before_install: - R -q -e 'remotes::install_local(getwd(), force = TRUE); print(tic::dsl_load()); tic::prepare_all_stages()' - R -q -e 'tic::before_install()' install: R -q -e 'tic::install()' -after_install: R -q -e 'tic::after_install()' before_script: R -q -e 'tic::before_script()' script: R -q -e 'tic::script()' after_success: R -q -e 'tic::after_success()' @@ -30,8 +29,7 @@ after_script: R -q -e 'tic::after_script()' # Header language: r -sudo: false -dist: xenial +dist: bionic cache: packages latex: false @@ -61,11 +59,8 @@ jobs: - r: 3.4 - r: 3.3 - r: 3.2 - - -#matrix: Early abortion of failed builds -matrix: fast_finish: true + #services services: diff --git a/DESCRIPTION b/DESCRIPTION index 500816cd..3c7de746 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,8 +32,7 @@ Description: Provides a way to describe common build and deployment workflows for R-based projects: packages, websites (e.g. blogdown, pkgdown), or data processing (e.g. research compendia). The recipe is described independent of the continuous integration tool - used for processing the workflow (e.g. 'Travis CI' or - 'AppVeyor'). + used for processing the workflow (e.g. 'Travis CI' or 'AppVeyor'). License: GPL (>= 2) URL: https://github.com/ropenscilabs/tic BugReports: https://github.com/ropenscilabs/tic/issues @@ -70,9 +69,9 @@ Suggests: VignetteBuilder: knitr Remotes: + pat-s/circle, r-lib/rlang, - ropenscilabs/travis, - pat-s/circle + ropenscilabs/travis ByteCompile: No Encoding: UTF-8 LazyData: TRUE @@ -110,5 +109,6 @@ Collate: 'steps-write-text-file.R' 'tic-package.R' 'travis.R' + 'use-yaml.R' 'use_tic.R' 'utils.R' diff --git a/NAMESPACE b/NAMESPACE index 36e998ae..cb67dc88 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,8 +67,11 @@ export(step_setup_push_deploy) export(step_setup_ssh) export(step_test_ssh) export(step_write_text_file) +export(use_appveyor_yml) +export(use_circle_yml) export(use_tic) export(use_travis_deploy) +export(use_travis_yml) import(backports) import(cli) import(rlang) diff --git a/R/use-yaml.R b/R/use-yaml.R new file mode 100644 index 00000000..72ca3c74 --- /dev/null +++ b/R/use-yaml.R @@ -0,0 +1,95 @@ +#' @title Use CI YAML templates +#' @description Installs YAML templates for various CI providers. +#' +#' @param type `[character]`\cr +#' Which template to use. The string should be given following the logic +#' `--`. See details for more. +#' +#' @section Type: +#' `tic` supports a variety of different YAML templates which follow the +#' `--` pattern. The first one is mandatory, the +#' others are optional. +#' +#' * Possible values for `` are `travis`, and `circle` +#' * Possible values for `` are `linux`, and `macos`, `windows`. +#' * Possible values for `` are `matrix` and `deploy`. +#' +#' Not every combinations is supported on all CI systems. +#' For example, for `use_appveyor_yaml()` only `windows` and `windows-matrix` are valid. +#' +#' @name yaml-templates +#' @export +use_travis_yml <- function(type) { + if (type == "linux") { + template = "travis-linux.yml" + } else if (type == "linux-matrix") { + template = "travis-linux-matrix.yml" + } else if (type == "linux-deploy") { + template = "travis-linux-deploy.yml" + } else if (type == "linux-deploy-matrix") { + template = "travis-linux-deploy-matrix.yml" + } else if (type == "macos") { + template = "travis-macos.yml" + } else if (type == "macos-matrix") { + template = "travis-macos-matrix.yml" + } else if (type == "macos-deploy") { + template = "travis-macos-deploy.yml" + } else if (type == "macos-deploy-matrix") { + template = "travis-macos-deploy-matrix.yml" + } + use_tic_template( + template, + save_as = ".travis.yml", + data = list(install_tic = double_quotes(get_install_tic_code())) + ) +} + +#' @rdname yaml-templates +#' @export +use_appveyor_yml <- function(type) { + if (type == "windows") { + template = "appveyor.yml" + } else if (type == "windows-matrix") { + template = "appveyor-matrix.yml" + } + use_tic_template( + template, + save_as = "appveyor.yml", + data = list(install_tic = get_install_tic_code()) + ) +} + +#' @rdname yaml-templates +#' @export +use_circle_yml <- function(type) { + if (type == "linux") { + template = "circle.yml" + } else if (type == "linux-matrix") { + template = "circle-matrix.yml" + } else if (type == "linux-deploy") { + template = "circle-deploy.yml" + } else if (type == "linux-deploy-matrix") { + template = "circle-deploy-matrix.yml" + } + dir.create(".circleci", showWarnings = FALSE) + use_tic_template( + template, + save_as = ".circleci/config.yml", + data = list(install_tic = get_install_tic_code()) + ) + + # FIXME: upstream issue in _whisker_ pkg which cannot handle curly braces + # https://github.com/edwindj/whisker/issues/20 + tx <- readLines(sprintf("%s/.circleci/config.yml", usethis::proj_path())) + tx2 <- gsub(pattern = "checksum", replacement = "{{ checksum", x = tx) + tx2 <- gsub(pattern = '_tmp_file"', replacement = '_tmp_file" }}', x = tx2) + writeLines(tx2, con=sprintf("%s/.circleci/config.yml", usethis::proj_path())) +} + +use_tic_template <- function(template, save_as = template, open = FALSE, + ignore = TRUE, data = NULL) { + usethis::use_template( + template, save_as, + package = "tic", open = open, ignore = ignore, data = data + ) +} diff --git a/R/use_tic.R b/R/use_tic.R index 133acbfc..08c9067a 100644 --- a/R/use_tic.R +++ b/R/use_tic.R @@ -1,260 +1,211 @@ -# This code can only run interactively -# nocov start - -#' Initialize CI testing using tic +#' @title Initialize CI testing using tic +#' @description Prepares a repo for building and deploying supported by +#' \pkg{tic}. #' -#' Prepares a repo for building and deploying supported by \pkg{tic}. +#' @details #' -#' @param quiet `[flag]`\cr -#' Less verbose output? Default: `FALSE`. +#' 1. Query information which CI providers should be used +#' 1. Setup permissions for providers selected for deployment +#' 1. Create YAML files for selected providers +#' 1. Create a default `tic.R` file depending on the repo type +#' (package, website, bookdown, ...) #' +#' @param quiet `[flag]`\cr Less verbose output? Default: `FALSE`. #' @export use_tic <- function(quiet = FALSE) { - cli::cat_boxx("Welcome to `tic`!", col = "green") - cli::cat_bullet( - "This wizard will set all the required tokens and files\n", - "on Travis CI and GitHub. Let's get started!", - bullet = "info" - ) + cli_alert("Welcome to {.pkg tic}!") + cli_text(c( + "This wizard will guide you through the setup process for getting started with various CI providers." + )) - #' @details - #' This function requires the \pkg{travis} and \pkg{usethis} packages. - if (!is_installed("travis")) { - cli::cat_rule(col = "red") - stopc( - "`use_tic()` needs the `travis` package. Please ", - 'install it using `remotes::install_github("ropenscilabs/travis")`.' - ) - } + cli_h1("Introduction:") + cli_text("{.pkg tic} currently comes with support for three CI providers: ") - if (!is_installed("usethis")) { - cli::cat_rule(col = "red") - stopc( - "`use_tic()` needs the `usethis` package, ", - 'please install using `install.packages("usethis")`.' - ) - } + cli_ul(c("Appveyor", "Circle CI", "Travis CI")) - #' @details - #' The project path is retrieved with [usethis::proj_get()]. - path <- usethis::proj_get() - cli::cat_bullet( - bullet = "info", - paste0("Using active project ", usethis::ui_value(path)) + cli_par() + cli_text(c("There is no need to use all of them.", + " You can choose which one(s) you want to use,", + " whether you want to deploy (i.e. push from builds)", + " and if you want to test on multiple R versions.") ) - - repo_type <- detect_repo_type() - - if (needs_deploy(repo_type) && !is_installed("openssl")) { - cli::cat_rule(col = "red") - stopc( - "`use_tic()` needs the `openssl` package to set up deployment, ", - 'please install using install.packages("openssl").' - ) - } - - - #' @details - #' The preparation consists of the following steps: - #' 1. If necessary, create a GitHub repository via [usethis::use_github()] - #' - cli::cat_boxx( - "Step #1: We check if a GitHub repository exists.", - col = "green" + cli_end() + + cli_text("We recommend the following setup:") + cli_ul(c("Appveyor: Windows", "Circle CI: Linux", "Travis CI: macOS")) + cli_par() + cli_end() + + if (yesno("Ready to get started?")) { + return(invisible(NULL)) + } + + cli_h1("Choosing your setup.") + cli_text("We'll ask you a few yes/no questions to gather your preferences.") + cli_par() + cli_end() + + windows = menu(c("Yes", "No"), title = "Do you want to build on Windows (= Appveyor)?") + mac = menu(c("Yes", "No"), title = "Do you want to build on macOS (= Travis CI)?") + + linux = menu(c("Circle CI", "Travis CI", "None", "All"), + title = "Which provider do you want to use for Linux builds?") + + deploy = menu(c("Circle CI", "Travis CI", "No", "All"), + title = "Do you want to deploy (i.e. push from the CI build to your repo) on certain providers? If yes, which ones?") + + matrix = menu(c("Circle CI", "Travis CI", "Appveyor", "No", "All"), + title = "Do you want to build on multiple R versions? (i.e. R-devel, R-release, R-oldrelease). If yes, on which platform(s)?") + + cli_h1("Setting up the CI providers.") + + cli_text("Next we are getting the selected CI providers ready for deployment.", + " This requires some interaction with their API and you may need to create an API token.") + cli_par() + cli_end() + + # init deploy ---------------------------------------------------------------- + + if (deploy == 1) { + rule(left = "Circle CI") + check_circle_pkg() + circle::enable_repo() + circle::use_circle_deploy() + } else if (deploy == 2) { + rule(left = "Travis CI") + travis::travis_enable() + check_travis_pkg() + travis::use_travis_deploy() + } else if (deploy == 3) { + rule(left = "Travis CI") + check_travis_pkg() + travis::travis_enable() + travis::use_travis_deploy() + + rule(left = "Circle CI") + check_circle_pkg() + circle::enable_repo() + circle::use_circle_deploy() + } + + # create YAMLs --------------------------------------------------------------- + + cli_par() + cli_end() + cli_h1("Creating YAML files...") + + # Travis --------------------------------------------------------------------- + + rule(left = "Travis CI") + + if (linux == 2 || linux == 4) { + # deployment + if (deploy == 2 || deploy == 4) { + # build matrix + if (matrix == 2 || matrix == 5) { + use_travis_yml("linux-deploy-matrix") + } else { + use_travis_yml("linux-deploy") + } + } else { + # build matrix + if (matrix == 2 || matrix == 5) { + use_travis_yml("linux-matrix") + } else { + use_travis_yml("linux") + } + } + } else if (mac == 1) { + if (deploy == 2 || deploy == 4) { + # build matrix + if (matrix == 2 || matrix == 5) { + use_travis_yml("macos-deploy-matrix") + } else { + use_travis_yml("macos-deploy") + } + } else { + # build matrix + if (matrix == 2 || matrix == 5) { + use_travis_yml("macos-matrix") + } else { + use_travis_yml("macos") + } + } + } + + # Circle ---------------------------------------------------------------------- + + Sys.sleep(3) + rule(left = "Circle CI") + + if (linux == 1 || linux == 4) { + # deployment + if (deploy == 1 || deploy == 4) { + # build matrix + if (matrix == 1 || matrix == 5) { + use_circle_yml("linux-deploy-matrix") + } else { + use_circle_yml("linux-deploy") + } + } else { + # build matrix + if (matrix == 1 || matrix == 5) { + use_circle_yml("linux-matrix") + } else { + use_circle_yml("linux") + } + } + } + + # Appveyor ------------------------------------------------------------------- + + Sys.sleep(3) + rule(left = "Appveyor CI") + + if (windows == 1) { + if (matrix == 3 || matrix == 5) { + use_appveyor_yml("windows-matrix") + } else { + use_appveyor_yml("windows") + } + } + + # tic.R ---------------------------------------------------------------------- + + Sys.sleep(3) + rule(left = "tic") + + use_tic_r(repo_type = detect_repo_type()) + + rule("Finished") + cat_bullet( + "Done! Thanks for using ", crayon::blue("tic"), ".", + bullet = "star", bullet_col = "yellow" ) - use_github_interactive() - if (!isTRUE(travis::uses_github())) { - stopc( - "A GitHub repository is needed. ", - "Please create one manually or re-run `use_tic()` to do it automatically." - ) - } else { - cli::cat_bullet( - "GitHub repo exists.", - bullet = "tick", bullet_col = "green" - ) - } - - #' 1. Enable Travis via [travis::travis_enable()] - cli::cat_boxx( - "Step #2: We check if Travis is already enabled.", - col = "green" + cat_bullet( + "Below is the file structure of the newly added files (in case you selected all providers):", + bullet = "arrow_down", bullet_col = "blue" ) - travis::travis_enable() - - cli::cat_boxx( - c( - "Step #3: We create new files", - "`.travis.yml`, `appveyor.yml` and `tic.R`." - ), - col = "green" - ) - - #' 1. Create a default `.travis.yml` file - #' (overwrite after confirmation in interactive mode only) - use_travis_yml() - #' 1. Create a default `appveyor.yml` file - #' (depending on repo type, overwrite after confirmation - #' in interactive mode only) - if (needs_appveyor(repo_type)) { - use_appveyor_yml() - } - #' 1. Create a default `.circleci/config.yml` file - #' (depending on repo type, overwrite after confirmation - #' in interactive mode only) - if (needs_circle(repo_type)) { - use_circle_yml() - } - #' 1. Create a default `tic.R` file depending on the repo type - #' (package, website, bookdown, ...) - use_tic_r(repo_type) - - #' 1. Enable deployment (if necessary, depending on repo type) - #' via [use_travis_deploy()] - cli::cat_boxx( - c( - "Step #4: We create a SSH key pair", - "to allow Travis deployment to GitHub." - ), - col = "green" + data <- data.frame( + stringsAsFactors = FALSE, + package = c(basename(getwd()), ".circleci", "appveyor.yml", ".travis.yml", "config.yml", "tic.R"), + dependencies = I(list( + c(".circleci", "appveyor.yml", ".travis.yml", "tic.R"), + "config.yml", + character(0), + character(0), + character(0), + character(0) + )) ) - if (needs_deploy(repo_type)) use_travis_deploy() - - cli::cat_boxx( - c( - "Step #5: We create a GitHub PAT key on Travis CI", - "to avoid GitHub API rate limitations in the builds." - ), - col = "green" - ) - #' 1. Create a GitHub PAT and install it on Travis CI - #' via [travis::travis_set_pat()] - travis::travis_set_pat() - - #' - #' This function is aimed at supporting the most common use cases. - #' Users who require more control are advised to review - #' the source code of `use_tic()` - #' and manually call the individual functions, some of which aren't exported. -} - -use_travis_yml <- function() { - use_tic_template( - "dot-travis.yml", - save_as = ".travis.yml", - data = list(install_tic = double_quotes(get_install_tic_code())) - ) -} + tree(data, root = basename(getwd())) -use_appveyor_yml <- function() { - use_tic_template( - "appveyor.yml", - data = list(install_tic = get_install_tic_code()) - ) -} - -use_circle_yml <- function() { - use_tic_template( - "circle.yml", - save_as = ".circleci/config.yml", - data = list(install_tic = get_install_tic_code()) - ) -} - -get_install_tic_code <- function() { - if (getNamespaceVersion("tic") >= "1.0") { - # We are on CRAN! - "remotes::install_cran('tic', upgrade = 'always')" - } else { - "remotes::install_github('ropenscilabs/tic', upgrade = 'always')" - } -} - -double_quotes <- function(x) { - gsub("'", '"', x, fixed = TRUE) } use_tic_r <- function(repo_type) { - use_tic_template(file.path(repo_type, "tic.R"), "tic.R", open = TRUE) -} - -use_tic_template <- function(template, save_as = template, open = FALSE, - ignore = TRUE, data = NULL) { - usethis::use_template( - template, save_as, - package = "tic", open = open, ignore = ignore, data = data - ) -} - -needs_appveyor <- function(repo_type) { - repo_type == "package" -} - -needs_circle <- function(repo_type) { - repo_type == "package" -} - -needs_deploy <- function(repo_type) { - repo_type != "unknown" -} - -use_github_interactive <- function() { - if (!interactive()) { - return() - } - if (travis::uses_github()) { - return() - } - - if (!yesno("Create GitHub repo and push code?")) { - return() - } - - message("Creating GitHub repository") - usethis::use_github() -} - -detect_repo_type <- function() { - if (file.exists("_bookdown.yml")) { - return("bookdown") - } - if (file.exists("_site.yml")) { - return("site") - } - if (file.exists("config.toml")) { - return("blogdown") - } - if (file.exists("DESCRIPTION")) { - return("package") - } - - if (!interactive()) { - return("unknown") - } - - cli::cat_bullet( - "Unable to guess the repo type. ", - "Please choose the desired one from the menu.", - bullet = "warning" - ) - - choices <- c( - blogdown = "Blogdown", bookdown = "Bookdown", - package = "Package", website = "Website", - unknown = "Other" - ) - chosen <- utils::menu(choices) - if (chosen == 0) { - stopc("Aborted.") - } else { - names(choices)[[chosen]] - } -} - -yesno <- function(...) { - utils::menu(c("Yes", "No"), title = paste0(...)) == 1 + use_tic_template(file.path(repo_type, "tic.R"), "tic.R") } # This code can only run interactively diff --git a/R/utils.R b/R/utils.R index 7ea9291a..690069d9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -45,3 +45,118 @@ tempfile_slash <- function(pattern = "file", tmpdir = tempdir(), fileext = "") { path <- tempfile(pattern, tmpdir, fileext) normalizePath(path, winslash = "/", mustWork = FALSE) } + +yesno <- function(...) { + yeses <- c("Yes", "Definitely", "For sure", "Yup", "Yeah", "Of course", "Absolutely") + nos <- c("No way", "Not yet", "I forget", "No", "Nope", "Uhhhh... Maybe?") + + cat(paste0(..., collapse = "")) + qs <- c(sample(yeses, 1), sample(nos, 2)) + rand <- sample(length(qs)) + + menu(qs[rand]) != which(rand == 1) +} + +check_travis_pkg = function() { + if (!is_installed("travis")) { + cli::cat_rule(col = "red") + stopc( + "`use_tic()` needs the `travis` package. Please ", + 'install it using `remotes::install_github("ropenscilabs/travis")`.' + ) + } +} + +check_circle_pkg = function() { + if (!is_installed("circle")) { + cli::cat_rule(col = "red") + stopc( + "`use_tic()` needs the `circle` package. Please ", + 'install it using `remotes::install_github("pat-s/circle")`.' + ) + } +} + +check_usethis_pkg = function() { + if (!is_installed("usethis")) { + cli::cat_rule(col = "red") + stopc( + "`use_tic()` needs the `usethis` package, ", + 'please install using `install.packages("usethis")`.' + ) + } +} + +check_openssl_pkg = function() { + cli::cat_rule(col = "red") + stopc( + "`use_tic()` needs the `openssl` package to set up deployment, ", + 'please install using install.packages("openssl").' + ) +} + +detect_repo_type <- function() { + if (file.exists("_bookdown.yml")) { + return("bookdown") + } + if (file.exists("_site.yml")) { + return("site") + } + if (file.exists("config.toml")) { + return("blogdown") + } + if (file.exists("DESCRIPTION")) { + return("package") + } + + if (!interactive()) { + return("unknown") + } + + cli::cat_bullet( + "Unable to guess the repo type. ", + "Please choose the desired one from the menu.", + bullet = "warning" + ) + + choices <- c( + blogdown = "Blogdown", bookdown = "Bookdown", + package = "Package", website = "Website", + unknown = "Other" + ) + chosen <- utils::menu(choices) + if (chosen == 0) { + stopc("Aborted.") + } else { + names(choices)[[chosen]] + } +} + +use_github_interactive <- function() { + if (!interactive()) { + return() + } + if (travis::uses_github()) { + return() + } + + if (!yesno("Create GitHub repo and push code?")) { + return() + } + + message("Creating GitHub repository") + usethis::use_github() +} + +get_install_tic_code <- function() { + if (getNamespaceVersion("tic") >= "1.0") { + # We are on CRAN! + "remotes::install_cran('tic', upgrade = 'always')" + } else { + "remotes::install_github('ropenscilabs/tic', upgrade = 'always')" + } +} + +double_quotes <- function(x) { + gsub("'", '"', x, fixed = TRUE) +} diff --git a/README.md b/README.md index 951195c3..5492dd98 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,20 @@ # tic -[![Travis-CI Build Status](https://travis-ci.org/ropenscilabs/tic.svg?branch=master)](https://travis-ci.org/ropenscilabs/tic) -[![Build status](https://ci.appveyor.com/api/projects/status/r8w1psd0f5r4hs6t/branch/master?svg=true)](https://ci.appveyor.com/project/ropensci/tic/branch/master) -[![CircleCI](https://circleci.com/gh/ropenscilabs/tic.svg?style=svg)](https://circleci.com/gh/ropenscilabs/tic) + +[![Travis build status](https://img.shields.io/travis/ropenscilabs/tic/master?logo=travis&style=flat-square&label=Linux)](https://travis-ci.org/ropenscilabs/tic) +[![AppVeyor build status](https://img.shields.io/appveyor/ci/ropensci/tic?label=Windows&logo=appveyor&style=flat-square)](https://ci.appveyor.com/project/ropensci/tic) +[![CircleCI](https://img.shields.io/circleci/build/gh/ropenscilabs/tic/master?label=Linux&logo=circle&logoColor=green&style=flat-square)](https://circleci.com/gh/ropenscilabs/tic) [![CRAN status](https://www.r-pkg.org/badges/version/tic)](https://cran.r-project.org/package=tic) -[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) +[![codecov](https://codecov.io/gh/ropenscilabs/tic/branch/master/graph/badge.svg)](https://codecov.io/gh/ropenscilabs/tic) +[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) [![](https://badges.ropensci.org/305_status.svg)](https://github.com/ropensci/software-review/issues/305) + The goal of tic is to enhance and simplify working with continuous integration (CI) systems. The following ones are supported: -- [Travis CI](https://travis-ci.org) (Linux) +- [Travis CI](https://travis-ci.org) (Linux, macOS) - [AppVeyor](https://www.appveyor.com/) (Windows) - [Circle CI](https://circleci.com/) (Linux) @@ -39,7 +42,7 @@ remotes::install_github("ropenscilabs/tic") ## Setup By calling `tic::use_tic()` a production ready CI setup is initialized, tailored to your specific R project. -The created templates will use the providers https://travis-ci.org and https://appveyor.com. +The created templates will use the providers https://travis-ci.org, https://appveyor.com and https://circleci.com. For an R package, the following steps will be set up for the CI workflow: - Installation of required dependencies for the project diff --git a/inst/templates/appveyor-matrix.yml b/inst/templates/appveyor-matrix.yml new file mode 100644 index 00000000..151dc424 --- /dev/null +++ b/inst/templates/appveyor-matrix.yml @@ -0,0 +1,34 @@ +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# Download script file from GitHub +init: + ps: | + $ErrorActionPreference = "Stop" + Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" + Import-Module '..\appveyor-tool.ps1' + +install: + - ps: Bootstrap + - cmd: Rscript -e "writeLines('options(repos = \'https://cloud.r-project.org\')', '~/.Rprofile')" + - cmd: Rscript -e "getOption('repos')" + - cmd: Rscript -e "if (!requireNamespace('remotes')) install.packages('remotes', type = 'binary')" + - cmd: Rscript -e "if (getRversion() < '3.2' && !requireNamespace('curl')) install.packages('curl', type = 'binary')" + - cmd: Rscript -e "options(pkgType = 'binary'); {{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()" + +before_build: Rscript -e "tic::before_install()" +build_script: Rscript -e "tic::install()" +after_build: Rscript -e "tic::after_install()" +before_test: Rscript -e "tic::before_script()" +test_script: Rscript -e "tic::script()" +on_success: Rscript -e "try(tic::after_success(), silent = TRUE)" +on_failure: Rscript -e "tic::after_failure()" +on_finish: Rscript -e "tic::after_script()" + +# no testing on R-devel because no package binaries are available +environment: + matrix: + - R_VERSION: release + - R_VERSION: oldrel + +matrix: + fast_finish: true diff --git a/inst/templates/appveyor.yml b/inst/templates/appveyor.yml index 838e5d4b..3a964879 100644 --- a/inst/templates/appveyor.yml +++ b/inst/templates/appveyor.yml @@ -1,4 +1,4 @@ -# DO NOT CHANGE the "init" and "install" sections below +# tic documentation to get started: https://ropenscilabs.github.io/tic/ # Download script file from GitHub init: @@ -26,35 +26,3 @@ before_deploy: Rscript -e "tic::before_deploy()" deploy_script: Rscript -e "tic::deploy()" after_deploy: Rscript -e "tic::after_deploy()" on_finish: Rscript -e "tic::after_script()" - -# Adapt as necessary starting from here - -#on_failure: -# - 7z a failure.zip *.Rcheck\* -# - appveyor PushArtifact failure.zip - -#environment: - # The example below will not work for your repository, - # you need to encrypt your own token. - # Please follow https://ci.appveyor.com/tools/encrypt . - #GITHUB_PAT: - # secure: VXO22OHLkl4YhVIomSMwCZyOTx03Xf2WICaVng9xH7gISlAg8a+qrt1DtFtk8sK5 - -artifacts: - - path: '*.Rcheck\**\*.log' - name: Logs - - - path: '*.Rcheck\**\*.out' - name: Logs - - - path: '*.Rcheck\**\*.fail' - name: Logs - - - path: '*.Rcheck\**\*.Rout' - name: Logs - - - path: '\*_*.tar.gz' - name: Bits - - - path: '\*_*.zip' - name: Bits diff --git a/inst/templates/circle-deploy-matrix.yml b/inst/templates/circle-deploy-matrix.yml new file mode 100644 index 00000000..913a0f8a --- /dev/null +++ b/inst/templates/circle-deploy-matrix.yml @@ -0,0 +1,125 @@ +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +version: 2 +jobs: + "r-3.6.1": + docker: + - image: rocker/verse:3.6.1 + steps: + - checkout + # create a unique env var for the cache. Unfortunately normal env vars + # are not picked up by the cache, therefore this workaround is needed. + # See https://discuss.circleci.com/t/cannot-use-circle-yml-environment-variables-in-cache-keys/10994/7 + - run: echo "$(date -d "$D" '+%d')3.6.1" > /tmp/_tmp_file + - restore_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + + # install deps and check pkg --------------------------------------------- + - run: + name: Install package dependencies + command: | + sudo apt update + sudo apt install -y libglu1-mesa-dev libgmp-dev libgs-dev libgdal-dev libproj-dev libgeos-dev libudunits2-dev jags + echo -e 'options(Ncpus = 6, repos = structure(c(CRAN = "https://cloud.r-project.org/")))' > $HOME/.Rprofile + R -q -e 'if (!requireNamespace("remotes") || "remotes" %in% old.packages()) install.packages("remotes")' + R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' + R -q -e 'tic::before_install()' + R -q -e 'tic::install()' + - run: + name: Check package + no_output_timeout: 60m + command: | + R -q -e 'tic::before_script()' + R -q -e 'tic::script()' + + # save R pkg cache ------------------------------------------------------- + - save_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + paths: + - /usr/local/lib/R/site-library + deploy: + environment: + id_rsa: true + docker: + - image: rocker/verse:3.6.1 + steps: + - checkout + - run: echo "$(date -d "$D" '+%d')" > /tmp/_tmp_file + - restore_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + # Add your own SSH key fingerprint here, see https://circleci.com/docs/2.0/gh-bb-integration/#creating-a-github-deploy-key + # and https://discuss.circleci.com/t/adding-ssh-keys-fails/7747/24 on how to create a valid key + #- add_ssh_keys: + # fingerprints: + # - "15:9c:45:50:dc:94:87:6f:a9:ca:e1:fc:6a:b9:7e:62" + - run: + name: Deploy Over SSH + command: | + R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' + R -q -e 'tic::before_deploy()' + R -q -e 'tic::deploy()' + R -q -e 'tic::after_deploy()' + + "r-3.5.3": + docker: + - image: rocker/verse:3.5.3 + steps: + - checkout + # create a unique env var for the cache. Unfortunately normal env vars + # are not picked up by the cache, therefore this workaround is needed. + # See https://discuss.circleci.com/t/cannot-use-circle-yml-environment-variables-in-cache-keys/10994/7 + - run: echo "$(date -d "$D" '+%d')3.5.3" > /tmp/_tmp_file + - restore_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + + # install deps and check pkg --------------------------------------------- + - run: + name: Install package dependencies + command: | + sudo apt update + sudo apt install -y libglu1-mesa-dev libgmp-dev libgs-dev libgdal-dev libproj-dev libgeos-dev libudunits2-dev jags + echo -e 'options(Ncpus = 6, repos = structure(c(CRAN = "https://cloud.r-project.org/")))' > $HOME/.Rprofile + R -q -e 'if (!requireNamespace("remotes") || "remotes" %in% old.packages()) install.packages("remotes")' + R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' + R -q -e 'tic::before_install()' + R -q -e 'tic::install()' + - run: + name: Check package + no_output_timeout: 60m + command: | + R -q -e 'tic::before_script()' + R -q -e 'tic::script()' + + # save R pkg cache ------------------------------------------------------- + - save_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + paths: + - /usr/local/lib/R/site-library + +workflows: + version: 2 + build: + jobs: + - "r-3.6.1" + - "r-3.5.3" + - deploy: + requires: + - "r-3.6.1" + +# CRON job daily at 3 am in the morning +# - runs the "build" job on the master branch and builds package cache + nightly: + triggers: + - schedule: + cron: "0 3 * * *" + filters: + branches: + only: + - master + jobs: + - "r-3.6.1" + - "r-3.5.3" diff --git a/inst/templates/circle-deploy.yml b/inst/templates/circle-deploy.yml new file mode 100644 index 00000000..e99ebb59 --- /dev/null +++ b/inst/templates/circle-deploy.yml @@ -0,0 +1,80 @@ +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +version: 2 +jobs: + "r-3.6.1": + docker: + - image: rocker/verse:3.6.1 + steps: + - checkout + + # create a unique env var for the cache. Unfortunately normal env vars + # are not picked up by the cache, therefore this workaround is needed. + # See https://discuss.circleci.com/t/cannot-use-circle-yml-environment-variables-in-cache-keys/10994/7 + - run: echo "$(date -d "$D" '+%d')3.6.1" > /tmp/_tmp_file + - restore_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + + # install deps and check pkg --------------------------------------------- + - run: + name: Install package dependencies + command: | + echo -e 'options(Ncpus = 6, repos = structure(c(CRAN = "https://cloud.r-project.org/")))' > $HOME/.Rprofile + R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' + R -q -e 'tic::before_install()' + R -q -e 'tic::install()' + - run: + name: Check package + no_output_timeout: 60m + command: | + R -q -e 'tic::before_script()' + R -q -e 'tic::script()' + + # save R pkg cache ------------------------------------------------------- + - save_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + paths: + - /usr/local/lib/R/site-library + deploy: + environment: + id_rsa: true + docker: + - image: rocker/verse + steps: + - checkout + - run: echo "$(date -d "$D" '+%d')" > /tmp/_tmp_file + - restore_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + - run: + name: Deploy Over SSH + command: | + R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' + R -q -e 'tic::before_deploy()' + R -q -e 'tic::deploy()' + R -q -e 'tic::after_deploy()' + +workflows: + version: 2 + build-and-deploy: + jobs: + - build + - deploy: + requires: + - build + +# CRON job daily at 3 am in the morning +# - runs the "build" job on the master branch and builds package cache + nightly: + triggers: + - schedule: + cron: "0 3 * * *" + filters: + branches: + only: + - master + jobs: + - build diff --git a/inst/templates/circle-matrix.yml b/inst/templates/circle-matrix.yml new file mode 100644 index 00000000..61597492 --- /dev/null +++ b/inst/templates/circle-matrix.yml @@ -0,0 +1,98 @@ +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +version: 2 +jobs: + "r-3.6.1": + docker: + - image: rocker/verse:3.6.1 + steps: + - checkout + # create a unique env var for the cache. Unfortunately normal env vars + # are not picked up by the cache, therefore this workaround is needed. + # See https://discuss.circleci.com/t/cannot-use-circle-yml-environment-variables-in-cache-keys/10994/7 + - run: echo "$(date -d "$D" '+%d')3.6.1" > /tmp/_tmp_file + - restore_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + + # install deps and check pkg --------------------------------------------- + - run: + name: Install package dependencies + command: | + sudo apt update + sudo apt install -y libglu1-mesa-dev libgmp-dev libgs-dev libgdal-dev libproj-dev libgeos-dev libudunits2-dev jags + echo -e 'options(Ncpus = 6, repos = structure(c(CRAN = "https://cloud.r-project.org/")))' > $HOME/.Rprofile + R -q -e 'if (!requireNamespace("remotes") || "remotes" %in% old.packages()) install.packages("remotes")' + R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' + R -q -e 'tic::before_install()' + R -q -e 'tic::install()' + - run: + name: Check package + no_output_timeout: 60m + command: | + R -q -e 'tic::before_script()' + R -q -e 'tic::script()' + + # save R pkg cache ------------------------------------------------------- + - save_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + paths: + - /usr/local/lib/R/site-library + + "r-3.5.3": + docker: + - image: rocker/verse:3.5.3 + steps: + - checkout + # create a unique env var for the cache. Unfortunately normal env vars + # are not picked up by the cache, therefore this workaround is needed. + # See https://discuss.circleci.com/t/cannot-use-circle-yml-environment-variables-in-cache-keys/10994/7 + - run: echo "$(date -d "$D" '+%d')3.5.3" > /tmp/_tmp_file + - restore_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + + # install deps and check pkg --------------------------------------------- + - run: + name: Install package dependencies + command: | + sudo apt update + sudo apt install -y libglu1-mesa-dev libgmp-dev libgs-dev libgdal-dev libproj-dev libgeos-dev libudunits2-dev jags + echo -e 'options(Ncpus = 6, repos = structure(c(CRAN = "https://cloud.r-project.org/")))' > $HOME/.Rprofile + R -q -e 'if (!requireNamespace("remotes") || "remotes" %in% old.packages()) install.packages("remotes")' + R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' + R -q -e 'tic::before_install()' + R -q -e 'tic::install()' + - run: + name: Check package + no_output_timeout: 60m + command: | + R -q -e 'tic::before_script()' + R -q -e 'tic::script()' + + # save R pkg cache ------------------------------------------------------- + - save_cache: + key: R-package-library-checksum "/tmp/_tmp_file" + paths: + - /usr/local/lib/R/site-library + +workflows: + version: 2 + build: + jobs: + - "r-3.6.1" + - "r-3.5.3" + +# CRON job daily at 3 am in the morning +# - runs the "build" job on the master branch and builds package cache + nightly: + triggers: + - schedule: + cron: "0 3 * * *" + filters: + branches: + only: + - master + jobs: + - "r-3.6.1" + - "r-3.5.3" diff --git a/inst/templates/circle.yml b/inst/templates/circle.yml index 1223f4ce..a9915e06 100644 --- a/inst/templates/circle.yml +++ b/inst/templates/circle.yml @@ -11,7 +11,7 @@ jobs: # See https://discuss.circleci.com/t/cannot-use-circle-yml-environment-variables-in-cache-keys/10994/7 - run: echo "$(date -d "$D" '+%d')" > /tmp/_tmp_file - restore_cache: - key: R-package-library-{{ checksum "/tmp/_tmp_file" }} + key: R-package-library-checksum "/tmp/_tmp_file" # install deps and check pkg --------------------------------------------- - run: @@ -32,45 +32,16 @@ jobs: # save R pkg cache ------------------------------------------------------- - save_cache: - key: R-package-library-{{ checksum "/tmp/_tmp_file" }} + key: R-package-library-checksum "/tmp/_tmp_file" paths: - /usr/local/lib/R/site-library - deploy: - environment: - id_rsa: true - docker: - - image: rocker/verse - steps: - - checkout - - run: echo "$(date -d "$D" '+%d')" > /tmp/_tmp_file - - restore_cache: - key: R-package-library-{{ checksum "/tmp/_tmp_file" }} - # Add your own SSH key fingerprint here, see https://circleci.com/docs/2.0/gh-bb-integration/#creating-a-github-deploy-key - # and https://discuss.circleci.com/t/adding-ssh-keys-fails/7747/24 on how to create a valid key - #- add_ssh_keys: - # fingerprints: - # - "15:9c:45:50:dc:94:87:6f:a9:ca:e1:fc:6a:b9:7e:62" - - run: - name: Deploy Over SSH - command: | - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' - R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' - R -q -e 'tic::before_deploy()' - R -q -e 'tic::deploy()' - R -q -e 'tic::after_deploy()' workflows: version: 2 - build-and-deploy: + build: jobs: - build - - deploy: - requires: - - build - filters: - branches: - only: circle-ci + # CRON job daily at 3 am in the morning # - runs the "build" job on the master branch and builds package cache nightly: diff --git a/inst/templates/package/tic.R b/inst/templates/package/tic.R index a1e4305d..d98fe3fa 100644 --- a/inst/templates/package/tic.R +++ b/inst/templates/package/tic.R @@ -1,5 +1,7 @@ +# installs dependencies, runs R CMD check, runs covr::codecov() do_package_checks() if (ci_on_travis()) { + # creates pkgdown site and pushes to gh-pages branch do_pkgdown() } diff --git a/inst/templates/dot-travis.yml b/inst/templates/travis-linux-deploy-matrix.yml similarity index 77% rename from inst/templates/dot-travis.yml rename to inst/templates/travis-linux-deploy-matrix.yml index 3962c65a..04d5641e 100644 --- a/inst/templates/dot-travis.yml +++ b/inst/templates/travis-linux-deploy-matrix.yml @@ -1,7 +1,5 @@ -# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r # Default configuration for use with tic package # tic documentation to get started: https://ropenscilabs.github.io/tic/ -# Usually you shouldn't need to change the first part of the file # DO NOT CHANGE THE CODE BELOW before_install: @@ -10,7 +8,6 @@ before_install: - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' - R -q -e 'tic::before_install()' install: R -q -e 'tic::install()' -after_install: R -q -e 'tic::after_install()' before_script: R -q -e 'tic::before_script()' script: R -q -e 'tic::script()' after_success: R -q -e 'tic::after_success()' @@ -25,19 +22,21 @@ after_deploy: R -q -e 'tic::after_deploy()' after_script: R -q -e 'tic::after_script()' # DO NOT CHANGE THE CODE ABOVE -# Custom parts: - -# Header language: r -sudo: false -dist: xenial -cache: packages +dist: bionic +cache: + - packages + - $HOME/.ccache latex: false -#env env: global: - MAKEFLAGS="-j 2" -#services -services: +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release diff --git a/inst/templates/travis-linux-deploy.yml b/inst/templates/travis-linux-deploy.yml new file mode 100644 index 00000000..28b81be7 --- /dev/null +++ b/inst/templates/travis-linux-deploy.yml @@ -0,0 +1,34 @@ +# Default configuration for use with tic package +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# DO NOT CHANGE THE CODE BELOW +before_install: + - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' + - R -q -e 'tic::before_install()' +install: R -q -e 'tic::install()' +before_script: R -q -e 'tic::before_script()' +script: R -q -e 'tic::script()' +after_success: R -q -e 'tic::after_success()' +after_failure: R -q -e 'tic::after_failure()' +before_deploy: R -q -e 'tic::before_deploy()' +deploy: + provider: script + script: R -q -e 'tic::deploy()' + on: + all_branches: true +after_deploy: R -q -e 'tic::after_deploy()' +after_script: R -q -e 'tic::after_script()' +# DO NOT CHANGE THE CODE ABOVE + +language: r +dist: bionic +cache: + - packages + - $HOME/.ccache +latex: false + +env: + global: + - MAKEFLAGS="-j 2" diff --git a/inst/templates/travis-linux-matrix.yml b/inst/templates/travis-linux-matrix.yml new file mode 100644 index 00000000..784573bc --- /dev/null +++ b/inst/templates/travis-linux-matrix.yml @@ -0,0 +1,36 @@ +# Default configuration for use with tic package +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# DO NOT CHANGE THE CODE BELOW +before_install: + - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' + - R -q -e 'tic::before_install()' +install: R -q -e 'tic::install()' +before_script: R -q -e 'tic::before_script()' +script: R -q -e 'tic::script()' +after_success: R -q -e 'tic::after_success()' +after_failure: R -q -e 'tic::after_failure()' +before_deploy: R -q -e 'tic::before_deploy()' +after_script: R -q -e 'tic::after_script()' +# DO NOT CHANGE THE CODE ABOVE + +language: r +dist: bionic +cache: + - packages + - $HOME/.ccache +latex: false + +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release + +env: + global: + - MAKEFLAGS="-j 2" diff --git a/inst/templates/travis-linux.yml b/inst/templates/travis-linux.yml new file mode 100644 index 00000000..243d69f8 --- /dev/null +++ b/inst/templates/travis-linux.yml @@ -0,0 +1,28 @@ +# Default configuration for use with tic package +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# DO NOT CHANGE THE CODE BELOW +before_install: + - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' + - R -q -e 'tic::before_install()' +install: R -q -e 'tic::install()' +before_script: R -q -e 'tic::before_script()' +script: R -q -e 'tic::script()' +after_success: R -q -e 'tic::after_success()' +after_failure: R -q -e 'tic::after_failure()' +before_deploy: R -q -e 'tic::before_deploy()' +after_script: R -q -e 'tic::after_script()' +# DO NOT CHANGE THE CODE ABOVE + +language: r +dist: bionic +cache: + - packages + - $HOME/.ccache +latex: false + +env: + global: + - MAKEFLAGS="-j 2" diff --git a/inst/templates/travis-macos-deploy-matrix.yml b/inst/templates/travis-macos-deploy-matrix.yml new file mode 100644 index 00000000..0d41ee52 --- /dev/null +++ b/inst/templates/travis-macos-deploy-matrix.yml @@ -0,0 +1,43 @@ +# Default configuration for use with tic package +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# DO NOT CHANGE THE CODE BELOW +before_install: + - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' + - R -q -e 'tic::before_install()' +install: R -q -e 'tic::install()' +before_script: R -q -e 'tic::before_script()' +script: R -q -e 'tic::script()' +after_success: R -q -e 'tic::after_success()' +after_failure: R -q -e 'tic::after_failure()' +before_deploy: R -q -e 'tic::before_deploy()' +deploy: + provider: script + script: R -q -e 'tic::deploy()' + on: + all_branches: true +after_deploy: R -q -e 'tic::after_deploy()' +after_script: R -q -e 'tic::after_script()' +# DO NOT CHANGE THE CODE ABOVE + +language: r +os: osx +cache: + - packages + - $HOME/.ccache + - $HOME/Library/Caches/Homebrew +latex: false + +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release + +env: + global: + - MAKEFLAGS="-j 2" diff --git a/inst/templates/travis-macos-deploy.yml b/inst/templates/travis-macos-deploy.yml new file mode 100644 index 00000000..205a9a16 --- /dev/null +++ b/inst/templates/travis-macos-deploy.yml @@ -0,0 +1,35 @@ +# Default configuration for use with tic package +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# DO NOT CHANGE THE CODE BELOW +before_install: + - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' + - R -q -e 'tic::before_install()' +install: R -q -e 'tic::install()' +before_script: R -q -e 'tic::before_script()' +script: R -q -e 'tic::script()' +after_success: R -q -e 'tic::after_success()' +after_failure: R -q -e 'tic::after_failure()' +before_deploy: R -q -e 'tic::before_deploy()' +deploy: + provider: script + script: R -q -e 'tic::deploy()' + on: + all_branches: true +after_deploy: R -q -e 'tic::after_deploy()' +after_script: R -q -e 'tic::after_script()' +# DO NOT CHANGE THE CODE ABOVE + +language: r +os: osx +cache: + - packages + - $HOME/.ccache + - $HOME/Library/Caches/Homebrew +latex: false + +env: + global: + - MAKEFLAGS="-j 2" diff --git a/inst/templates/travis-macos-matrix.yml b/inst/templates/travis-macos-matrix.yml new file mode 100644 index 00000000..71f0f533 --- /dev/null +++ b/inst/templates/travis-macos-matrix.yml @@ -0,0 +1,35 @@ +# Default configuration for use with tic package +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# DO NOT CHANGE THE CODE BELOW +before_install: + - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' + - R -q -e 'tic::before_install()' +install: R -q -e 'tic::install()' +before_script: R -q -e 'tic::before_script()' +script: R -q -e 'tic::script()' +after_success: R -q -e 'tic::after_success()' +after_failure: R -q -e 'tic::after_failure()' +# DO NOT CHANGE THE CODE ABOVE + +language: r +os: osx +cache: + - packages + - $HOME/.ccache + - $HOME/Library/Caches/Homebrew +latex: false + +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release + +env: + global: + - MAKEFLAGS="-j 2" diff --git a/inst/templates/travis-macos.yml b/inst/templates/travis-macos.yml new file mode 100644 index 00000000..ed73ed9e --- /dev/null +++ b/inst/templates/travis-macos.yml @@ -0,0 +1,30 @@ +# Default configuration for use with tic package +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + +# DO NOT CHANGE THE CODE BELOW +before_install: + - R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")' + - R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")' + - R -q -e '{{{install_tic}}}; print(tic::dsl_load()); tic::prepare_all_stages()' + - R -q -e 'tic::before_install()' +install: R -q -e 'tic::install()' +before_script: R -q -e 'tic::before_script()' +script: R -q -e 'tic::script()' +after_success: R -q -e 'tic::after_success()' +after_failure: R -q -e 'tic::after_failure()' +before_deploy: R -q -e 'tic::before_deploy()' +after_script: R -q -e 'tic::after_script()' +# DO NOT CHANGE THE CODE ABOVE + +language: r +os: osx +cache: + - packages + - $HOME/.ccache + - $HOME/Library/Caches/Homebrew +latex: false + +env: + global: + - MAKEFLAGS="-j 2" + diff --git a/man/tic-package.Rd b/man/tic-package.Rd index 0530c2c3..1a33a057 100644 --- a/man/tic-package.Rd +++ b/man/tic-package.Rd @@ -10,8 +10,7 @@ Provides a way to describe common build and deployment workflows for R-based projects: packages, websites (e.g. blogdown, pkgdown), or data processing (e.g. research compendia). The recipe is described independent of the continuous integration tool - used for processing the workflow (e.g. 'Travis CI' or - 'AppVeyor'). + used for processing the workflow (e.g. 'Travis CI' or 'AppVeyor'). } \details{ The \code{\link[=use_tic]{use_tic()}} function prepares a code repository for use with diff --git a/man/use_tic.Rd b/man/use_tic.Rd index 913be64b..85143dad 100644 --- a/man/use_tic.Rd +++ b/man/use_tic.Rd @@ -7,39 +7,18 @@ use_tic(quiet = FALSE) } \arguments{ -\item{quiet}{\code{[flag]}\cr -Less verbose output? Default: \code{FALSE}.} +\item{quiet}{\code{[flag]}\cr Less verbose output? Default: \code{FALSE}.} } \description{ -Prepares a repo for building and deploying supported by \pkg{tic}. +Prepares a repo for building and deploying supported by +\pkg{tic}. } \details{ -This function requires the \pkg{travis} and \pkg{usethis} packages. - -The project path is retrieved with \code{\link[usethis:proj_get]{usethis::proj_get()}}. - -The preparation consists of the following steps: \enumerate{ -\item If necessary, create a GitHub repository via \code{\link[usethis:use_github]{usethis::use_github()}} -\item Enable Travis via \code{\link[travis:travis_enable]{travis::travis_enable()}} -\item Create a default \code{.travis.yml} file -(overwrite after confirmation in interactive mode only) -\item Create a default \code{appveyor.yml} file -(depending on repo type, overwrite after confirmation -in interactive mode only) -\item Create a default \code{.circleci/config.yml} file -(depending on repo type, overwrite after confirmation -in interactive mode only) +\item Query information which CI providers should be used +\item Setup permissions for providers selected for deployment +\item Create YAML files for selected providers \item Create a default \code{tic.R} file depending on the repo type (package, website, bookdown, ...) -\item Enable deployment (if necessary, depending on repo type) -via \code{\link[=use_travis_deploy]{use_travis_deploy()}} -\item Create a GitHub PAT and install it on Travis CI -via \code{\link[travis:travis_set_pat]{travis::travis_set_pat()}} } - -This function is aimed at supporting the most common use cases. -Users who require more control are advised to review -the source code of \code{use_tic()} -and manually call the individual functions, some of which aren't exported. } diff --git a/man/use_travis_deploy.Rd b/man/use_travis_deploy.Rd index 0289be34..c79f3c21 100644 --- a/man/use_travis_deploy.Rd +++ b/man/use_travis_deploy.Rd @@ -16,8 +16,7 @@ The private environment variable on Travis CI to write the private key to, default: \code{"id_rsa"}. Use this value as \code{name} argument to \code{\link[=step_setup_ssh]{step_setup_ssh()}} or \code{\link[=step_install_ssh_keys]{step_install_ssh_keys()}}.} -\item{quiet}{\code{[flag]}\cr -Less verbose output? Default: \code{FALSE}.} +\item{quiet}{\code{[flag]}\cr Less verbose output? Default: \code{FALSE}.} } \description{ Creates a public-private key pair, diff --git a/man/yaml-templates.Rd b/man/yaml-templates.Rd new file mode 100644 index 00000000..bbb65d57 --- /dev/null +++ b/man/yaml-templates.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/use-yaml.R +\name{yaml-templates} +\alias{yaml-templates} +\alias{use_travis_yml} +\alias{use_appveyor_yml} +\alias{use_circle_yml} +\title{Use CI YAML templates} +\usage{ +use_travis_yml(type) + +use_appveyor_yml(type) + +use_circle_yml(type) +} +\arguments{ +\item{type}{\code{[character]}\cr +Which template to use. The string should be given following the logic +\code{--}. See details for more.} +} +\description{ +Installs YAML templates for various CI providers. +} +\section{Type}{ + +\code{tic} supports a variety of different YAML templates which follow the +\code{--} pattern. The first one is mandatory, the +others are optional. +\itemize{ +\item Possible values for \code{} are \code{travis}, and \code{circle} +\item Possible values for \code{} are \code{linux}, and \code{macos}, \code{windows}. +\item Possible values for \code{} are \code{matrix} and \code{deploy}. +} + +Not every combinations is supported on all CI systems. +For example, for \code{use_appveyor_yaml()} only \code{windows} and \code{windows-matrix} are valid. +} + diff --git a/vignettes/build-lifecycle.Rmd b/vignettes/build-lifecycle.Rmd index e35bc709..cbeda6d7 100644 --- a/vignettes/build-lifecycle.Rmd +++ b/vignettes/build-lifecycle.Rmd @@ -41,7 +41,6 @@ before_install: - R -q -e 'remotes::install_cran("tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()' - R -q -e 'tic::before_install()' install: R -q -e 'tic::install()' -after_install: R -q -e 'tic::after_install()' before_script: R -q -e 'tic::before_script()' script: R -q -e 'tic::script()' after_success: R -q -e 'tic::after_success()' diff --git a/vignettes/tic.Rmd b/vignettes/tic.Rmd index dfda6487..2588c2fc 100644 --- a/vignettes/tic.Rmd +++ b/vignettes/tic.Rmd @@ -29,167 +29,89 @@ See the ["Features" article](features.html) for a comparison with other solution # Initialization The easiest way to use *tic* for CI services is to call `tic::use_tic()`. -This will create templates for both "Travis CI" and "Appveyor" and initialize all the required authentication steps for deployment. -During the process, browser pages will open up, ensuring that all permissions are set correctly and all apps are authorized. -Also a Personal Access Token (PAT) will be created on GitHub and stored as an encrypted variable on Travis. -This avoids hitting rate limitations when accessing the GitHub API, see [Locke Data's blog post about GitHUB PATs](https://itsalocke.com/blog/using-travis-make-sure-you-use-a-github-pat/) for more details. -The PAT creation cannot be fully automated as some input from the user on GitHub is required when creating the PAT. +This will initialize a setup wizard which will guide you through all possibilities of the offered CI providers by _tic_. -First, authentication with Travis (a browser window opens) and GitHub is initiated (another browser window opens). -Also, the repo is activated on Travis. +Several yes/no questions need to be answered. +Based on the replies we'll select specific templates. + +Besides the question which CI system you want to use, you'll be asked if you want to + +- deploy from builds to Github (e.g. if you are building a pkgdown site) + +- test your package on multiple R versions ```r tic::use_tic() -┌───────────────────────┐ -│ │ -│ Welcome to `tic`! │ -│ │ -└───────────────────────┘ -ℹ This wizard will set all the required tokens and files - on Travis CI and GitHub. Lets get started! -✔ Setting active project to '/home/pjs/git/test2' -ℹ Using active project '/home/pjs/git/test2' -┌──────────────────────────────────────────────────────┐ -│ │ -│ Step #1: We check if a GitHub repository exists. │ -│ │ -└──────────────────────────────────────────────────────┘ -❯ Authenticating to GitHub. -Waiting for authentication in browser... -Press Esc/Ctrl + C to abort -Authentication complete. -✔ Authentication successful. -❯ Authenticating to GitHub. -Waiting for authentication in browser... -Press Esc/Ctrl + C to abort -Authentication complete. -✔ Authentication successful. -✔ GitHub repo exists. -┌─────────────────────────────────────────────────────┐ -│ │ -│ Step #2: We check if Travis is already enabled. │ -│ │ -└─────────────────────────────────────────────────────┘ -❯ Authenticating to GitHub. -Waiting for authentication in browser... -Press Esc/Ctrl + C to abort -Authentication complete. -✔ Authentication successful. -❯ Authenticating to GitHub. -❯ Authenticating to GitHub. -Waiting for authentication in browser... -Press Esc/Ctrl + C to abort -Authentication complete. -✔ Authentication successful. -Finished activating repo pat-s/test2 on Travis CI. -``` -Next, you will be asked if the current `.travis.yml` should be replaced with the template from *tic* (if one exists). -Otherwise, the template is added without asking. +→ Welcome to → tic! +This wizard will guide you through the setup process for getting started with various CI +providers. -```r -┌────────────────────────────────────────────────┐ -│ │ -│ Step #3: We create new files │ -│ `.travis.yml`, `appveyor.yml` and `tic.R`. │ -│ │ -└────────────────────────────────────────────────┘ -Overwrite pre-existing file '.travis.yml'? -1: Absolutely not -2: Nope -3: Yeah -``` +Introduction: -The same is done for Appveyor. +tic currently comes with support for three CI providers: +● Appveyor +● Circle CI +● Travis CI -``` -Selection: 3 -✔ Writing '.travis.yml' -Overwrite pre-existing file 'appveyor.yml'? -1: Yeah -2: Nope -3: No way - -Selection: 1 -✔ Writing 'appveyor.yml' -``` +There is no need to use all of them. You can choose which one(s) you want to use, whether +you want to deploy (i.e. push from builds) and if you want to test on multiple R +versions. -And also for the `tic.R` file. -Additionally, it is added to `.Rbuildignore` to not interfere with the package building. +We recommend the following setup: +● Appveyor: Windows +● Circle CI: Linux +● Travis CI: macOS -``` -Overwrite tic.R? +Selection: 2 +Choosing your setup. + +We'll ask you a few yes/no questions to gather your preferences. + +Do you want to build on Windows (= Appveyor)? 1: Yes 2: No -Selection: 1 -Added tic.R from template. -✔ Adding '^tic\\.R$' to '.Rbuildignore' -``` +Do you want to build on macOS (= Travis CI)? -Next, the private deploy key for Travis is added to the GitHub repo. -This is needed to give Travis permissions to deploy into the GitHub repo. +1: Yes +2: No -```r -┌───────────────────────────────────────────┐ -│ │ -│ Step #4: We create a SSH key pair │ -│ to allow Travis deployment to GitHub. │ -│ │ -└───────────────────────────────────────────┘ -Finished adding deploy keys on GitHub for repo . -✔ Successfully added public deploy key 'travis+tic' to GitHub for . -❯ You should receive a confirmation e-mail from GitHub. -❯ Delete the key in the repositorys settings to revoke access for that key or when you no longer need it. -``` +Which provider do you want to use for Linux builds? -Besides the private deploy key, also the public deploy key needs to be added as an environment variable to Travis. -As it is a SSH key, its named `id_rsa` by default. +1: Circle CI +2: Travis CI +3: None +4: All -```r -❯ Authenticating to GitHub. -Waiting for authentication in browser... -Press Esc/Ctrl + C to abort -Authentication complete. -✔ Authentication successful. -Finished updating private environment variable id_rsa for on Travis CI. -✔ Successfully added private deploy key to as secure environment variable id_rsa to Travis CI. -``` +Do you want to deploy (i.e. push from the CI build to your repo) on certain providers? If yes, which ones? -Last, a PAT is created to avoid the download limit of GitHub packages on Travis. -You now see two environment variables in your setting on Travis CI: `GITHUB_PAT` and `id_rsa`. +1: Circle CI +2: Travis CI +3: No +4: All -```r -┌─────────────────────────────────────────────────────────┐ -│ │ -│ Step #5: We create a GitHub PAT key on Travis CI │ -│ to avoid GitHub API rate limitations in the builds. │ -│ │ -└─────────────────────────────────────────────────────────┘ -❯ Authenticating to GitHub. -Waiting for authentication in browser... -Press Esc/Ctrl + C to abort -Authentication complete. -✔ Authentication successful. -❯ Creating a personal access token (PAT). -❯ The suggested description 'travis+tic for pat-s/test2' has been copied to the clipboard.travis+tic for pat-s/test2 -ℹ If you use this token only to avoid GitHubs rate limit, you can leave all scopes unchecked. -ℹ Then, copy the new token to the clipboard, it will be detected and applied automatically. -ℹ Please visit - https://github.com/settings/tokens/new - A browser window will be opened. -ℹ If you use this token only to avoid GitHubs rate limit, you can leave all scopes unchecked. +Do you want to build on multiple R versions? (i.e. R-devel, R-release, R-oldrelease). If yes, on which platform(s)? + +1: Circle CI +2: Travis CI +3: Appveyor +4: No +5: All ``` -Most functionality of the wizard comes from the _travis_ package. +Last, we'll add a `tic.R` file to the project root. + + +The deployment setup functionality comes from the _travis_ and _circle_ packages. See the ["tic & travis" article](tic-travis.html) for more detailed information on how *tic* and *travis* work together. # Explanation of the basic template -After having called `tic::use_tic()` you will find a `.travis.yml`, `appveyor.yml` and a `tic.R` file in your repo. -Usually you do not need to touch `appveyor.yml` and `.travis.yml` anymore. -All build customizations are done in `tic.R` and apply to both services. +After having called `tic::use_tic()` you will find a `.travis.yml`, `.circleci/config.yml`, `appveyor.yml` and a `tic.R` file in your repo. +Usually you do not need to touch the YAML files anymore. +All build customization are done in `tic.R` and apply to all providers. For more information about the whole build lifecycle, check the ["Build lifecycle" article](build-lifecycle.html). The basic `tic.R` template looks as follows: @@ -297,7 +219,6 @@ You may find inspiration for your own project there. - [sf](https://github.com/r-spatial/sf) - [dbi](https://github.com/r-dbi/DBI) - # Advanced The advanced usage of *tic* is described in more detail in the ["Advanced Usage" article](advanced.html):