|
1 | | -# Run CI for R using https://eddelbuettel.github.io/r-ci/ |
2 | | - |
3 | 1 | name: check |
4 | 2 |
|
5 | 3 | on: |
|
8 | 6 | pull_request: |
9 | 7 | branches: [main, master] |
10 | 8 |
|
11 | | -env: |
12 | | - USE_BSPM: "true" |
13 | | - _R_CHECK_FORCE_SUGGESTS_: "false" |
14 | | - NO_BINARY_INSTALL_R_PACKAGES: 'c("madrat", "magclass", "citation", "gms", "goxygen", "GDPuc", "roxygen2")' |
15 | | - |
16 | 9 | jobs: |
17 | 10 | check: |
18 | 11 | runs-on: ubuntu-latest |
19 | 12 |
|
20 | 13 | steps: |
21 | | - - uses: actions/checkout@v3 |
| 14 | + - uses: actions/checkout@v4 |
22 | 15 |
|
23 | | - - name: Bootstrap |
24 | | - run: | |
25 | | - sudo chown runner -R . |
26 | | - sudo locale-gen en_US.UTF-8 |
27 | | - sudo add-apt-repository -y ppa:ubuntugis/ppa |
28 | | - curl -OLs https://eddelbuettel.github.io/r-ci/run.sh |
29 | | - chmod 0755 run.sh |
30 | | - ./run.sh bootstrap |
31 | | - rm -f bspm_*.tar.gz |
32 | | -
|
33 | | - - name: Enable r-universe repo, modify bspm integration |
34 | | - run: | |
35 | | - # install packages from https://pik-piam.r-universe.dev and CRAN |
36 | | - echo ' |
37 | | - options(repos = c(universe = "https://pik-piam.r-universe.dev", |
38 | | - CRAN = "https://cloud.r-project.org")) |
39 | | - ' >> .Rprofile |
40 | | - cat .Rprofile |
41 | | - # modify bspm integration to never install binary builds of PIK CRAN packages |
42 | | - sudo sed -i '/bspm::enable()/d' /etc/R/Rprofile.site |
43 | | - # need double % because of printf, %s is replaced with "$NO_BINARY_INSTALL_R_PACKAGES" (see "env:" above) |
44 | | - printf ' |
45 | | - local({ |
46 | | - expr <- quote({ |
47 | | - if (!is.null(repos)) { |
48 | | - noBinaryInstallRPackages <- %s |
49 | | - pkgs <- c(bspm::install_sys(pkgs[!pkgs %%in%% noBinaryInstallRPackages]), |
50 | | - pkgs[pkgs %%in%% noBinaryInstallRPackages]) |
51 | | - } |
52 | | - type <- "source" |
53 | | - }) |
54 | | - trace(utils::install.packages, expr, print = FALSE) |
55 | | - }) |
56 | | - ' "$NO_BINARY_INSTALL_R_PACKAGES" | sudo tee --append /etc/R/Rprofile.site >/dev/null |
57 | | - cat /etc/R/Rprofile.site |
| 16 | + - uses: r-lib/actions/setup-pandoc@v2 |
58 | 17 |
|
59 | | - - name: Set up Pandoc |
60 | | - uses: r-lib/actions/setup-pandoc@v2 |
61 | | - |
62 | | - - name: Set up Python 3.9 |
63 | | - uses: actions/setup-python@v4 |
| 18 | + - uses: r-lib/actions/setup-r@v2 |
64 | 19 | with: |
65 | | - python-version: 3.9 |
| 20 | + use-public-rspm: true |
| 21 | + extra-repositories: "https://rse.pik-potsdam.de/r/packages" |
66 | 22 |
|
67 | | - - name: Cache R libraries |
68 | | - if: ${{ !env.ACT }} # skip when running locally via nektos/act |
69 | | - uses: pat-s/always-upload-cache@v3 |
| 23 | + - uses: r-lib/actions/setup-r-dependencies@v2 |
70 | 24 | with: |
71 | | - path: /usr/local/lib/R/ |
72 | | - key: 3-${{ runner.os }}-usr-local-lib-R-${{ hashFiles('DESCRIPTION') }} |
73 | | - restore-keys: | |
74 | | - 3-${{ runner.os }}-usr-local-lib-R- |
75 | | -
|
76 | | - - name: Restore R library permissions |
77 | | - run: | |
78 | | - sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library |
79 | | -
|
80 | | - - name: Install dependencies |
81 | | - run: | |
82 | | - ./run.sh install_aptget libhdf5-dev libharfbuzz-dev libfribidi-dev |
83 | | - ./run.sh install_all |
84 | | - ./run.sh install_r_binary covr rstudioapi |
85 | | - ./run.sh install_r lucode2 |
| 25 | + extra-packages: | |
| 26 | + any::lucode2 |
| 27 | + any::covr |
| 28 | + any::madrat |
| 29 | + any::magclass |
| 30 | + any::citation |
| 31 | + any::gms |
| 32 | + any::goxygen |
| 33 | + any::GDPuc |
| 34 | + # piam packages also available on CRAN (madrat, magclass, citation, |
| 35 | + # gms, goxygen, GDPuc) will usually have an outdated binary version |
| 36 | + # available; by using extra-packages we get the newest version |
| 37 | + |
| 38 | + - uses: actions/setup-python@v5 |
| 39 | + with: |
| 40 | + python-version: 3.9 |
86 | 41 |
|
87 | 42 | - name: Install python dependencies if applicable |
88 | 43 | run: | |
89 | 44 | [ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true |
90 | 45 | [ -f requirements.txt ] && pip install -r requirements.txt || true |
91 | 46 |
|
92 | | - - name: Remove bspm integration # to get rid of error when running install.packages |
93 | | - run: | |
94 | | - sudo sed -i '/ trace(utils::install.packages, expr, print = FALSE)/d' /etc/R/Rprofile.site |
95 | | - cat /etc/R/Rprofile.site |
96 | | -
|
97 | 47 | - name: Verify validation key |
98 | 48 | shell: Rscript {0} |
99 | 49 | run: lucode2:::validkey(stopIfInvalid = TRUE) |
100 | 50 |
|
| 51 | + - name: Verify that lucode2::buildLibrary was successful |
| 52 | + if: github.event_name == 'pull_request' |
| 53 | + shell: Rscript {0} |
| 54 | + run: lucode2:::isVersionUpdated() |
| 55 | + |
101 | 56 | - name: Checks |
102 | 57 | shell: Rscript {0} |
103 | 58 | run: | |
|
106 | 61 |
|
107 | 62 | - name: Test coverage |
108 | 63 | shell: Rscript {0} |
109 | | - run: covr::codecov(quiet = FALSE) |
| 64 | + run: | |
| 65 | + nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) |
| 66 | + if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE) |
110 | 67 | env: |
111 | 68 | NOT_CRAN: "true" |
0 commit comments