Skip to content

Commit

Permalink
styler
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias committed Dec 15, 2023
1 parent d529daf commit 242d88b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
13 changes: 13 additions & 0 deletions .github/styler.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
library("argparse")
library("styler")

parser <- ArgumentParser(description = "Call styler")
parser$add_argument("dir",
metavar = "DIR", type = "character",
help = "File to parse"
)
parser$add_argument("--dry",
choices = c("off", "on", "fail"), default = "on"
)
args <- parser$parse_args()
result <- style_dir(args$dir, dry = args$dry)
36 changes: 8 additions & 28 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,38 +202,18 @@ jobs:
with:
path: ${{ env.R_LIBS_USER }}
key: r_cache_${{ matrix.os }}_${{ matrix.r-version }}
- name: Install non-R lintr dependencies
run: sudo apt-get install libcurl4-openssl-dev
- name: Install lintr
run: |
install.packages('remotes')
remotes::install_cran("lintr")
shell: Rscript {0}
- name: Install packages
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
any::argparse
any::styler
- name: Save repositories to file
run: echo '${{ needs.setup.outputs.repository-list }}' > repository_list.txt
- name: lintr
run: |
library(lintr)
linters <- linters_with_defaults(line_length_linter = NULL, cyclocomp_linter = NULL, object_usage_linter = NULL, object_name_linter = NULL)
con <- file("repository_list.txt", "r")
status <- 0
while (TRUE) {
repo <- readLines(con, n = 1)
if (length(repo) == 0) {
break
}
lnt <- lint_dir(repo, relative_path=T, linters=linters)
if (length(lnt) > 0) {
status <- 1
for (l in lnt) {
rel_path <- paste(repo, l$filename, sep="/")
write(paste(paste(rel_path, l$line_number, l$column_number, sep=":"), l$message, paste("(", l$line, ")")), stderr())
write(paste(paste(rel_path, l$line_number, l$column_number, sep=":"), l$message, paste("(", l$line, ")")), "rlint_report.txt", append=TRUE)
}
}
}
quit(status = status)
shell: Rscript {0}
echo '${{ needs.setup.outputs.repository-list }}' | xargs -d '\n' .github/styler.R --dry off
git diff --exit-code | tee rlint_report.txt
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
Expand Down

0 comments on commit 242d88b

Please sign in to comment.