Skip to content

Commit

Permalink
wf from tech guides
Browse files Browse the repository at this point in the history
  • Loading branch information
GuidoMaggio committed Aug 23, 2023
1 parent 44c2afc commit 0dcb454
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,56 @@ on:
push:
pull_request:
schedule:
# Allow manual runs from the Actions tab
workflow_dispatch:
# every day at 21 UTC
- cron: "0 21 * * *"

name: CI-CD

# renv with GitHub actions: https://rstudio.github.io/renv/articles/ci.html#github-actions


jobs:
CI-CD:
runs-on: ubuntu-latest
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
# We keep a matrix for convenience, but we would typically just run on one
# single OS and R version, aligned with the target deployment environment
matrix:
config:
- {os: ubuntu-latest, r: '4.2.1'}

env:
RENV_PATHS_ROOT: ~/.local/share/renv
# Access token for GitHub
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
# Preserve package sources for informative references in case of errors
R_KEEP_PKG_SOURCE: yes

steps:

- name: Checkout repo
uses: actions/checkout@v3

- name: Setup version-stable R 4.2.1
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: 4.2.1

- name: Cache packages
uses: actions/cache@v3
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
r-version: ${{ matrix.config.r }}
# Enable RStudio Package Manager to speed up package installation
use-public-rspm: true

- name: Install system dependencies
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
# This is not taken care of (yet) by r-lib/actions/setup-renv
# Package distro used to get the distro for the used ubuntu-latest
run: |
Rscript -e "renv::install('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
Rscript -e "install.packages(c('remotes', 'distro'))"
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(with(distro::distro(), remotes::system_requirements(id, short_version)))')
- name: Activate renv and restore packages with cache
uses: r-lib/actions/setup-renv@v2
Expand Down

0 comments on commit 0dcb454

Please sign in to comment.