Skip to content

Commit

Permalink
custom R dependency loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Sparre Spiegelhauer (HSPU) committed Apr 16, 2024
1 parent 58afca7 commit 355b14e
Showing 1 changed file with 70 additions and 41 deletions.
111 changes: 70 additions & 41 deletions .github/workflows/R-CMD-check-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,57 +35,86 @@
r-version: ${{ matrix.config.r }}
use-public-rspm: false

- name: Install pak (Windows + CRAN snapshot)
if: runner.os == 'Windows' && matrix.config.date != 'latest'
- name: Determine the CRAN image to use
id: cran-image
run: |
# Install pak
cat("::group::Install pak\n")
#lib <- Sys.getenv("R_LIB_FOR_PAK")
#dir.create(lib, showWarnings = FALSE, recursive = TRUE)
install.packages("pak", repos = sprintf(
"https://r-lib.github.io/p/pak/%s/%s/%s/%s",
"stable",
.Platform$pkgType,
R.Version()$os,
R.Version()$arch
))
cat("::endgroup::\n")
shell: Rscript {0}

- name: Install pak (Unix + CRAN snapshot)
if: runner.os != 'Windows' && matrix.config.date != 'latest'
if ("${{ matrix.config.date }}" == "latest") {
echo "::set-output name=image::https://packagemanager.posit.co/cran"
} else {
echo "::set-output name=image::https://packagemanager.posit.co/cran/${{ matrix.config.date }}"
}
shell: bash

- name: Debug image
run: |
# Install pak
echo "::group::Install pak"
if which sudo >/dev/null; then SUDO="sudo -E --preserve-env=PATH env"; else SUDO=""; fi
#$SUDO R -q -e 'dir.create(Sys.getenv("R_LIB_FOR_PAK"), recursive = TRUE, showWarnings = FALSE)'
$SUDO R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "stable", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
echo "::endgroup::"
echo ${{ steps.cran-image.outputs.image }}
shell: bash

- uses: ./.github/actions/setup-r-dependencies.yaml
with:
cache: true
dependency_repo: ${{ steps.cran-image.outputs.image }}
working-directory: ${{ github.workspace }}
extra-packages: any::rcmdcheck


# Install package dependencies (if a specific date)
- name: Install dependencies ${{ matrix.config.date }} (CRAN snapshot)
if: matrix.config.date != 'latest'
run: |
options(
repos = c(CRAN = "https://packagemanager.posit.co/cran/${{ matrix.config.date }}")
)
# - name: Install curl
# if: matrix.os == 'ubuntu-latest' && matrix.config.date != 'latest'
# run: |
# sudo apt install libcurl4-openssl-dev

install.packages(c("rcmdcheck", "devtools"), Ncpus = parallel::detectCores()-1)
# - name: Install pak (Windows + CRAN snapshot)
# if: runner.os == 'Windows' && matrix.config.date != 'latest'
# run: |
# # Install pak
# cat("::group::Install pak\n")
# #lib <- Sys.getenv("R_LIB_FOR_PAK")
# #dir.create(lib, showWarnings = FALSE, recursive = TRUE)
# install.packages("pak", repos = sprintf(
# "https://r-lib.github.io/p/pak/%s/%s/%s/%s",
# "stable",
# .Platform$pkgType,
# R.Version()$os,
# R.Version()$arch
# ))
# cat("::endgroup::\n")
# shell: Rscript {0}

# - name: Install pak (Unix + CRAN snapshot)
# if: runner.os != 'Windows' && matrix.config.date != 'latest'
# run: |
# # Install pak
# echo "::group::Install pak"
# if which sudo >/dev/null; then SUDO="sudo -E --preserve-env=PATH env"; else SUDO=""; fi
# #$SUDO R -q -e 'dir.create(Sys.getenv("R_LIB_FOR_PAK"), recursive = TRUE, showWarnings = FALSE)'
# $SUDO R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "stable", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
# echo "::endgroup::"
# shell: bash

pak::pkg_install(".", dependencies = TRUE, upgrade = TRUE)

#devtools::install(".", dependencies = TRUE, upgrade = TRUE, Ncpus = parallel::detectCores()-1)
# # Install package dependencies (if a specific date)
# - name: Install dependencies ${{ matrix.config.date }} (CRAN snapshot)
# if: matrix.config.date != 'latest'
# run: |
# options(
# repos = c(CRAN = "https://packagemanager.posit.co/cran/${{ matrix.config.date }}")
# )

shell: Rscript {0}
# #install.packages(c("rcmdcheck", "devtools"), Ncpus = parallel::detectCores()-1)

# Install package dependencies (if lastest)
- uses: r-lib/actions/setup-r-dependencies@v2
if: matrix.config.date == 'latest'
with:
extra-packages: any::rcmdcheck
needs: check
# pak::pkg_install(".", dependencies = TRUE, upgrade = TRUE)

# #devtools::install(".", dependencies = TRUE, upgrade = TRUE, Ncpus = parallel::detectCores()-1)

# shell: Rscript {0}

# # Install package dependencies (if lastest)
# - name: Install dependencies (CRAN latest)
# if: matrix.config.date == 'latest'
# uses: r-lib/actions/setup-r-dependencies@v2
# with:
# extra-packages: any::rcmdcheck
# needs: check


- name: Session info
Expand Down

0 comments on commit 355b14e

Please sign in to comment.