Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change R linter #188

Merged
merged 11 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ on:
required: false
type: boolean
default: true
lint-all-files:
description: Lint all files every time
default: false
required: false
type: boolean

concurrency:
group: lint-${{ github.event.pull_request.number || github.ref }}
Expand Down Expand Up @@ -75,6 +80,42 @@ jobs:
VALIDATE_DOCKERFILE: true
VALIDATE_MARKDOWN: true
MARKDOWN_CONFIG_FILE: .markdownlint.yaml
VALIDATE_R: true
VALIDATE_YAML: true
LINTR_ERROR_ON_LINT: ${{ inputs.lintr_error_on_lint }}

lint-r-code:
name: Lint R code 🧶
runs-on: ubuntu-latest
if: >
!contains(github.event.commits[0].message, '[skip linter]')
&& github.event.pull_request.draft == false
container:
image: ghcr.io/insightsengineering/rstudio_4.3.1_bioc_3.17:latest
steps:
- name: Checkout repo 🛎
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Changed files 🖋️
id: files
uses: Ana06/[email protected]
with:
format: 'json'
filter: '*'

- name: Lint 🧶
run: |
exclusions_list <- NULL
if (!identical("${{ inputs.lint-all-files }}", "true")) {
changed_files <- jsonlite::fromJSON('${{ steps.files.outputs.added_modified }}')
all_files <- list.files(recursive = TRUE)
exclusions_list <- as.list(setdiff(all_files, changed_files))
}
lints <- lintr::lint_package(exclusions = exclusions_list)
if (length(lints) > 0L) {
print(lints)
if (identical("${{ inputs.lintr_error_on_lint }}", "true")) {
stop("Lints detected. Please review and adjust code according to the comments provided.", call. = FALSE)
}
}
shell: Rscript {0}
Loading