Skip to content

Commit

Permalink
updated github action
Browse files Browse the repository at this point in the history
  • Loading branch information
monopteryx committed Aug 17, 2024
1 parent c3f40dd commit 1a86cbf
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions .github/workflows/tic.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
## tic GitHub Actions template: linux-windows
## revision date: 2023-05-22
## tic GitHub Actions template: linux-macos-windows-deploy
## revision date: 2021-06-27
on:
workflow_dispatch:
push:
branches:
- main
- master
- cran-*
pull_request:
branches:
- main
- master
# for now, CRON jobs only run on the default branch of the repo (i.e. usually on master)
schedule:
# * is a special character in YAML so you have to quote this string
Expand All @@ -29,17 +22,24 @@ jobs:
matrix:
config:
# use a different tic template type if you do not want to build on all listed platforms
- { os: ubuntu-latest, r: "release", pkgdown: "true", latex: "true" }
- { os: windows-latest, r: "release" }
- { os: macOS-latest, r: "release" }
- { os: ubuntu-latest, r: "devel" }
- { os: ubuntu-latest, r: "release", pkgdown: "true", latex: "true" }

env:
# otherwise remotes::fun() errors cause the build to fail. Example: Unavailability of binaries
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
CRAN: ${{ matrix.config.cran }}
# make sure to run `tic::use_ghactions_deploy()` to set up deployment
TIC_DEPLOY_KEY: ${{ secrets.TIC_DEPLOY_KEY }}
# prevent rgl issues because no X11 display is available
RGL_USE_NULL: true
# if you use bookdown or blogdown, replace "PKGDOWN" by the respective
# capitalized term. This also might need to be done in tic.R
BUILD_PKGDOWN: ${{ matrix.config.pkgdown }}
# macOS >= 10.15.4 linking
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
# use GITHUB_TOKEN from GitHub to workaround rate limits in {remotes}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -51,6 +51,10 @@ jobs:
r-version: ${{ matrix.config.r }}
Ncpus: 4

# LaTeX. Installation time:
# Linux: ~ 1 min
# macOS: ~ 1 min 30s
# Windows: never finishes
- uses: r-lib/actions/setup-tinytex@v2
if: matrix.config.latex == 'true'

Expand All @@ -62,17 +66,17 @@ jobs:
- name: "[Cache] Prepare daily timestamp for cache"
if: runner.os != 'Windows'
id: date
run: echo "date=$(date '+%d-%m')" >> $GITHUB_OUTPUT
run: echo "::set-output name=date::$(date '+%d-%m')"

- name: "[Cache] Cache R packages"
if: runner.os != 'Windows'
uses: pat-s/always-upload-cache@v3
uses: pat-s/always-upload-cache@v2.1.3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}

- name: "[Stage] [Linux] Install curl and libgit2"
- name: "[Stage] [Linux] Install required system libs"
if: runner.os == 'Linux'
run: sudo apt install libcurl4-openssl-dev libgit2-dev libsodium-dev libharfbuzz-dev libfribidi-dev

Expand All @@ -98,21 +102,34 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev libgeos-dev libudunits2-dev

- name: "[Stage] Install pak"
run: Rscript -e "install.packages('pak', repos = 'https://r-lib.github.io/p/pak/stable')"
- name: "[Custom block] [macOS] Install spatial libraries [ copied from https://github.com/r-spatial/sf/blob/master/.github/workflows/tic-db.yml#L99 ]"
if: runner.os == 'macOS'
run: |
# conflicts with gfortran from r-lib/actions when linking gcc
rm '/usr/local/bin/gfortran'
brew install pkg-config gdal proj geos
- name: "[Stage] Install"
run: Rscript -e "if (grepl('Ubuntu', Sys.info()[['version']]) && !grepl('Under development', R.version[['status']])) {options(repos = c(CRAN = sprintf('https://packagemanager.rstudio.com/all/__linux__/%s/latest', system('lsb_release -cs', intern = TRUE))))}else{options(repos = c(CRAN = 'cloud.r-project.org'))}; pak::pkg_install('ropensci/tic')" -e "print(tic::dsl_load())" -e "tic::prepare_all_stages()" -e "tic::before_install()" -e "tic::install()"
if: matrix.config.os != 'macOS-latest' || matrix.config.r != 'devel'
run: Rscript -e "remotes::install_github('ropensci/tic')" -e "print(tic::dsl_load())" -e "tic::prepare_all_stages()" -e "tic::before_install()" -e "tic::install()"

# macOS devel needs its own stage because we need to work with an option to suppress the usage of binaries
- name: "[Stage] Prepare & Install (macOS-devel)"
if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'devel'
run: |
echo -e 'options(Ncpus = 4, pkgType = "source", repos = structure(c(CRAN = "https://cloud.r-project.org/")))' > $HOME/.Rprofile
Rscript -e "remotes::install_github('ropensci/tic')" -e "print(tic::dsl_load())" -e "tic::prepare_all_stages()" -e "tic::before_install()" -e "tic::install()"
- name: "[Stage] Script"
run: Rscript -e 'tic::script()'

- name: "[Stage] After Success"
if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'release'
run: Rscript -e "tic::after_success()"

- name: "[Stage] Upload R CMD check artifacts"
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v2.2.1
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
Expand Down

0 comments on commit 1a86cbf

Please sign in to comment.