-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
144 lines (108 loc) · 5.19 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# inteRgrate: Very opinated package development
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![CRAN](http://www.r-pkg.org/badges/version/inteRgrate)](https://cran.r-project.org/package=inteRgrate)
<!-- [![codecov.io](https://codecov.io/github/csgillespie/poweRlaw/coverage.svg?branch=master)](https://codecov.io/github/csgillespie/poweRlaw?branch=master) -->
<!-- [![Downloads](http://cranlogs.r-pkg.org/badges/poweRlaw?color=brightgreen)](https://cran.r-project.org/package=poweRlaw) -->
[![Codecov test coverage](https://codecov.io/gh/jumpingrivers/inteRgrate/branch/master/graph/badge.svg)](https://codecov.io/gh/jumpingrivers/inteRgrate?branch=master)
[![R-CMD-check](https://github.com/jumpingrivers/inteRgrate/workflows/R-CMD-check/badge.svg)](https://github.com/jumpingrivers/inteRgrate/actions)
<!-- badges: end -->
The goal of inteRgrate is to provide an very opinionated set of rules for R package development.
The idea is that when many people contribute to a package, it's easy for standards to diverge. We
think that CI can help here.
This package has the same functions for both travis and Gitlab-CI environments.
Currently, the package is used by [Jumping Rivers](https://www.jumpingrivers.com) on GitHub and
GitLab.
The rationale behind this package is
* While checking R packages on travis is easy, support for GitLab (and others) is lacking.
* When developing a package, sometimes we want to specify the exact number of NOTES
and WARNINGS we expect/allow.
* Having a consistent system for different CI is desirable.
* For our CI steps, we have a few other checks that we tend to implement, e.g. lints, not
using imports within namespaces.
This package is still being developed, but we are now actively using it, so hopefully we can
avoid breaking changes.
## Installation
As the package is currently being developed, it isn't yet on CRAN.
The development version can be installed from [GitHub](https://github.com/) with:
```{r, eval = FALSE}
install.packages("remotes")
remotes::install_github("jumpingrivers/inteRgrate")
```
## Functions
The package is meant to be used within a continuous integration framework, e.g. travis, GitLab
runner. This package contains a number functions that are useful for CI:
* `check_pkg()` - installs package dependencies, builds & installs the package, before
running package check. By default, __any__ notes or warnings will raise an error message.
This can be changed by setting the environment variables `ALLOWED_NOTES` and
`ALLOWED_WARNINGS`.
* `check_lintr()` - runs lintr on the package, README.Rmd and vignettes.
* `check_namespace()` - check for instances of `import()` in the NAMESPACE file. By default,
no imports are allowed. This can be changed via the environment variable `NO_IMPORTS`
* `check_r_filenames()` - ensures file extensions are `.R` and all names are lower case.
* `check_version()` - ensures that the package description has been updated.
* `check_gitignore()` - .gitignore contains standard files.
* `check_readme()` - checks README.Rmd timestamps
* `check_tidy_description()` - ensure that the DESCRIPTION file is tidy,
via `usethis::use_tidy_description()`
* `check_file_permissions()`, `check_line_breaks()` - ensures that linux line breaks are used and file permissions are
sensible.
* `create_tag()` - autotag via the CI.
See the help pages for customisation.
There's also a pre-commit hook to help. Run `inteRgrate::add_pre_commit()` in root git directory
of your repo and checks will be run before committing.
### Example .travis.yml file
Within a CI file, it's often better to use `check_via_env()` that will automatically call all checks.
Specific checks can be switch on/off via environment variables.
```
language: r
cache: packages
env:
global:
- ALLOWED_WARNINGS=0
- ALLOWED_NOTES=0
- NO_IMPORTS=0
script:
- Rscript -e "inteRgrate::check_via_env(default = 'true')"
```
### Example .gitlab.yml file
```
image: rocker/r-ubuntu:18.04
variables:
ALLOWED_WARNINGS: 0
ALLOWED_NOTES: 0
NO_IMPORTS: 0
before_script:
- Rscript -e "install.packages('remotes')"
- Rscript -e "remotes::install_github('jumpingrivers/inteRgrate')"
check:
script:
- Rscript -e "inteRgrate::check_via_env(default = 'true')"
```
### Command line
You can also use it at the command line
```{r, eval = FALSE}
library("inteRgrate")
check_pkg()
check_r_filenames()
```
Other information
-----------------
* ROpensci are developing a related package - [tic](https://github.com/ropenscilabs/tic).
The [tic](https://github.com/ropenscilabs/tic) package aims to specify the CI environment purely by an R script.
* If you have any suggestions or find bugs, please use the github [issue tracker](https://github.com/jumpingrivers/inteRgrate/issues)
* Feel free to submit pull requests
---
Development of this package was supported by [Jumping Rivers](https://www.jumpingrivers.com)