Add debugging to GitHub actions #34
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
# 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, master] | |
pull_request: | |
branches: [main, master] | |
workflow_dispatch: | |
inputs: | |
ssh_debug: | |
description: Launch shell for interactive debugging? | |
type: boolean | |
required: true | |
default: false | |
name: R-CMD-check | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
R-CMD-check-base: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
R_KEEP_PKG_SOURCE: yes | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Do a pre-emptive apt-update | |
run: sudo apt-get update -qq | |
if: ${{ !env.ACT }} | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: release | |
use-public-rspm: true | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
extra-packages: any::sessioninfo, any::rcmdcheck, any::pkgdepends, any::covr | |
needs: check | |
cache: ${{ !env.ACT }} | |
- name: Run just package tests and record test coverage | |
run: | | |
cat("LOGNAME=", Sys.info()[["user"]], "\n", sep = "", file = Sys.getenv("GITHUB_ENV"), append = TRUE) | |
cat("check-dir-path=", file.path(getwd(), ("check")), "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE) | |
coverage <- covr::package_coverage(code = "saveRDS(testthat::test_package('relic', reporter = 'Summary'), file.path('check', 'coverage.rds'))", install_path = "check") | |
saveRDS(coverage, file.path("check", "coverage.rds")) | |
shell: Rscript {0} | |
- name: Run R-CMD-check without tests | |
run: | | |
options(crayon.enabled = TRUE) | |
cat("LOGNAME=", Sys.info()[["user"]], "\n", sep = "", file = Sys.getenv("GITHUB_ENV"), append = TRUE) | |
if (Sys.getenv("_R_CHECK_FORCE_SUGGESTS_", "") == "") Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "false") | |
if (Sys.getenv("_R_CHECK_CRAN_INCOMING_", "") == "") Sys.setenv("_R_CHECK_CRAN_INCOMING_" = "false") | |
cat("check-dir-path=", file.path(getwd(), ("check")), "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE) | |
rcmdcheck::rcmdcheck(args = c("--no-tests", "--no-manual"), error_on = "warning", check_dir = ("check")) | |
shell: Rscript {0} | |
- name: Print and upload coverage | |
run: | | |
library(covr) | |
coverage <- readRDS(file.path("check", "coverage.rds")) | |
coverage | |
covr::codecov(coverage = coverage) | |
shell: Rscript {0} | |
continue-on-error: true | |
- name: Additional diagnostics | |
run: | | |
pkc <- pkgcheck::pkgcheck(goodpractice = FALSE) | |
gp <- goodpractice::goodpractice(checks = goodpractice::all_checks()[grep("(rcmdcheck|covr)", goodpractice::all_checks(), invert = TRUE)]) | |
pkc | |
gp | |
shell: Rscript {0} | |
continue-on-error: true | |
- name: Launch a temporary interactive debugging session | |
uses: mxschmitt/action-tmate@v3.16 | |
if: always() && inputs.ssh_debug | |
with: | |
detached: true | |
# - uses: r-lib/actions/check-r-package@v2 | |
# with: | |
# upload-snapshots: true | |
R-CMD-check-grid: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | |
needs: R-CMD-check-base | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {os: macos-latest, r: 'release'} | |
- {os: windows-latest, r: 'release'} | |
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} | |
#- {os: ubuntu-latest, r: 'release'} | |
- {os: ubuntu-latest, r: 'oldrel-1'} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
R_KEEP_PKG_SOURCE: yes | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Do a pre-emptive apt-update | |
run: sudo apt-get update -qq | |
if: ${{ !env.ACT }} | |
- 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::sessioninfo, any::rcmdcheck, any::pkgdepends | |
needs: check | |
cache: ${{ !env.ACT }} | |
- uses: r-lib/actions/check-r-package@v2 | |
with: | |
upload-snapshots: true | |
- name: Launch a temporary interactive debugging session | |
uses: mxschmitt/action-tmate@v3.16 | |
if: always() && inputs.ssh_debug | |
with: | |
detached: true |