|
1 | | -name: R-CMD-check |
2 | | - |
3 | 1 | on: |
4 | 2 | push: |
5 | 3 | branches: [main] |
6 | 4 | pull_request: |
7 | 5 | branches: [main] |
8 | 6 |
|
| 7 | +name: R-CMD-check |
| 8 | + |
9 | 9 | jobs: |
10 | 10 | R-CMD-check: |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 |
|
13 | 13 | steps: |
14 | | - - uses: actions/checkout@v4 |
| 14 | + - uses: actions/checkout@v2 |
15 | 15 |
|
16 | 16 | - uses: r-lib/actions/setup-r@v2 |
17 | 17 | with: |
18 | 18 | Ncpus: 4 |
| 19 | + |
19 | 20 | - uses: r-lib/actions/setup-tinytex@v2 |
20 | 21 | - uses: r-lib/actions/setup-pandoc@v2 |
21 | 22 |
|
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 |
24 | 26 | run: echo "datem=$(date '+%Y-%m')" >> "$GITHUB_OUTPUT" |
25 | 27 |
|
26 | 28 | - name: Cache R packages |
27 | 29 | uses: pat-s/always-upload-cache@v2 |
28 | 30 | with: |
29 | 31 | path: ${{ env.R_LIBS_USER }} |
30 | | - key: rcache-${{ steps.stamp.outputs.datem }} |
| 32 | + key: rcache-${{ steps.date.outputs.datem }} |
31 | 33 | restore-keys: rcache- |
32 | 34 |
|
33 | 35 | - name: Cache pip |
34 | 36 | uses: pat-s/always-upload-cache@v2 |
35 | 37 | with: |
36 | 38 | path: ~/.cache/pip |
37 | | - key: pycache-${{ steps.stamp.outputs.datem }} |
| 39 | + key: pycache-${{ steps.date.outputs.datem }} |
38 | 40 | restore-keys: pycache- |
39 | 41 |
|
40 | | - - name: Install system libs (image + common) |
| 42 | + - name: Install Linux prerequisites |
41 | 43 | run: | |
42 | 44 | sudo apt-get update |
43 | 45 | 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 |
46 | 49 |
|
47 | | - - name: Install base R deps (reticulate, rcmdcheck) |
| 50 | + - name: Install R package dependencies |
48 | 51 | run: | |
49 | | - install.packages(c("remotes","reticulate","rcmdcheck")) |
| 52 | + install.packages(c("remotes","rcmdcheck")) |
| 53 | + remotes::install_deps(dependencies = TRUE) |
50 | 54 | shell: Rscript {0} |
51 | 55 |
|
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 |
53 | 58 | run: | |
54 | 59 | reticulate::install_miniconda(update = TRUE) |
55 | 60 | 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 | + ) |
65 | 73 | shell: Rscript {0} |
66 | 74 |
|
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} |
78 | 90 |
|
79 | | - - name: Install vignette extras |
| 91 | + - name: Install dependencies - Tutorial (Vignette) |
80 | 92 | run: | |
81 | 93 | install.packages(c("ggplot2","reshape2","MASS","gamlss.data","distr")) |
82 | 94 | shell: Rscript {0} |
83 | 95 |
|
84 | 96 | - 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 | + ) |
88 | 105 | shell: Rscript {0} |
0 commit comments