Merge pull request #603 from lorenzwalthert/hook-dependencies-update #1315
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
# NOTE: This workflow is overkill for most R packages | |
# check-standard.yaml is likely a better choice | |
# usethis::use_github_action("check-standard") will install it. | |
# | |
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. | |
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
name: R-CMD-check | |
jobs: | |
R-CMD-check: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.os }} (${{ matrix.config.r }}, ${{ matrix.config.installation_method }}) | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
# macOS | |
- {os: macOS-latest, r: 'release', installation_method: 'brew'} | |
- {os: macOS-latest, r: 'release', installation_method: 'conda'} | |
- {os: macOS-latest, r: 'release', installation_method: 'pip'} | |
# Windows | |
- {os: windows-latest, r: 'release', installation_method: 'pip'} | |
- {os: windows-latest, r: 'release', installation_method: 'conda'} | |
- {os: windows-latest, r: 'devel', installation_method: 'conda'} | |
# Linux | |
- {os: ubuntu-latest, r: 'release', installation_method: 'pip', use-public-rspm: true} | |
- {os: ubuntu-latest, r: 'release', installation_method: 'conda', use-public-rspm: true} | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
PRECOMMIT_INSTALLATION_METHOD: ${{ matrix.config.installation_method }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r }} | |
http-user-agent: ${{ matrix.config.http-user-agent }} | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- name: Install system dependencies (brew) | |
if: matrix.config.installation_method == 'brew' | |
run: brew install pre-commit | |
- name: Install system dependencies (pip, non-macOS) | |
if: matrix.config.installation_method == 'pip' && matrix.config.os != 'macOS-latest' | |
run: | | |
pip3 install pre-commit --user | |
- name: Install system dependencies (pip, macOS) | |
if: matrix.config.installation_method == 'pip' && matrix.config.os == 'macOS-latest' | |
run: | | |
pip3 install pre-commit --user --break-system-packages | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
- name: Remove reticulate for other installation methods | |
run: | | |
# installation methods other than conda don't need reticulate | |
if (Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != 'conda') { | |
remove.packages('reticulate') | |
} | |
shell: Rscript {0} | |
- name: Install system dependencies (conda) | |
if: matrix.config.installation_method == 'conda' | |
run: | | |
reticulate::install_miniconda() | |
shell: Rscript {0} | |
- name: Session info | |
run: | | |
options(width = 100) | |
pkgs <- installed.packages()[, "Package"] | |
sessioninfo::session_info(pkgs, include_base = TRUE) | |
shell: Rscript {0} | |
- name: Check | |
env: | |
_R_CHECK_CRAN_INCOMING_: false | |
run: | | |
options(crayon.enabled = TRUE) | |
if (Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != 'conda') { | |
Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "False") | |
} | |
remotes::install_local() # circumvent https://github.com/r-lib/rcmdcheck/issues/136 | |
install.packages("rcmdcheck") | |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") | |
shell: Rscript {0} | |
- name: Show testthat output | |
if: always() | |
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true | |
shell: bash | |
- name: Upload check results | |
if: failure() | |
uses: actions/upload-artifact@main | |
with: | |
name: ${{ runner.os }}-r${{ matrix.config.r }}-results | |
path: check | |
- name: Don't use tar from old Rtools to store the cache | |
if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }} | |
shell: bash | |
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH |