Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-s committed Dec 15, 2023
1 parent a9344a5 commit 1110378
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion inst/templates/ghactions-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

- name: "[Stage] Upload R CMD check artifacts"
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -65,6 +65,10 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2

- name: Install sys deps for Ubuntu
if: runner.os == 'Linux'
run: sudo apt update && sudo apt install -y libgit2-dev libcurl4-openssl-dev

# set date/week for use in cache creation
# https://github.community/t5/GitHub-Actions/How-to-set-and-access-a-Workflow-variable/m-p/42970
# - cache R packages daily
Expand All @@ -73,23 +77,26 @@ jobs:
id: date
run: echo "date=$(date '+%d-%m')" >> $GITHUB_OUTPUT

- name: "[Cache] Cache R packages"
- name: "[Cache] Restore R package cache"
if: runner.os != 'Windows'
uses: pat-s/always-upload-cache@v3
uses: actions/cache/restore@v3
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: "[Custom block] Test custom user block"
run: |
echo 'test'
- name: "[Stage] Install pak"
run: Rscript -e "install.packages('pak', repos = 'https://r-lib.github.io/p/pak/stable')"

- 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()"
run: Rscript -e "install.packages('tic', repos = c('https://ropensci.r-universe.dev', if (grepl('Ubuntu', Sys.info()[['version']])) {sprintf('https://packagemanager.rstudio.com/all/__linux__/%s/latest', system('lsb_release -cs', intern = TRUE))} else {'https://cloud.r-project.org'}))" -e "print(tic::dsl_load())" -e "tic::prepare_all_stages()" -e "tic::before_install()" -e "tic::install()"

- name: "[Cache] Save R package cache"
if: runner.os != 'Windows' && always()
uses: actions/cache/save@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}

- name: "[Stage] Script"
run: Rscript -e 'tic::script()'
Expand All @@ -103,7 +110,7 @@ jobs:

- name: "[Stage] Upload R CMD check artifacts"
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
Expand Down
31 changes: 14 additions & 17 deletions inst/testdata/ghactions-test-update-yaml-env-and-blocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ jobs:

- uses: r-lib/actions/setup-pandoc@master

- name: Install sys deps for Ubuntu
if: runner.os == 'Linux'
run: sudo apt update && sudo apt install -y libgit2-dev libcurl4-openssl-dev

# set date/week for use in cache creation
# https://github.community/t5/GitHub-Actions/How-to-set-and-access-a-Workflow-variable/m-p/42970
# - cache R packages daily
Expand All @@ -82,31 +86,17 @@ jobs:
id: date
run: echo "date=$(date '+%d-%m')" >> $GITHUB_OUTPUT

- name: "[Cache] Cache R packages"
- name: "[Cache] Restore R package cache"
if: runner.os != 'Windows'
uses: pat-s/always-upload-cache@v1.2.0
uses: actions/cache/restore@v3
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}}

# install ccache and write config file
- name: "[Linux] ccache"
if: runner.os == 'Linux'
run: |
sudo apt install ccache libcurl4-openssl-dev
mkdir -p ~/.R && echo -e 'CC=ccache gcc -std=gnu99\nCXX=ccache g++\nFC=ccache gfortran\nF77=ccache gfortran' > $HOME/.R/Makevars

- name: "[Custom block] Test custom user block"
run: |
echo 'test'
# for some strange Windows reason this step and the next one need to be decoupled
- name: "[Stage] Prepare"
run: |
Rscript -e "if (!requireNamespace('remotes')) install.packages('remotes', type = 'source')"
Rscript -e "if (getRversion() < '3.2' && !requireNamespace('curl')) install.packages('curl', type = 'source')"
- name: "[Stage] 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()"
Expand All @@ -118,6 +108,13 @@ jobs:
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: "[Cache] Save R package cache"
if: runner.os != 'Windows' && always()
uses: actions/cache/save@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{steps.date.outputs.date}}

- name: "[Stage] Script"
run: Rscript -e 'tic::script()'

Expand All @@ -131,7 +128,7 @@ jobs:

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

0 comments on commit 1110378

Please sign in to comment.