-
Notifications
You must be signed in to change notification settings - Fork 79
/
action.yml
71 lines (64 loc) · 2.11 KB
/
action.yml
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
name: "Action to auto-style a package"
runs:
using: "composite"
steps:
- name: Check styler options
id: check
run: |
set -x
scope=$( ( grep Config/autostyle/scope DESCRIPTION || true ) | cut -d " " -f 2)
strict=$( ( grep Config/autostyle/strict DESCRIPTION || true ) | cut -d " " -f 2)
rmd=$( ( grep Config/autostyle/rmd DESCRIPTION || true ) | cut -d " " -f 2)
echo scope=$scope >> $GITHUB_OUTPUT
echo strict=$strict >> $GITHUB_OUTPUT
echo rmd=$rmd >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v3
if: ${{ steps.check.outputs.scope }}
with:
path: |
~/.cache/R/R.cache
key: ${{ runner.os }}-2-${{ github.run_id }}-
restore-keys: |
${{ runner.os }}-2-
- name: Imprint run ID
if: ${{ steps.check.outputs.scope }}
run: |
mkdir -p ~/.cache/R/R.cache/styler
touch ~/.cache/R/R.cache/${{ github.run_id }}
shell: bash
- name: Show cache
if: ${{ steps.check.outputs.scope }}
run: |
ls -l ~/.cache/R/R.cache
ls -l ~/.cache/R/R.cache/styler
shell: bash
- name: Enable styler cache
if: ${{ steps.check.outputs.scope }}
run: |
styler::cache_activate(verbose = TRUE)
shell: Rscript {0}
- name: Run styler
if: ${{ steps.check.outputs.scope }}
run: |
strict <- as.logical("${{ steps.check.outputs.strict }}")
if (is.na(strict)) {
strict <- FALSE
}
rmd <- as.logical("${{ steps.check.outputs.rmd }}")
if (is.na(rmd)) {
rmd <- TRUE
}
styler::style_pkg(
scope = "${{ steps.check.outputs.scope }}",
strict = strict,
filetype = c("R", "Rprofile", if (rmd) c("Rmd", "Rmarkdown", "Rnw", "Qmd"))
)
shell: Rscript {0}
- name: Show cache again
if: ${{ steps.check.outputs.scope }}
run: |
ls -l ~/.cache/R/R.cache
ls -l ~/.cache/R/R.cache/styler
gdu -s --inodes ~/.cache/R/R.cache/styler/* || du -s --inodes ~/.cache/R/R.cache/styler/*
shell: bash