Skip to content

Commit 278a662

Browse files
Update R-CMD-check.yaml
1 parent 97fea31 commit 278a662

File tree

1 file changed

+54
-37
lines changed

1 file changed

+54
-37
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,105 @@
1-
name: R-CMD-check
2-
31
on:
42
push:
53
branches: [main]
64
pull_request:
75
branches: [main]
86

7+
name: R-CMD-check
8+
99
jobs:
1010
R-CMD-check:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v2
1515

1616
- uses: r-lib/actions/setup-r@v2
1717
with:
1818
Ncpus: 4
19+
1920
- uses: r-lib/actions/setup-tinytex@v2
2021
- uses: r-lib/actions/setup-pandoc@v2
2122

22-
- name: Prepare month stamp for caches
23-
id: stamp
23+
# Cache keys rotate monthly to keep size under control
24+
- name: "[Custom block] [Cache] Prepare monthly timestamp"
25+
id: date
2426
run: echo "datem=$(date '+%Y-%m')" >> "$GITHUB_OUTPUT"
2527

2628
- name: Cache R packages
2729
uses: pat-s/always-upload-cache@v2
2830
with:
2931
path: ${{ env.R_LIBS_USER }}
30-
key: rcache-${{ steps.stamp.outputs.datem }}
32+
key: rcache-${{ steps.date.outputs.datem }}
3133
restore-keys: rcache-
3234

3335
- name: Cache pip
3436
uses: pat-s/always-upload-cache@v2
3537
with:
3638
path: ~/.cache/pip
37-
key: pycache-${{ steps.stamp.outputs.datem }}
39+
key: pycache-${{ steps.date.outputs.datem }}
3840
restore-keys: pycache-
3941

40-
- name: Install system libs (image + common)
42+
- name: Install Linux prerequisites
4143
run: |
4244
sudo apt-get update
4345
sudo apt-get install -y \
44-
libpng-dev libjpeg-turbo8-dev libtiff5-dev \
45-
libxml2-dev libcurl4-openssl-dev libssl-dev
46+
libxml2-dev libcurl4-openssl-dev \
47+
libpng-dev libtiff-dev libjpeg-dev \
48+
tidy
4649
47-
- name: Install base R deps (reticulate, rcmdcheck)
50+
- name: Install R package dependencies
4851
run: |
49-
install.packages(c("remotes","reticulate","rcmdcheck"))
52+
install.packages(c("remotes","rcmdcheck"))
53+
remotes::install_deps(dependencies = TRUE)
5054
shell: Rscript {0}
5155

52-
- name: Create Miniconda env and install TF/Keras 2.10 stack
56+
# --- Pin old TF/Keras in a Python 3.8 conda env and expose to reticulate ---
57+
- name: Install Miniconda + Python 3.8 + TF/Keras 2.10
5358
run: |
5459
reticulate::install_miniconda(update = TRUE)
5560
reticulate::conda_create('r-reticulate', packages = c('python==3.8'))
56-
reticulate::conda_install('r-reticulate', pip = TRUE, packages = c(
57-
'numpy<2.0',
58-
'tensorflow==2.10.*',
59-
'keras==2.10.*',
60-
'tensorflow_probability==0.16.*'
61-
))
62-
cat(sprintf("RETICULATE_PYTHON=%s\n",
63-
file.path(reticulate::miniconda_path(), "envs","r-reticulate","bin","python")),
64-
file = Sys.getenv("GITHUB_ENV"), append = TRUE)
61+
py <- reticulate::conda_python('r-reticulate')
62+
# Make the env visible to later steps
63+
cat(sprintf("RETICULATE_PYTHON=%s\n", py), file = Sys.getenv("GITHUB_ENV"), append = TRUE)
64+
reticulate::use_python(py, required = TRUE)
65+
keras::install_keras(
66+
version = "2.10.0",
67+
tensorflow = "2.10.0",
68+
extra_packages = c(
69+
'IPython','requests','certifi','urllib3','six',
70+
'tensorflow_probability==0.16.0'
71+
)
72+
)
6573
shell: Rscript {0}
6674

67-
- uses: r-lib/actions/setup-r-dependencies@v2
68-
with:
69-
sysreqs: true
70-
extra-packages: >
71-
any::png
72-
any::jpeg
73-
any::tiff
74-
any::tensorflow
75-
any::keras
76-
any::tfprobability
77-
needs: check
75+
# --- Torch runtime (Lantern) so torch tests can run ---
76+
- name: Install torch runtime (Lantern, CPU)
77+
run: |
78+
if (!requireNamespace("torch", quietly = TRUE)) install.packages("torch")
79+
if (!requireNamespace("luz", quietly = TRUE)) install.packages("luz")
80+
torch::install_torch() # downloads Lantern CPU libs matching installed {torch}
81+
shell: Rscript {0}
82+
83+
# (Optional) Verify torch loads — helps catch Lantern issues early
84+
- name: Torch preflight
85+
run: |
86+
library(torch)
87+
torch_manual_seed(1)
88+
print(torch_randn(c(1)))
89+
shell: Rscript {0}
7890

79-
- name: Install vignette extras
91+
- name: Install dependencies - Tutorial (Vignette)
8092
run: |
8193
install.packages(c("ggplot2","reshape2","MASS","gamlss.data","distr"))
8294
shell: Rscript {0}
8395

8496
- name: Check
85-
run: rcmdcheck::rcmdcheck(args = c("--as-cran","--no-build-vignettes"),
86-
build_args = c("--no-build-vignettes"),
87-
error_on = "error")
97+
env:
98+
RETICULATE_PYTHON: ${{ env.RETICULATE_PYTHON }}
99+
run: |
100+
rcmdcheck::rcmdcheck(
101+
args = c("--as-cran","--no-build-vignettes"),
102+
build_args = c("--no-build-vignettes"),
103+
error_on = "error"
104+
)
88105
shell: Rscript {0}

0 commit comments

Comments
 (0)