Skip to content

Improve dark mode

Improve dark mode #182

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# lintr provides static code analysis for R.
# It checks for adherence to a given style,
# identifying syntax errors and possible semantic issues,
# then reports them to you so you can take action.
# More details at https://lintr.r-lib.org/
name: lintr
on:
push:
branches:
- main
- master
workflow_dispatch:
workflow_run:
workflows: [update-docs]
types: completed
branches: [main, master]
pull_request:
# The branches below must be a subset of the branches above
branches:
- main
- master
schedule:
- cron: "30 09 * * 5"
permissions:
contents: read
# This will cancel running jobs once a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
lintr:
name: Run lintr scanning
runs-on: ubuntu-latest
if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
security-events: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Setup lintr
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
local::.
any::lintr
any::jsonlite
- name: Run lintr
run: |
# Lintr package
out <- lintr::lint_package()
# Create SARIF report
lintr::sarif_output(out, "lintr-results.sarif")
# Display
out
shell: Rscript {0}
continue-on-error: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: lintr-results.sarif
wait-for-processing: true
- name: Install jarl
uses: etiennebacher/setup-jarl@v0.1.1
continue-on-error: true
with:
args: "--version"
- name: Run jarl
run: |
jarl check . --output-format json > jarl-results.json
continue-on-error: true
- name: Convert jarl results to SARIF
run: |
library(jsonlite)
`%||%` <- function(x, y) {
if (is.null(x) || length(x) == 0) y else x
}
as_sarif_uri <- function(path) {
path <- gsub("\\\\", "/", path)
path <- sub("^\\./", "", path)
path
}
as_file_uri <- function(path) {
path <- normalizePath(path, winslash = "/", mustWork = FALSE)
if (.Platform$OS.type == "windows") {
paste0("file:///", path, "/")
} else {
paste0("file://", path, "/")
}
}
jarl <- fromJSON("jarl-results.json", simplifyVector = FALSE)
diagnostics <- jarl$diagnostics %||% list()
rule_ids <- unique(vapply(
diagnostics,
function(x) x$message$name %||% "jarl",
character(1)
))
rules <- lapply(rule_ids, function(id) {
diagnostic <- diagnostics[[match(
id,
vapply(
diagnostics,
function(x) x$message$name %||% "jarl",
character(1)
)
)]]
list(
id = id,
fullDescription = list(
text = diagnostic$message$body %||% id
),
help = list(
text = diagnostic$message$suggestion %||% ""
),
defaultConfiguration = list(
level = "warning"
)
)
})
rule_index <- setNames(seq_along(rule_ids) - 1L, rule_ids)
results <- lapply(diagnostics, function(x) {
id <- x$message$name %||% "jarl"
msg <- paste(
c(
x$message$body %||% id,
if (!is.null(x$message$suggestion)) {
paste("Suggestion:", x$message$suggestion)
}
),
collapse = "\n"
)
list(
ruleId = id,
ruleIndex = unname(rule_index[[id]]),
message = list(text = msg),
locations = list(
list(
physicalLocation = list(
artifactLocation = list(
uri = as_sarif_uri(x$filename %||% ""),
uriBaseId = "ROOTPATH"
),
region = list(
startLine = max(1L, x$location$row %||% 1L),
startColumn = max(1L, x$location$column %||% 1L)
)
)
)
)
)
})
sarif <- list(
`$schema` = "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json",
version = "2.1.0",
runs = list(
list(
tool = list(
driver = list(
name = "jarl",
informationUri = "https://jarl.etiennebacher.com/",
rules = rules
)
),
columnKind = "utf16CodeUnits",
originalUriBaseIds = list(
ROOTPATH = list(
uri = as_file_uri(getwd())
)
),
results = results
)
)
)
write_json(
sarif,
"jarl-results.sarif",
auto_unbox = TRUE,
pretty = TRUE
)
shell: Rscript {0}
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: jarl-results.sarif
wait-for-processing: true