-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (48 loc) · 1.58 KB
/
tidyCode.yaml
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
on:
push:
branches:
- main
pull_request:
name: tidy-code
jobs:
automatedTests:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Install git2r dependencies
run: sudo apt-get install -y libgit2-dev
- name: Cache renv packages
id: cache-renv
uses: actions/cache@v4
with:
path: cache-renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- uses: r-lib/actions/setup-renv@v2
- name: Tidy code
shell: Rscript {0}
run: |
codeChecks <- dfeshiny::tidy_code()
if(any(is.na(codeChecks))) {
stop("There is a breaking error in the code.")
} else {
if(TRUE %in% codeChecks) {
stop("The code is not styled correctly. Open the project in RStudio and use tidy_code() to restyle the code.")
} else {
message("----------------------------------------")
message("The code is beautiful, go you!")
message("----------------------------------------")
}
}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-tests
path: tests