-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, devel] | ||
pull_request: | ||
branches: [main, devel, devtools_check] | ||
|
||
name: R-CMD-check | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ${{ matrix.config.os }} | ||
|
||
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {os: windows-latest, r: 'release'} | ||
- {os: ubuntu-latest, r: 'release'} | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
r-version: ${{ matrix.config.r }} | ||
http-user-agent: ${{ matrix.config.http-user-agent }} | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- uses: r-lib/actions/check-r-package@v2 | ||
with: | ||
upload-snapshots: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
pull_request: | ||
branches: [main, devel, devtools_check] | ||
|
||
name: lint-changed-files | ||
|
||
jobs: | ||
lint-changed-files: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: | | ||
any::gh | ||
r-lib/lintr | ||
any::purrr | ||
needs: check | ||
|
||
- name: Install package | ||
run: R CMD INSTALL . | ||
|
||
- name: Extract and lint files changed by this PR | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
library(lintr) | ||
files <- gh::gh("GET https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files") | ||
changed_files <- purrr::map_chr(files, "filename") | ||
all_files <- list.files(recursive = TRUE) | ||
exclusions_list <- as.list(setdiff(all_files, changed_files)) | ||
lint_package(linters = linters_with_defaults( | ||
line_length_linter(100), | ||
object_length_linter(50L), | ||
cyclocomp_linter(75L), | ||
indentation_linter = NULL, | ||
object_usage_linter = NULL, | ||
object_name_linter = NULL | ||
), exclusions = exclusions_list) | ||
shell: Rscript {0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,47 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [devel] | ||
pull_request: | ||
branches: [devel, devtools_check] | ||
|
||
name: lint | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
pak-version: devel | ||
extra-packages: | | ||
r-lib/lintr | ||
local::. | ||
needs: lint | ||
|
||
# TODO: Revisit to remove some of these allowances after more important lints | ||
# have been removed. | ||
- name: Lint | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
library(lintr) | ||
lint_package(linters = linters_with_defaults( | ||
line_length_linter(100), | ||
object_length_linter(50L), | ||
cyclocomp_linter(75L), | ||
indentation_linter = NULL, | ||
object_usage_linter = NULL, | ||
object_name_linter = NULL | ||
)) | ||
shell: Rscript {0} | ||
env: | ||
LINTR_ERROR_ON_LINT: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
pull_request: | ||
branches: [main, devel, devtools_check] | ||
|
||
name: Style | ||
|
||
jobs: | ||
style: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
pak-version: devel | ||
dependencies: '"hard"' | ||
extra-packages: | | ||
local::. | ||
r-lib/pkgapi | ||
r-lib/styler | ||
r-lib/roxygen2 | ||
needs: | | ||
styler | ||
roxygen2 | ||
- name: Enable styler cache | ||
run: | | ||
styler::cache_activate() | ||
shell: Rscript {0} | ||
|
||
- name: Determine cache location | ||
id: styler-location | ||
run: | | ||
cat( | ||
"location=", | ||
styler::cache_info(format = "tabular")$location, | ||
"\n", | ||
file = Sys.getenv("GITHUB_OUTPUT"), | ||
append = TRUE, | ||
sep = "" | ||
) | ||
shell: Rscript {0} | ||
|
||
- name: Cache styler | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.styler-location.outputs.location }} | ||
key: ${{ runner.os }}-styler-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-styler- | ||
${{ runner.os }}- | ||
- name: Style package | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
styler::style_pkg() | ||
shell: Rscript {0} | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, devel] | ||
pull_request: | ||
branches: [devel, main, devtools_check] | ||
|
||
name: test-coverage | ||
|
||
jobs: | ||
test-coverage: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: | | ||
any::covr | ||
local::. | ||
- name: Test package coverage | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
library(covr) | ||
coverage <- covr::package_coverage( | ||
quiet = FALSE, | ||
line_exclusions = list("R/app_server.R", "R/app_ui.R", "R/app_config.R", "R/run_app.R") | ||
) | ||
print(coverage) | ||
percent_coverage <- covr::percent_coverage(coverage) | ||
threshold <- 50 | ||
cli::cli_rule() | ||
if (percent_coverage < threshold) { | ||
cli::cli_abort("Code coverage is below the required threshold ({threshold}%).") | ||
} else { | ||
cli::cli_alert_success("Code coverage is above the required threshold ({threshold}%).") | ||
} | ||
cli::cli_rule() | ||
shell: Rscript {0} |