Skip to content

Commit ece965c

Browse files
authored
Merge pull request #802 from dragosmg/readme-ci-project
added a paragraph on how to use lintr with for project (with the new GHA p…
2 parents 0c91d45 + 15c6b8a commit ece965c

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,11 @@ The resulting configuration will contain each currently failing linter and the c
177177
If you are developing a package, you can add `^\.lintr$` to your `.Rbuildignore` file using `usethis::use_build_ignore(".lintr")`.
178178

179179
## Continuous integration ##
180-
You can configure `lintr` to run as part of continuous integration in order to automatically check that commits and pull requests do not deteriorate code style.
180+
You can configure `lintr` to run as part of continuous integration (either for a package or a general project containing R files) in order to automatically check that commits and pull requests do not deteriorate code style.
181181

182-
### GitHub Actions ###
182+
### For packages
183+
184+
#### GitHub Actions ###
183185

184186
If your package is on GitHub, the easiest way to do this is with GitHub Actions.
185187
The workflow configuration files use YAML syntax. The `usethis` package has some
@@ -198,7 +200,7 @@ location, namely in the `.github/workflows` directory of your repository. This f
198200
pull request with the lints found and they will also be printed as [annotations](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/about-status-checks#types-of-status-checks-on-github) along side the status check on GitHub. If you want to disable the commenting you can
199201
set the environment variable `LINTR_COMMENT_BOT=false`.
200202

201-
### Travis CI ###
203+
#### Travis CI ###
202204

203205
If you want to run `lintr` on [Travis-CI](https://travis-ci.org), you will need
204206
to have Travis install the package first. This can be done by adding the
@@ -216,7 +218,7 @@ add comments to the commit or pull request with the lints found and they will al
216218
printed on Travis-CI. If you want to disable the commenting you can
217219
set the environment variable `LINTR_COMMENT_BOT=false`.
218220

219-
#### Non-failing Lints ####
221+
##### Non-failing Lints ####
220222
```yaml
221223
after_success:
222224
- R CMD INSTALL $PKG_TARBALL
@@ -225,6 +227,19 @@ after_success:
225227

226228
Live example of a package using this setup: [`hibpwned`](https://github.com/lockedata/HIBPwned/blob/master/.travis.yml), [lintr-bot commenting on a PR](https://github.com/lockedata/HIBPwned/pull/30).
227229

230+
### For projects ###
231+
232+
You are not limited you using `lintr` for packages only, you can use it in combination with continuous integration for any other project.
233+
234+
#### GitHub Actions ####
235+
236+
If your project is on GitHub, you could take advantage of GitHub Actions and the `usethis` functionality. [r-lib/actions](https://github.com/r-lib/actions/tree/master/examples) includes a `lint-project` example, which you can use by calling:
237+
238+
```r
239+
usethis::use_github_action("lint-project")
240+
```
241+
242+
228243
## Installation of development version ##
229244
To install the latest development version of lintr from GitHub
230245

0 commit comments

Comments
 (0)