change how we load EJAM package #20
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
name: EJAM Installation | |
on: | |
push: | |
branches: [ "main", "test" ] | |
pull_request: | |
branches: [ "main", "test" ] | |
permissions: | |
contents: read | |
jobs: | |
install_ejam: | |
if: ${{ !github.event.repository.private }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
r-version: [4.3, 4.4] | |
install-method: [github, url] # Matrix for installation method | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.r-version }} | |
- name: Restore R package cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ runner.temp }} | |
key: ${{ runner.os }}-R-${{ matrix.r-version }}-${{ hashFiles('**/DESCRIPTION') }} | |
restore-keys: ${{ runner.os }}-R-${{ matrix.r-version }}- | |
- name: System Libraries | |
if: runner.os != 'Windows' | |
run: | | |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then | |
sudo apt-get update | |
sudo apt-get install -y libfontconfig1-dev libudunits2-dev libcairo2-dev libcurl4-openssl-dev \ | |
libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev \ | |
libjpeg-dev libgdal-dev libgeos-dev libproj-dev | |
elif [ "${{ matrix.os }}" == "macOS-latest" ]; then | |
brew install freetype udunits cairo harfbuzz fribidi libpng libtiff jpeg gdal pkg-config | |
fi | |
- name: Get latest tar.gz URL | |
if: matrix.install-method == 'url' | |
shell: bash | |
run: | | |
LATEST_TAG=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r '.tag_name') | |
TAR_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${LATEST_TAG}.tar.gz" | |
echo "TAR_URL=$TAR_URL" >> $GITHUB_ENV | |
- name: Install EJAM (method- ${{ matrix.install-method }}) | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
install.packages("remotes") | |
if("${{ matrix.install-method }}" == "github") { | |
remotes::install_github( | |
"${{ github.repository }}", # what owner/repo has the pkg to try to install | |
dependencies=TRUE, | |
force=TRUE, | |
INSTALL_opts = c("--with-keep.source", "--install-tests") | |
) | |
} else { | |
remotes::install_url( | |
url = Sys.getenv("TAR_URL"), | |
dependencies = TRUE, | |
auth_token = "" | |
) | |
} | |
shell: Rscript {0} | |
- name: Restore R package cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ runner.temp }} | |
key: ${{ runner.os }}-R-${{ matrix.r-version }}-${{ hashFiles('**/DESCRIPTION') }} | |
restore-keys: ${{ runner.os }}-R-${{ matrix.r-version }}- | |
- name: Test Installation | |
run: | | |
library(EJAM) | |
print("Package loaded successfully")' | |
shell: Rscript {0} |