--- title: "Getting started with CI for R" author: "Patrick Schratz, Kirill Müller" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting started with CI for R} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library("tic") ``` # Prerequisites Continuous Integration (CI) is a huge field in software development. There are a lot of resources out there that try to explain what it can do and why you need it (and usually why their particular company/service does it best). If you are just getting started with software development or `git` based project work you might think: > "Ah I don't need all of this overhead, I am fine doing X and Y manually for this project. > The overhead learning this next additional "tool" is not worth it. Reading [all vignettes of this package](https://docs.ropensci.org/tic/articles/) will help you understand what {tic} does to simplify all of that specifically for the R language. However, there is a lot of advanced information in these vignettes which might be a bit overwhelming at first if you are just getting started. Therefore we will explain a few of the most important terms first to give you a kickstart:
Runner One build job (possibly among many others) on any operating system that executes certain commands specified in the YAML config file.
YAML config file A file written in the YAML language telling the runner what to do after a push to the repository.
Build matrix Specification how many runners are started and their specification (operating system, custom environment variables, etc.)
CI Provider A company that offers ready-to-use virtual images for runners which are started after a certain action (.e.g Circle CI). However, code hosting sites like GitHub or GitLab also have their own CI integration meanwhile.
Deployment CI builds cannot just perform specific checks on a package/project, they can also be used to (re-)build certain files in every run. With the appropriate permissions these files can then be pushed to a repository via `git` without the need to take manual actions by the user. This can save a lot of time and is commonly used to ensure that documentation is always up-to-date.
CI Client packages R packages that interface the command line API of CI providers to simplify the execution of certain tasks (scraping build logs, enabling repos, etc.), e.g. [{circle}](https://github.com/ropenscilabs/circle).
CI Badges Badges in the README of a repository showing the current build status of the project: Did the last build fail or finish successfully?
DSL "DSL" stands for "[domain-specific language](https://en.wikipedia.org/wiki/Domain-specific_language)" and essentially means the implementation of a general concept for a specific programming language.
# Initialization/Setup The easiest way to use {tic} for CI services is to call `tic::use_tic()`. This will initialize a setup wizard which will guide you through all possibilities of the offered CI providers by {tic}. 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 Last, we'll add a `tic.R` file to the project root. After this, your project is ready for continuous integration. The next push to GitHub will create a build on Circle CI. See the [Troubleshooting](advanced.html#troubleshooting) section in case anything doesn't work as expected. #### Quickstart If you are a new user, run ```r tic::use_tic() ``` If you already use {tic} and want to configure a new CI provider, do ```r ## Circle CI circle::use_circle_deploy() # (optional for deployment) tic::use_circle_yml(