@@ -3,69 +3,29 @@ name: "Action to auto-style a package"
3
3
runs :
4
4
using : " composite"
5
5
steps :
6
- - name : Check styler options
6
+ - name : Check air.toml
7
7
id : check
8
8
run : |
9
9
set -x
10
- scope=$( ( grep Config/autostyle/scope DESCRIPTION || true ) | cut -d " " -f 2)
11
- strict=$( ( grep Config/autostyle/strict DESCRIPTION || true ) | cut -d " " -f 2)
12
- rmd=$( ( grep Config/autostyle/rmd DESCRIPTION || true ) | cut -d " " -f 2)
13
- echo scope=$scope >> $GITHUB_OUTPUT
14
- echo strict=$strict >> $GITHUB_OUTPUT
15
- echo rmd=$rmd >> $GITHUB_OUTPUT
10
+ if [ -f air.toml ]; then
11
+ echo enabled=true >> $GITHUB_OUTPUT
12
+ else
13
+ echo enabled=false >> $GITHUB_OUTPUT
14
+ fi
16
15
shell : bash
17
16
18
- - uses : actions/cache@v4
19
- if : ${{ steps.check.outputs.scope }}
20
- with :
21
- path : |
22
- ~/.cache/R/R.cache
23
- key : ${{ runner.os }}-2-${{ github.run_id }}-
24
- restore-keys : |
25
- ${{ runner.os }}-2-
17
+ - name : Install air
18
+ if : ${{ steps.check.outputs.enabled == 'true' }}
19
+ uses : posit-dev/setup-air@v1
26
20
27
- - name : Imprint run ID
28
- if : ${{ steps.check.outputs.scope }}
21
+ - name : Run air
22
+ if : ${{ steps.check.outputs.enabled == 'true' }}
29
23
run : |
30
- mkdir -p ~/.cache/R/R.cache/styler
31
- touch ~/.cache/R/R.cache/${{ github.run_id }}
24
+ air format .
32
25
shell : bash
33
26
34
- - name : Show cache
35
- if : ${{ steps.check.outputs.scope }}
27
+ - name : Check Git status
28
+ if : ${{ steps.check.outputs.enabled == 'true' }}
36
29
run : |
37
- ls -l ~/.cache/R/R.cache
38
- ls -l ~/.cache/R/R.cache/styler
39
- shell : bash
40
-
41
- - name : Enable styler cache
42
- if : ${{ steps.check.outputs.scope }}
43
- run : |
44
- styler::cache_activate(verbose = TRUE)
45
- shell : Rscript {0}
46
-
47
- - name : Run styler
48
- if : ${{ steps.check.outputs.scope }}
49
- run : |
50
- strict <- as.logical("${{ steps.check.outputs.strict }}")
51
- if (is.na(strict)) {
52
- strict <- FALSE
53
- }
54
- rmd <- as.logical("${{ steps.check.outputs.rmd }}")
55
- if (is.na(rmd)) {
56
- rmd <- TRUE
57
- }
58
- styler::style_pkg(
59
- scope = "${{ steps.check.outputs.scope }}",
60
- strict = strict,
61
- filetype = c("R", "Rprofile", if (rmd) c("Rmd", "Rmarkdown", "Rnw", "Qmd"))
62
- )
63
- shell : Rscript {0}
64
-
65
- - name : Show cache again
66
- if : ${{ steps.check.outputs.scope }}
67
- run : |
68
- ls -l ~/.cache/R/R.cache
69
- ls -l ~/.cache/R/R.cache/styler
70
- gdu -s --inodes ~/.cache/R/R.cache/styler/* || du -s --inodes ~/.cache/R/R.cache/styler/*
30
+ git status
71
31
shell : bash
0 commit comments