From 2152aab4c0d536c4b650f740d8acca0393e94b7c Mon Sep 17 00:00:00 2001 From: pat-s Date: Mon, 21 Oct 2019 21:59:57 +0200 Subject: [PATCH 01/17] save progress --- R/use_tic.R | 109 ++++++++++++++++++++++++---------------------------- R/utils.R | 31 +++++++++++++++ 2 files changed, 81 insertions(+), 59 deletions(-) diff --git a/R/use_tic.R b/R/use_tic.R index 133acbfc..bb38c8c7 100644 --- a/R/use_tic.R +++ b/R/use_tic.R @@ -10,31 +10,49 @@ #' #' @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." + )) + + cli_h1("Introduction:") + cli_text("{.pkg tic} currently comes with support for three CI providers: ") + + cli_ul(c("Appveyor", "Circle CI", "Travis CI")) + + cli_par() + cli_text(c("There is no need to use all of them.", + " You can choose which one(s) you want to use and on which systems you want to build on.") ) + cli_end() - #' @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_text("We recommend the following setup:") + cli_ul(c("Appveyor: Windows", "Circle CI: Linux", "Travis CI: macOS")) - if (!is_installed("usethis")) { - cli::cat_rule(col = "red") - stopc( - "`use_tic()` needs the `usethis` package, ", - 'please install using `install.packages("usethis")`.' - ) + if (yesno("Ready to get started?")) { + return(invisible()) } + cli_h1("Choosing your setup.") + cli_text("We'll ask you a few yes/no questions to gather your preferences.") + + 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", "Both"), title = "Which provider do you want to use for Linux builds?") + + deploy = menu(c("Circle CI", "Travis CI", "None", "Both"), title = "Do you want to deploy (i.e. push from the CI build to your repo) on certain providers? If yes, which ones?") + + cli_h1("Setting up the CI providers.") + + cli_text("Now 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.") + if (linux == 2 && deploy == 2) { + browser() + + check_travis_pkg() + check_usethis_pkg() + #' @details #' The project path is retrieved with [usethis::proj_get()]. path <- usethis::proj_get() @@ -46,54 +64,27 @@ use_tic <- function(quiet = FALSE) { 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" - ) - - 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" - ) + check_openssl_pkg() } #' 1. Enable Travis via [travis::travis_enable()] - cli::cat_boxx( - "Step #2: We check if Travis is already enabled.", - col = "green" - ) + cli_alert_info("Step #1: Checking if Travis CI is enabled for this repo.") travis::travis_enable() - cli::cat_boxx( - c( - "Step #3: We create new files", - "`.travis.yml`, `appveyor.yml` and `tic.R`." - ), - col = "green" - ) + cli_alert_info(c("Step #2: Creation of YAML file.")) #' 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) diff --git a/R/utils.R b/R/utils.R index 7ea9291a..411fcc4a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -45,3 +45,34 @@ 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_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")`.' + ) + } +} From 66169a9fa2e32c7e71672aeccaf7fb663af91059 Mon Sep 17 00:00:00 2001 From: pat-s Date: Tue, 22 Oct 2019 23:09:03 +0200 Subject: [PATCH 02/17] save progress --- R/use_tic.R | 104 ++++++++++++++- R/utils.R | 18 +++ inst/templates/circle-deploy-matrix.yml | 123 ++++++++++++++++++ inst/templates/circle-deploy.yml | 83 ++++++++++++ inst/templates/circle-matrix.yml | 96 ++++++++++++++ inst/templates/circle.yml | 33 +---- .../dot-travis-linux-deploy-matrix.yml | 53 ++++++++ inst/templates/dot-travis-linux-deploy.yml | 44 +++++++ inst/templates/dot-travis-linux-matrix.yml | 46 +++++++ inst/templates/dot-travis-linux.yml | 38 ++++++ .../dot-travis-macos-deploy-matrix.yml | 52 ++++++++ ...travis.yml => dot-travis-macos-deploy.yml} | 7 +- inst/templates/dot-travis-macos-matrix.yml | 44 +++++++ inst/templates/dot-travis-macos.yml | 38 ++++++ 14 files changed, 740 insertions(+), 39 deletions(-) create mode 100644 inst/templates/circle-deploy-matrix.yml create mode 100644 inst/templates/circle-deploy.yml create mode 100644 inst/templates/circle-matrix.yml create mode 100644 inst/templates/dot-travis-linux-deploy-matrix.yml create mode 100644 inst/templates/dot-travis-linux-deploy.yml create mode 100644 inst/templates/dot-travis-linux-matrix.yml create mode 100644 inst/templates/dot-travis-linux.yml create mode 100644 inst/templates/dot-travis-macos-deploy-matrix.yml rename inst/templates/{dot-travis.yml => dot-travis-macos-deploy.yml} (96%) create mode 100644 inst/templates/dot-travis-macos-matrix.yml create mode 100644 inst/templates/dot-travis-macos.yml diff --git a/R/use_tic.R b/R/use_tic.R index bb38c8c7..ed8b1d8f 100644 --- a/R/use_tic.R +++ b/R/use_tic.R @@ -39,19 +39,112 @@ use_tic <- function(quiet = FALSE) { 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", "Both"), title = "Which provider do you want to use for Linux builds?") + 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", "None", "Both"), title = "Do you want to deploy (i.e. push from the CI build to your repo) on certain providers? If yes, which ones?") + deploy = menu(c("Circle CI", "Travis CI", "None", "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", "None", "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("Now 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.") - if (linux == 2 && deploy == 2) { - browser() + # init deploy ---------------------------------------------------------------- + + if (deploy == 1) { + check_circle_pkg() + circle::enable_project() + circle::use_circle_deploy() + } else if (deploy == 2) { + travis::travis_enable() + check_travis_pkg() + travis::use_travis_deploy() + } else if (deploy == 3) { + travis::travis_enable() + check_travis_pkg() + + check_circle_pkg() + + circle::use_circle_deploy() + travis::use_travis_deploy() + } + + # create YAMLS --------------------------------------------------------------- + + cli_h1("Creating YAML files.") + + cli_text("Next, we are creating the YAML files based on your selected preferences.") + + # Travis --------------------------------------------------------------------- + + 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 ---------------------------------------------------------------------- + + + + + + + if (matrix) + + } else if (deploy == 2) { + travis::travis_enable() check_travis_pkg() - check_usethis_pkg() + travis::use_travis_deploy() + } else if (deploy == 3) { + travis::travis_enable() + check_travis_pkg() + + check_circle_pkg() + + circle::use_circle_deploy() + travis::use_travis_deploy() + } + + + + + + # build and deploy on Travis + if (linux == 2 && deploy == 2) { #' @details #' The project path is retrieved with [usethis::proj_get()]. @@ -78,6 +171,7 @@ use_tic <- function(quiet = FALSE) { use_travis_yml() + # FIXME> We should offer templates for building on one R version and on devel/release/oldrel diff --git a/R/utils.R b/R/utils.R index 411fcc4a..b82f6a9c 100644 --- a/R/utils.R +++ b/R/utils.R @@ -67,6 +67,16 @@ check_travis_pkg = function() { } } +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") @@ -76,3 +86,11 @@ check_usethis_pkg = function() { ) } } + +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").' + ) +} diff --git a/inst/templates/circle-deploy-matrix.yml b/inst/templates/circle-deploy-matrix.yml new file mode 100644 index 00000000..774196f9 --- /dev/null +++ b/inst/templates/circle-deploy-matrix.yml @@ -0,0 +1,123 @@ +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..83c0f60a --- /dev/null +++ b/inst/templates/circle-deploy.yml @@ -0,0 +1,83 @@ +version: 2 +jobs: + build: + docker: + - image: rocker/verse + 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')" > /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" }} + # 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: + 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..c80a507d --- /dev/null +++ b/inst/templates/circle-matrix.yml @@ -0,0 +1,96 @@ +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..ec71dae7 100644 --- a/inst/templates/circle.yml +++ b/inst/templates/circle.yml @@ -35,42 +35,13 @@ jobs: 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/dot-travis-linux-deploy-matrix.yml b/inst/templates/dot-travis-linux-deploy-matrix.yml new file mode 100644 index 00000000..99088b6d --- /dev/null +++ b/inst/templates/dot-travis-linux-deploy-matrix.yml @@ -0,0 +1,53 @@ +# 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: + - 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()' +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()' +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 + +# Custom parts: + +# Header +language: r +sudo: false +dist: bionic +cache: + - packages + - $HOME/.ccache +latex: false + +#env +env: + global: + - MAKEFLAGS="-j 2" + +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release + +#services +services: diff --git a/inst/templates/dot-travis-linux-deploy.yml b/inst/templates/dot-travis-linux-deploy.yml new file mode 100644 index 00000000..ba8896f4 --- /dev/null +++ b/inst/templates/dot-travis-linux-deploy.yml @@ -0,0 +1,44 @@ +# 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: + - 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()' +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()' +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 + +# Custom parts: + +# Header +language: r +dist: bionic +cache: + - packages + - $HOME/.ccache +latex: false + +#env +env: + global: + - MAKEFLAGS="-j 2" + +#services +services: diff --git a/inst/templates/dot-travis-linux-matrix.yml b/inst/templates/dot-travis-linux-matrix.yml new file mode 100644 index 00000000..450ecec6 --- /dev/null +++ b/inst/templates/dot-travis-linux-matrix.yml @@ -0,0 +1,46 @@ +# 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: + - 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()' +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()' +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 + +# Custom parts: + +# Header +language: r +dist: bionic +cache: + - packages + - $HOME/.ccache +latex: false + +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release + +#env +env: + global: + - MAKEFLAGS="-j 2" + +#services +services: diff --git a/inst/templates/dot-travis-linux.yml b/inst/templates/dot-travis-linux.yml new file mode 100644 index 00000000..ed83ea73 --- /dev/null +++ b/inst/templates/dot-travis-linux.yml @@ -0,0 +1,38 @@ +# 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: + - 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()' +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()' +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 + +# Custom parts: + +# Header +language: r +dist: bionic +cache: + - packages + - $HOME/.ccache +latex: false + +#env +env: + global: + - MAKEFLAGS="-j 2" + +#services +services: diff --git a/inst/templates/dot-travis-macos-deploy-matrix.yml b/inst/templates/dot-travis-macos-deploy-matrix.yml new file mode 100644 index 00000000..07e02923 --- /dev/null +++ b/inst/templates/dot-travis-macos-deploy-matrix.yml @@ -0,0 +1,52 @@ +# 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: + - 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()' +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()' +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 + +# Custom parts: + +# Header +language: r +os: osx +cache: + - packages + - $HOME/.ccache +latex: false + +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release + +#env +env: + global: + - MAKEFLAGS="-j 2" + +#services +services: diff --git a/inst/templates/dot-travis.yml b/inst/templates/dot-travis-macos-deploy.yml similarity index 96% rename from inst/templates/dot-travis.yml rename to inst/templates/dot-travis-macos-deploy.yml index 3962c65a..9165e26b 100644 --- a/inst/templates/dot-travis.yml +++ b/inst/templates/dot-travis-macos-deploy.yml @@ -29,9 +29,10 @@ after_script: R -q -e 'tic::after_script()' # Header language: r -sudo: false -dist: xenial -cache: packages +os: osx +cache: + - packages + - $HOME/.ccache latex: false #env diff --git a/inst/templates/dot-travis-macos-matrix.yml b/inst/templates/dot-travis-macos-matrix.yml new file mode 100644 index 00000000..7e47b475 --- /dev/null +++ b/inst/templates/dot-travis-macos-matrix.yml @@ -0,0 +1,44 @@ +# 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: + - 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()' +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()' +after_failure: R -q -e 'tic::after_failure()' +# DO NOT CHANGE THE CODE ABOVE + +# Custom parts: + +# Header +language: r +os: osx +cache: + - packages + - $HOME/.ccache +latex: false + +matrix: + allow_failures: + - r: oldrel + include: + - r: devel + - r: oldrel + - r: release + +#env +env: + global: + - MAKEFLAGS="-j 2" + +#services +services: diff --git a/inst/templates/dot-travis-macos.yml b/inst/templates/dot-travis-macos.yml new file mode 100644 index 00000000..9a1fc90d --- /dev/null +++ b/inst/templates/dot-travis-macos.yml @@ -0,0 +1,38 @@ +# 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: + - 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()' +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()' +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 + +# Custom parts: + +# Header +language: r +os: osx +cache: + - packages + - $HOME/.ccache +latex: false + +#env +env: + global: + - MAKEFLAGS="-j 2" + +#services +services: From 84c7d0dcadf6ee2f5b33caff7a0f320d27036251 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 24 Oct 2019 23:36:38 +0200 Subject: [PATCH 03/17] update templates --- inst/templates/appveyor-matrix.yml | 34 +++++++++++++++++++ inst/templates/appveyor.yml | 34 +------------------ inst/templates/circle-deploy-matrix.yml | 12 ++++--- inst/templates/circle-deploy.yml | 19 +++++------ inst/templates/circle-matrix.yml | 10 +++--- inst/templates/circle.yml | 4 +-- .../dot-travis-linux-deploy-matrix.yml | 10 ------ inst/templates/dot-travis-linux-deploy.yml | 9 ----- inst/templates/dot-travis-linux-matrix.yml | 9 ----- inst/templates/dot-travis-linux.yml | 9 ----- .../dot-travis-macos-deploy-matrix.yml | 10 +----- inst/templates/dot-travis-macos-deploy.yml | 10 +----- inst/templates/dot-travis-macos-matrix.yml | 10 +----- inst/templates/dot-travis-macos.yml | 9 +---- 14 files changed, 62 insertions(+), 127 deletions(-) create mode 100644 inst/templates/appveyor-matrix.yml 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 index 774196f9..913a0f8a 100644 --- a/inst/templates/circle-deploy-matrix.yml +++ b/inst/templates/circle-deploy-matrix.yml @@ -1,3 +1,5 @@ +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + version: 2 jobs: "r-3.6.1": @@ -10,7 +12,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')3.6.1" > /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: @@ -33,7 +35,7 @@ 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: @@ -45,7 +47,7 @@ jobs: - checkout - 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" # 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: @@ -71,7 +73,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')3.5.3" > /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: @@ -94,7 +96,7 @@ 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 diff --git a/inst/templates/circle-deploy.yml b/inst/templates/circle-deploy.yml index 83c0f60a..e99ebb59 100644 --- a/inst/templates/circle-deploy.yml +++ b/inst/templates/circle-deploy.yml @@ -1,17 +1,19 @@ +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + version: 2 jobs: - build: + "r-3.6.1": docker: - - image: rocker/verse + - 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')" > /tmp/_tmp_file + - run: echo "$(date -d "$D" '+%d')3.6.1" > /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,7 +34,7 @@ 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: @@ -44,12 +46,7 @@ jobs: - 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" + key: R-package-library-checksum "/tmp/_tmp_file" - run: name: Deploy Over SSH command: | diff --git a/inst/templates/circle-matrix.yml b/inst/templates/circle-matrix.yml index c80a507d..61597492 100644 --- a/inst/templates/circle-matrix.yml +++ b/inst/templates/circle-matrix.yml @@ -1,3 +1,5 @@ +# tic documentation to get started: https://ropenscilabs.github.io/tic/ + version: 2 jobs: "r-3.6.1": @@ -10,7 +12,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')3.6.1" > /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: @@ -33,7 +35,7 @@ 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 @@ -47,7 +49,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')3.5.3" > /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: @@ -70,7 +72,7 @@ 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 diff --git a/inst/templates/circle.yml b/inst/templates/circle.yml index ec71dae7..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,7 +32,7 @@ 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 diff --git a/inst/templates/dot-travis-linux-deploy-matrix.yml b/inst/templates/dot-travis-linux-deploy-matrix.yml index 99088b6d..a78b0cf6 100644 --- a/inst/templates/dot-travis-linux-deploy-matrix.yml +++ b/inst/templates/dot-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: @@ -25,18 +23,13 @@ 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: bionic cache: - packages - $HOME/.ccache latex: false -#env env: global: - MAKEFLAGS="-j 2" @@ -48,6 +41,3 @@ matrix: - r: devel - r: oldrel - r: release - -#services -services: diff --git a/inst/templates/dot-travis-linux-deploy.yml b/inst/templates/dot-travis-linux-deploy.yml index ba8896f4..d4aa2f86 100644 --- a/inst/templates/dot-travis-linux-deploy.yml +++ b/inst/templates/dot-travis-linux-deploy.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: @@ -25,9 +23,6 @@ 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 dist: bionic cache: @@ -35,10 +30,6 @@ cache: - $HOME/.ccache latex: false -#env env: global: - MAKEFLAGS="-j 2" - -#services -services: diff --git a/inst/templates/dot-travis-linux-matrix.yml b/inst/templates/dot-travis-linux-matrix.yml index 450ecec6..85ff05bb 100644 --- a/inst/templates/dot-travis-linux-matrix.yml +++ b/inst/templates/dot-travis-linux-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: @@ -19,9 +17,6 @@ before_deploy: R -q -e 'tic::before_deploy()' after_script: R -q -e 'tic::after_script()' # DO NOT CHANGE THE CODE ABOVE -# Custom parts: - -# Header language: r dist: bionic cache: @@ -37,10 +32,6 @@ matrix: - r: oldrel - r: release -#env env: global: - MAKEFLAGS="-j 2" - -#services -services: diff --git a/inst/templates/dot-travis-linux.yml b/inst/templates/dot-travis-linux.yml index ed83ea73..561ca0be 100644 --- a/inst/templates/dot-travis-linux.yml +++ b/inst/templates/dot-travis-linux.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: @@ -19,9 +17,6 @@ before_deploy: R -q -e 'tic::before_deploy()' after_script: R -q -e 'tic::after_script()' # DO NOT CHANGE THE CODE ABOVE -# Custom parts: - -# Header language: r dist: bionic cache: @@ -29,10 +24,6 @@ cache: - $HOME/.ccache latex: false -#env env: global: - MAKEFLAGS="-j 2" - -#services -services: diff --git a/inst/templates/dot-travis-macos-deploy-matrix.yml b/inst/templates/dot-travis-macos-deploy-matrix.yml index 07e02923..64c84be9 100644 --- a/inst/templates/dot-travis-macos-deploy-matrix.yml +++ b/inst/templates/dot-travis-macos-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: @@ -25,14 +23,12 @@ 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 os: osx cache: - packages - $HOME/.ccache + - $HOME/Library/Caches/Homebrew latex: false matrix: @@ -43,10 +39,6 @@ matrix: - r: oldrel - r: release -#env env: global: - MAKEFLAGS="-j 2" - -#services -services: diff --git a/inst/templates/dot-travis-macos-deploy.yml b/inst/templates/dot-travis-macos-deploy.yml index 9165e26b..b41b6d79 100644 --- a/inst/templates/dot-travis-macos-deploy.yml +++ b/inst/templates/dot-travis-macos-deploy.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: @@ -25,20 +23,14 @@ 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 os: osx cache: - packages - $HOME/.ccache + - $HOME/Library/Caches/Homebrew latex: false -#env env: global: - MAKEFLAGS="-j 2" - -#services -services: diff --git a/inst/templates/dot-travis-macos-matrix.yml b/inst/templates/dot-travis-macos-matrix.yml index 7e47b475..f9369946 100644 --- a/inst/templates/dot-travis-macos-matrix.yml +++ b/inst/templates/dot-travis-macos-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: @@ -17,14 +15,12 @@ after_success: R -q -e 'tic::after_success()' after_failure: R -q -e 'tic::after_failure()' # DO NOT CHANGE THE CODE ABOVE -# Custom parts: - -# Header language: r os: osx cache: - packages - $HOME/.ccache + - $HOME/Library/Caches/Homebrew latex: false matrix: @@ -35,10 +31,6 @@ matrix: - r: oldrel - r: release -#env env: global: - MAKEFLAGS="-j 2" - -#services -services: diff --git a/inst/templates/dot-travis-macos.yml b/inst/templates/dot-travis-macos.yml index 9a1fc90d..bdb0209b 100644 --- a/inst/templates/dot-travis-macos.yml +++ b/inst/templates/dot-travis-macos.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: @@ -19,20 +17,15 @@ before_deploy: R -q -e 'tic::before_deploy()' after_script: R -q -e 'tic::after_script()' # DO NOT CHANGE THE CODE ABOVE -# Custom parts: - -# Header language: r os: osx cache: - packages - $HOME/.ccache + - $HOME/Library/Caches/Homebrew latex: false -#env env: global: - MAKEFLAGS="-j 2" -#services -services: From 6bef17514f2911026373711d26a0d39afdcb0677 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 24 Oct 2019 23:36:56 +0200 Subject: [PATCH 04/17] first version of new use_tic() --- R/use_tic.R | 297 +++++++++++----------------------------------------- R/utils.R | 66 ++++++++++++ 2 files changed, 130 insertions(+), 233 deletions(-) diff --git a/R/use_tic.R b/R/use_tic.R index ed8b1d8f..f40d68d3 100644 --- a/R/use_tic.R +++ b/R/use_tic.R @@ -1,13 +1,16 @@ -# 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_alert("Welcome to {.pkg tic}!") @@ -22,12 +25,16 @@ use_tic <- function(quiet = FALSE) { cli_par() cli_text(c("There is no need to use all of them.", - " You can choose which one(s) you want to use and on which systems you want to build on.") + " 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.") ) 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()) @@ -35,6 +42,8 @@ use_tic <- function(quiet = FALSE) { 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)?") @@ -42,42 +51,49 @@ use_tic <- function(quiet = FALSE) { 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", "None", "All"), + 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", "None", "All"), + 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("Now 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_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() + browser() # init deploy ---------------------------------------------------------------- if (deploy == 1) { + cat(boxx("Circle CI", border_style = "double")) check_circle_pkg() circle::enable_project() circle::use_circle_deploy() } else if (deploy == 2) { + cat(boxx("Travis CI", border_style = "double")) travis::travis_enable() check_travis_pkg() travis::use_travis_deploy() } else if (deploy == 3) { - travis::travis_enable() + cat(boxx("Travis CI", border_style = "double")) check_travis_pkg() + travis::travis_enable() + travis::use_travis_deploy() + boxx("Circle CI", border_style = "double") check_circle_pkg() - + circle::enable_project() circle::use_circle_deploy() - travis::use_travis_deploy() } - # create YAMLS --------------------------------------------------------------- - - cli_h1("Creating YAML files.") + # create YAMLs --------------------------------------------------------------- - cli_text("Next, we are creating the YAML files based on your selected preferences.") + cli_par() + cli_end() + cli_h1("Creating YAML files...") # Travis --------------------------------------------------------------------- @@ -93,7 +109,7 @@ use_tic <- function(quiet = FALSE) { } else { # build matrix if (matrix == 2 || matrix == 5) { - use_travis_yml("linux=matrix") + use_travis_yml("linux-matrix") } else { use_travis_yml("linux") } @@ -102,7 +118,7 @@ use_tic <- function(quiet = FALSE) { if (deploy == 2 || deploy == 4) { # build matrix if (matrix == 2 || matrix == 5) { - use_travis_yml("macos-deploy-matrix") + use_travis_yml("macos-deploy-matrix") } else { use_travis_yml("macos-deploy") } @@ -116,231 +132,46 @@ use_tic <- function(quiet = FALSE) { } } - # Circle ---------------------------------------------------------------------- - - - - - - - if (matrix) - - } else if (deploy == 2) { - travis::travis_enable() - check_travis_pkg() - travis::use_travis_deploy() - } else if (deploy == 3) { - travis::travis_enable() - check_travis_pkg() - - check_circle_pkg() - - circle::use_circle_deploy() - travis::use_travis_deploy() - } - - - - - - # build and deploy on Travis - if (linux == 2 && deploy == 2) { - - #' @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)) - ) + # Circle ---------------------------------------------------------------------- - repo_type <- detect_repo_type() - - if (needs_deploy(repo_type) && !is_installed("openssl")) { - check_openssl_pkg() + 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") + } + } } - #' 1. Enable Travis via [travis::travis_enable()] - cli_alert_info("Step #1: Checking if Travis CI is enabled for this repo.") - travis::travis_enable() - - cli_alert_info(c("Step #2: Creation of YAML file.")) - - #' 1. Create a default `.travis.yml` file - #' (overwrite after confirmation in interactive mode only) - use_travis_yml() - - - # FIXME> We should offer templates for building on one R version and on devel/release/oldrel + # Appveyor ------------------------------------------------------------------- - - - - - - - #' 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() + if (windows == 1) { + if (matrix == 3 || matrix == 5) { + use_appveyor_yml("windows-matrix") + } else { + use_appveyor_yml("windows") + } } - #' 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" - ) - if (needs_deploy(repo_type)) use_travis_deploy() + # tic.R ---------------------------------------------------------------------- - 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() + use_tic_r(repo_type = detect_repo_type()) - #' - #' 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())) - ) -} - -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 -} - # This code can only run interactively # nocov end diff --git a/R/utils.R b/R/utils.R index b82f6a9c..690069d9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -94,3 +94,69 @@ check_openssl_pkg = function() { '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) +} From 465b688cdedb3e7905bd5c2608251409cff83cfd Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 24 Oct 2019 23:37:10 +0200 Subject: [PATCH 05/17] outsource to use-yaml.R --- R/use-yaml.R | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 R/use-yaml.R diff --git a/R/use-yaml.R b/R/use-yaml.R new file mode 100644 index 00000000..29ee834b --- /dev/null +++ b/R/use-yaml.R @@ -0,0 +1,69 @@ +use_travis_yml <- function(type) { + if (type == "linux") { + template = "dot-travis-linux.yml" + } else if (type == "linux-matrix") { + template = "dot-travis-linux-matrix.yml" + } else if (type == "linux-deploy") { + template = "dot-travis-linux-deploy.yml" + } else if (type == "linux-deploy-matrix") { + template = "dot-travis-linux-deploy-matrix.yml" + } else if (type == "macos") { + template = "dot-travis-macos.yml" + } else if (type == "macos-matrix") { + template = "dot-travis-macos-matrix.yml" + } else if (type == "macos-deploy") { + template = "dot-travis-macos-deploy.yml" + } else if (type == "macos-deploy-matrix") { + template = "dot-travis-macos-deploy-matrix.yml" + } + use_tic_template( + template, + save_as = ".travis.yml", + data = list(install_tic = double_quotes(get_install_tic_code())) + ) +} + +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()) + ) +} + +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" + } + 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 + ) +} From ad4389f9a3f5a8d369bbaeffd9dbc8318cb9200c Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 24 Oct 2019 23:38:46 +0200 Subject: [PATCH 06/17] add circle to DESC --- DESCRIPTION | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 431e5ffa..58129736 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 @@ -54,6 +53,7 @@ Suggests: base64enc, bookdown, callr, + circle, covr, devtools, drat, @@ -67,8 +67,9 @@ Suggests: travis (>= 0.2.11.9001), usethis VignetteBuilder: - knitr + knitr Remotes: + pat-s/circle, ropenscilabs/travis ByteCompile: No Encoding: UTF-8 @@ -107,5 +108,6 @@ Collate: 'steps-write-text-file.R' 'tic-package.R' 'travis.R' + 'use-yaml.R' 'use_tic.R' 'utils.R' From ae6b5d5cfcda3359ce9ec1db1118921254129d68 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 24 Oct 2019 23:39:26 +0200 Subject: [PATCH 07/17] man --- man/use_tic.Rd | 33 ++++++--------------------------- man/use_travis_deploy.Rd | 3 +-- 2 files changed, 7 insertions(+), 29 deletions(-) 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, From 59cf2470a6d03173d8d3a1ffd1bc500ad159a92b Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 24 Oct 2019 23:52:05 +0200 Subject: [PATCH 08/17] update vignette --- vignettes/tic.Rmd | 192 ++++++++++++++-------------------------------- 1 file changed, 57 insertions(+), 135 deletions(-) diff --git a/vignettes/tic.Rmd b/vignettes/tic.Rmd index dfda6487..5519b943 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: From 81a1d88d075d55e8dfaff7f7b160a24048bf07b2 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 21:29:40 +0100 Subject: [PATCH 09/17] finish use_tic() --- R/use-yaml.R | 1 + R/use_tic.R | 53 ++++++++++++++++++++++++++++++++++++++-------- man/tic-package.Rd | 3 +-- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/R/use-yaml.R b/R/use-yaml.R index 29ee834b..33e41f13 100644 --- a/R/use-yaml.R +++ b/R/use-yaml.R @@ -46,6 +46,7 @@ use_circle_yml <- function(type) { } else if (type == "linux-deploy-matrix") { template = "circle-deploy-matrix.yml" } + dir.create(".circleci") use_tic_template( template, save_as = ".circleci/config.yml", diff --git a/R/use_tic.R b/R/use_tic.R index f40d68d3..08c9067a 100644 --- a/R/use_tic.R +++ b/R/use_tic.R @@ -37,7 +37,7 @@ use_tic <- function(quiet = FALSE) { cli_end() if (yesno("Ready to get started?")) { - return(invisible()) + return(invisible(NULL)) } cli_h1("Choosing your setup.") @@ -64,28 +64,27 @@ use_tic <- function(quiet = FALSE) { cli_par() cli_end() - browser() # init deploy ---------------------------------------------------------------- if (deploy == 1) { - cat(boxx("Circle CI", border_style = "double")) + rule(left = "Circle CI") check_circle_pkg() - circle::enable_project() + circle::enable_repo() circle::use_circle_deploy() } else if (deploy == 2) { - cat(boxx("Travis CI", border_style = "double")) + rule(left = "Travis CI") travis::travis_enable() check_travis_pkg() travis::use_travis_deploy() } else if (deploy == 3) { - cat(boxx("Travis CI", border_style = "double")) + rule(left = "Travis CI") check_travis_pkg() travis::travis_enable() travis::use_travis_deploy() - boxx("Circle CI", border_style = "double") + rule(left = "Circle CI") check_circle_pkg() - circle::enable_project() + circle::enable_repo() circle::use_circle_deploy() } @@ -97,6 +96,8 @@ use_tic <- function(quiet = FALSE) { # Travis --------------------------------------------------------------------- + rule(left = "Travis CI") + if (linux == 2 || linux == 4) { # deployment if (deploy == 2 || deploy == 4) { @@ -134,6 +135,9 @@ use_tic <- function(quiet = FALSE) { # Circle ---------------------------------------------------------------------- + Sys.sleep(3) + rule(left = "Circle CI") + if (linux == 1 || linux == 4) { # deployment if (deploy == 1 || deploy == 4) { @@ -155,6 +159,9 @@ use_tic <- function(quiet = FALSE) { # Appveyor ------------------------------------------------------------------- + Sys.sleep(3) + rule(left = "Appveyor CI") + if (windows == 1) { if (matrix == 3 || matrix == 5) { use_appveyor_yml("windows-matrix") @@ -165,12 +172,40 @@ use_tic <- function(quiet = FALSE) { # 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" + ) + + cat_bullet( + "Below is the file structure of the newly added files (in case you selected all providers):", + bullet = "arrow_down", bullet_col = "blue" + ) + + 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) + )) + ) + tree(data, root = basename(getwd())) + } use_tic_r <- function(repo_type) { - use_tic_template(file.path(repo_type, "tic.R"), "tic.R", open = TRUE) + use_tic_template(file.path(repo_type, "tic.R"), "tic.R") } # This code can only run interactively 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 From ed3832a1e74486c21b5f454e60034c3ba491f646 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 21:32:16 +0100 Subject: [PATCH 10/17] update travis yaml --- .travis.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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: From ddcecb4935927a55eca38dfefbd3da46f148cdf5 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 21:41:23 +0100 Subject: [PATCH 11/17] update badges --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 From 5e4482a4dfecc14ef44db7880d0fc9716165921f Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 21:42:51 +0100 Subject: [PATCH 12/17] remove after_install step --- inst/templates/dot-travis-linux-deploy-matrix.yml | 1 - inst/templates/dot-travis-linux-deploy.yml | 1 - inst/templates/dot-travis-linux-matrix.yml | 1 - inst/templates/dot-travis-linux.yml | 1 - inst/templates/dot-travis-macos-deploy-matrix.yml | 1 - inst/templates/dot-travis-macos-deploy.yml | 1 - inst/templates/dot-travis-macos-matrix.yml | 1 - inst/templates/dot-travis-macos.yml | 1 - vignettes/build-lifecycle.Rmd | 1 - 9 files changed, 9 deletions(-) diff --git a/inst/templates/dot-travis-linux-deploy-matrix.yml b/inst/templates/dot-travis-linux-deploy-matrix.yml index a78b0cf6..04d5641e 100644 --- a/inst/templates/dot-travis-linux-deploy-matrix.yml +++ b/inst/templates/dot-travis-linux-deploy-matrix.yml @@ -8,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()' diff --git a/inst/templates/dot-travis-linux-deploy.yml b/inst/templates/dot-travis-linux-deploy.yml index d4aa2f86..28b81be7 100644 --- a/inst/templates/dot-travis-linux-deploy.yml +++ b/inst/templates/dot-travis-linux-deploy.yml @@ -8,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()' diff --git a/inst/templates/dot-travis-linux-matrix.yml b/inst/templates/dot-travis-linux-matrix.yml index 85ff05bb..784573bc 100644 --- a/inst/templates/dot-travis-linux-matrix.yml +++ b/inst/templates/dot-travis-linux-matrix.yml @@ -8,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()' diff --git a/inst/templates/dot-travis-linux.yml b/inst/templates/dot-travis-linux.yml index 561ca0be..243d69f8 100644 --- a/inst/templates/dot-travis-linux.yml +++ b/inst/templates/dot-travis-linux.yml @@ -8,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()' diff --git a/inst/templates/dot-travis-macos-deploy-matrix.yml b/inst/templates/dot-travis-macos-deploy-matrix.yml index 64c84be9..0d41ee52 100644 --- a/inst/templates/dot-travis-macos-deploy-matrix.yml +++ b/inst/templates/dot-travis-macos-deploy-matrix.yml @@ -8,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()' diff --git a/inst/templates/dot-travis-macos-deploy.yml b/inst/templates/dot-travis-macos-deploy.yml index b41b6d79..205a9a16 100644 --- a/inst/templates/dot-travis-macos-deploy.yml +++ b/inst/templates/dot-travis-macos-deploy.yml @@ -8,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()' diff --git a/inst/templates/dot-travis-macos-matrix.yml b/inst/templates/dot-travis-macos-matrix.yml index f9369946..71f0f533 100644 --- a/inst/templates/dot-travis-macos-matrix.yml +++ b/inst/templates/dot-travis-macos-matrix.yml @@ -8,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()' diff --git a/inst/templates/dot-travis-macos.yml b/inst/templates/dot-travis-macos.yml index bdb0209b..ed73ed9e 100644 --- a/inst/templates/dot-travis-macos.yml +++ b/inst/templates/dot-travis-macos.yml @@ -8,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()' 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()' From 510f185eb3065317a0063c558e12fe703a00578f Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 21:44:28 +0100 Subject: [PATCH 13/17] update tic.R template --- inst/templates/package/tic.R | 2 ++ 1 file changed, 2 insertions(+) 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() } From 2fa36630eebb305074b18889852b2ee1eda6d52e Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 21:44:43 +0100 Subject: [PATCH 14/17] remove empty line --- vignettes/tic.Rmd | 1 - 1 file changed, 1 deletion(-) diff --git a/vignettes/tic.Rmd b/vignettes/tic.Rmd index 5519b943..2588c2fc 100644 --- a/vignettes/tic.Rmd +++ b/vignettes/tic.Rmd @@ -219,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): From a40b0a73dac8b92d81f67d16edef5344ba32a68f Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 22:08:46 +0100 Subject: [PATCH 15/17] dot-travis -> travis --- ...vis-linux-deploy-matrix.yml => travis-linux-deploy-matrix.yml} | 0 .../{dot-travis-linux-deploy.yml => travis-linux-deploy.yml} | 0 .../{dot-travis-linux-matrix.yml => travis-linux-matrix.yml} | 0 inst/templates/{dot-travis-linux.yml => travis-linux.yml} | 0 ...vis-macos-deploy-matrix.yml => travis-macos-deploy-matrix.yml} | 0 .../{dot-travis-macos-deploy.yml => travis-macos-deploy.yml} | 0 .../{dot-travis-macos-matrix.yml => travis-macos-matrix.yml} | 0 inst/templates/{dot-travis-macos.yml => travis-macos.yml} | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename inst/templates/{dot-travis-linux-deploy-matrix.yml => travis-linux-deploy-matrix.yml} (100%) rename inst/templates/{dot-travis-linux-deploy.yml => travis-linux-deploy.yml} (100%) rename inst/templates/{dot-travis-linux-matrix.yml => travis-linux-matrix.yml} (100%) rename inst/templates/{dot-travis-linux.yml => travis-linux.yml} (100%) rename inst/templates/{dot-travis-macos-deploy-matrix.yml => travis-macos-deploy-matrix.yml} (100%) rename inst/templates/{dot-travis-macos-deploy.yml => travis-macos-deploy.yml} (100%) rename inst/templates/{dot-travis-macos-matrix.yml => travis-macos-matrix.yml} (100%) rename inst/templates/{dot-travis-macos.yml => travis-macos.yml} (100%) diff --git a/inst/templates/dot-travis-linux-deploy-matrix.yml b/inst/templates/travis-linux-deploy-matrix.yml similarity index 100% rename from inst/templates/dot-travis-linux-deploy-matrix.yml rename to inst/templates/travis-linux-deploy-matrix.yml diff --git a/inst/templates/dot-travis-linux-deploy.yml b/inst/templates/travis-linux-deploy.yml similarity index 100% rename from inst/templates/dot-travis-linux-deploy.yml rename to inst/templates/travis-linux-deploy.yml diff --git a/inst/templates/dot-travis-linux-matrix.yml b/inst/templates/travis-linux-matrix.yml similarity index 100% rename from inst/templates/dot-travis-linux-matrix.yml rename to inst/templates/travis-linux-matrix.yml diff --git a/inst/templates/dot-travis-linux.yml b/inst/templates/travis-linux.yml similarity index 100% rename from inst/templates/dot-travis-linux.yml rename to inst/templates/travis-linux.yml diff --git a/inst/templates/dot-travis-macos-deploy-matrix.yml b/inst/templates/travis-macos-deploy-matrix.yml similarity index 100% rename from inst/templates/dot-travis-macos-deploy-matrix.yml rename to inst/templates/travis-macos-deploy-matrix.yml diff --git a/inst/templates/dot-travis-macos-deploy.yml b/inst/templates/travis-macos-deploy.yml similarity index 100% rename from inst/templates/dot-travis-macos-deploy.yml rename to inst/templates/travis-macos-deploy.yml diff --git a/inst/templates/dot-travis-macos-matrix.yml b/inst/templates/travis-macos-matrix.yml similarity index 100% rename from inst/templates/dot-travis-macos-matrix.yml rename to inst/templates/travis-macos-matrix.yml diff --git a/inst/templates/dot-travis-macos.yml b/inst/templates/travis-macos.yml similarity index 100% rename from inst/templates/dot-travis-macos.yml rename to inst/templates/travis-macos.yml From 385c884d6e80b4c90c063b9ea85995626b5f9a2e Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 22:09:03 +0100 Subject: [PATCH 16/17] export use-yaml --- NAMESPACE | 3 +++ R/use-yaml.R | 41 +++++++++++++++++++++++++++++++++-------- man/yaml-templates.Rd | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 man/yaml-templates.Rd 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 index 33e41f13..e3778942 100644 --- a/R/use-yaml.R +++ b/R/use-yaml.R @@ -1,20 +1,41 @@ +#' @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 = "dot-travis-linux.yml" + template = "travis-linux.yml" } else if (type == "linux-matrix") { - template = "dot-travis-linux-matrix.yml" + template = "travis-linux-matrix.yml" } else if (type == "linux-deploy") { - template = "dot-travis-linux-deploy.yml" + template = "travis-linux-deploy.yml" } else if (type == "linux-deploy-matrix") { - template = "dot-travis-linux-deploy-matrix.yml" + template = "travis-linux-deploy-matrix.yml" } else if (type == "macos") { - template = "dot-travis-macos.yml" + template = "travis-macos.yml" } else if (type == "macos-matrix") { - template = "dot-travis-macos-matrix.yml" + template = "travis-macos-matrix.yml" } else if (type == "macos-deploy") { - template = "dot-travis-macos-deploy.yml" + template = "travis-macos-deploy.yml" } else if (type == "macos-deploy-matrix") { - template = "dot-travis-macos-deploy-matrix.yml" + template = "travis-macos-deploy-matrix.yml" } use_tic_template( template, @@ -23,6 +44,8 @@ use_travis_yml <- function(type) { ) } +#' @rdname yaml-templates +#' @export use_appveyor_yml <- function(type) { if (type == "windows") { template = "appveyor.yml" @@ -36,6 +59,8 @@ use_appveyor_yml <- function(type) { ) } +#' @rdname yaml-templates +#' @export use_circle_yml <- function(type) { if (type == "linux") { template = "circle.yml" 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. +} + From 57ce7a81ad95192d1772c748a3affc2dba6e81f2 Mon Sep 17 00:00:00 2001 From: pat-s Date: Thu, 31 Oct 2019 22:22:52 +0100 Subject: [PATCH 17/17] quiet dir.create() --- R/use-yaml.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/use-yaml.R b/R/use-yaml.R index e3778942..72ca3c74 100644 --- a/R/use-yaml.R +++ b/R/use-yaml.R @@ -71,7 +71,7 @@ use_circle_yml <- function(type) { } else if (type == "linux-deploy-matrix") { template = "circle-deploy-matrix.yml" } - dir.create(".circleci") + dir.create(".circleci", showWarnings = FALSE) use_tic_template( template, save_as = ".circleci/config.yml",