|
| 1 | +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples |
| 2 | +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help |
| 3 | + |
| 4 | +# Name of the workflow |
| 5 | +name: CI-renv |
| 6 | +# Create status badge with usethis::use_github_actions_badge("ci-renv.yml") |
| 7 | + |
| 8 | +on: |
| 9 | + # Triggered on push and pull request events |
| 10 | + push: |
| 11 | + pull_request: |
| 12 | + # Allow manual runs from the Actions tab |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + CI-CD: |
| 17 | + runs-on: ${{ matrix.config.os }} |
| 18 | + |
| 19 | + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) |
| 20 | + |
| 21 | + strategy: |
| 22 | + # We keep a matrix for convenience, but we would typically just run on one |
| 23 | + # single OS and R version, aligned with the target deployment environment |
| 24 | + matrix: |
| 25 | + config: |
| 26 | + - {os: ubuntu-latest, r: 'renv'} |
| 27 | + |
| 28 | + env: |
| 29 | + # Access token for GitHub |
| 30 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + # Preserve package sources for informative references in case of errors |
| 32 | + R_KEEP_PKG_SOURCE: yes |
| 33 | + |
| 34 | + steps: |
| 35 | + |
| 36 | + - name: Checkout repo |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Setup R |
| 40 | + uses: r-lib/actions/setup-r@v2 |
| 41 | + with: |
| 42 | + r-version: ${{ matrix.config.r }} |
| 43 | + # No RStudio Package Manager to respect renv.lock |
| 44 | + use-public-rspm: false |
| 45 | + |
| 46 | + - name: Install system dependencies |
| 47 | + # This is not taken care of (yet) by r-lib/actions/setup-renv |
| 48 | + # See https://github.com/r-lib/actions/issues/785 |
| 49 | + run: | |
| 50 | + # We rely on pkgdepends from the library embedded in pak |
| 51 | + install.packages("pak", repos = "https://r-lib.github.io/p/pak/stable/") |
| 52 | + install.packages("jsonlite") |
| 53 | + .libPaths(c(system.file("library", package = "pak"), .libPaths())) |
| 54 | + pkgdepends::new_pkg_installation_proposal( |
| 55 | + names(jsonlite::read_json("renv.lock")$Packages), config = list(dependencies = FALSE) |
| 56 | + )$solve()$install_sysreqs() |
| 57 | + shell: Rscript {0} |
| 58 | + |
| 59 | + - name: Activate renv and restore packages with cache |
| 60 | + uses: r-lib/actions/setup-renv@v2 |
| 61 | + |
| 62 | + - name: Install R CMD check |
| 63 | + run: install.packages("rcmdcheck") |
| 64 | + shell: Rscript {0} |
| 65 | + |
| 66 | + - name: Check package |
| 67 | + uses: r-lib/actions/check-r-package@v2 |
0 commit comments