-
Notifications
You must be signed in to change notification settings - Fork 20
233 lines (208 loc) · 11 KB
/
R-CMD-check.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
push:
branches:
- master
- main
pull_request:
schedule:
- cron: '0 3 * * 4'
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.dep }}${{ matrix.config.r }}, ${{ matrix.config.qgis }})
strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, qgis: 'none', r: 'release', dep: '', r-pkg-cache: 'v0'}
- {os: macOS-latest, qgis: 'macos-brew', r: 'release', dep: '', r-pkg-cache: 'v0'}
- {os: windows-latest, qgis: 'windows-chocolatey', r: 'release', dep: '', r-pkg-cache: 'v0'}
- {os: windows-latest, qgis: 'windows-chocolatey', r: 'devel', dep: '', r-pkg-cache: 'v2'}
- {os: ubuntu-22.04, qgis: 'ubuntu-nightly', r: 'release', dep: '', r-pkg-cache: 'v0'}
- {os: ubuntu-22.04, qgis: 'ubuntu-nightly', r: 'devel', dep: '', r-pkg-cache: 'v2'}
- {os: ubuntu-22.04, qgis: 'ubuntugis', r: 'release', dep: '', r-pkg-cache: 'v1'}
- {os: ubuntu-22.04, qgis: 'ubuntu', r: 'release', dep: '', r-pkg-cache: 'v0'}
- {os: ubuntu-22.04, qgis: 'ubuntu', r: 'release', dep: 'hard ', r-pkg-cache: 'v3'}
- {os: ubuntu-22.04, qgis: 'ubuntu-ltr', r: 'release', dep: '', r-pkg-cache: 'v0'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
SAGANGV: 0.0.7
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
extra-repositories: https://geocompr.r-universe.dev
- name: Prepare Ubuntu for installing QGIS (common code)
if: runner.os == 'Linux'
run: |
# Prepare Ubuntu for installing QGIS (common code)
echo "::group::Dynamically set QGIS_PLUGINPATH environment var (available to next steps)"
mkdir ../extra_plugins
echo "QGIS_PLUGINPATH=$(pwd)/../extra_plugins" >> $GITHUB_ENV
echo "::endgroup::"
echo "::group::Install the QGIS Signing Key"
sudo wget -qO /etc/apt/keyrings/qgis-archive-keyring.gpg https://download.qgis.org/downloads/qgis-archive-keyring.gpg
echo "::endgroup::"
- name: Add repo to install QGIS development version for Ubuntu
if: matrix.config.qgis == 'ubuntu-nightly'
run: |
# Add repo to install QGIS development version for Ubuntu (using an often outdated GRASS release from Ubuntu repo)
sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/ubuntu-nightly `lsb_release -c -s` main" > /etc/apt/sources.list.d/qgis.list'
- name: Add repos to install upcoming QGIS point release for Ubuntugis (becoming latest release in < 1 month)
if: matrix.config.qgis == 'ubuntugis'
run: |
# Add repos to install upcoming QGIS point release (becoming latest release in < 1 month) for Ubuntugis (ubuntugis-unstable PPA, with current GRASS release)
sudo mkdir -p /root/.gnupg
sudo chmod 700 /root/.gnupg
sudo gpg --no-default-keyring --keyring /etc/apt/keyrings/ubuntugis-unstable-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 6B827C12C2D425E227EDCA75089EBE08314DF160
sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/ubuntugis-unstable-archive-keyring.gpg] http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu `lsb_release -c -s` main" > /etc/apt/sources.list.d/ubuntugis-unstable.list'
sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/ubuntugis-nightly-release `lsb_release -c -s` main" > /etc/apt/sources.list.d/qgis.list'
- name: Add repo to install latest QGIS release for Ubuntu
if: matrix.config.qgis == 'ubuntu'
run: |
# Add repo to install latest QGIS release for Ubuntu (using an often outdated GRASS release from Ubuntu repo)
sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/ubuntu `lsb_release -c -s` main" > /etc/apt/sources.list.d/qgis.list'
- name: Add repo to install QGIS LTR (long-term release) for Ubuntu
if: matrix.config.qgis == 'ubuntu-ltr'
run: |
# Add repo to install QGIS LTR (long-term release) for Ubuntu (using an often outdated GRASS release from Ubuntu repo)
sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/ubuntu-ltr `lsb_release -c -s` main" > /etc/apt/sources.list.d/qgis.list'
- name: Install QGIS, GRASS, SAGA and the SAGA NextGen plugin (Ubuntu) from preset repos
if: runner.os == 'Linux'
run: |
# Install QGIS, GRASS, SAGA and the SAGA NextGen plugin (Ubuntu) from preset repos
sudo apt-get update
sudo apt-get install -y qgis qgis-plugin-grass saga
wget -qO ../sagang_plugin.zip https://plugins.qgis.org/plugins/processing_saga_nextgen/version/$SAGANGV/download/
unzip -q ../sagang_plugin.zip -d ../extra_plugins
- name: Install QGIS (MacOS homebrew)
if: matrix.config.qgis == 'macos-brew'
run: |
brew install --cask qgis
# installs last nightly build of QGIS
# works locally, hangs on GHA after download
# leaving this out until can figure out how to run reliably
- name: Install QGIS (MacOS nightly)
if: matrix.config.qgis == 'macos-nightly'
run: |
# Setup QGIS from MacOS nightly
curl https://qgis.org/downloads/macos/qgis-macos-nightly.dmg --output qgis-macos-nightly.dmg
yes | hdiutil attach -nobrowse -noverify -mountpoint qgis qgis-macos-nightly.dmg > /dev/null
sudo cp -R qgis/QGIS.app /Applications
- name: Install QGIS (Windows chocolatey)
if: matrix.config.qgis == 'windows-chocolatey'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install qgis
- name: Query R dependencies and report available versions
id: query
if: matrix.config.dep == ''
run: |
# Query R dependencies and report available versions
cat("::group::Install pak\n")
install.packages("pak", repos = "https://r-lib.github.io/p/pak/stable/")
cat("::endgroup::\n")
cat("::group::Create minimal data frame with pkg deps and store them\n")
depends <- pak::pkg_deps(c("deps::.", "any::sessioninfo", "any::rcmdcheck", "any::covr"), dependencies = c("Config/Needs/check", "all"))[, c("ref", "version")]
depends <- depends[depends$ref != "deps::.", ]
saveRDS(depends, ".github/depends.Rds")
cat("::endgroup::\n")
cat("::group::Store R-version\n")
cat("r-version=", sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
cat("::endgroup::\n")
cat("::group::Print results\n")
cat("R version:", sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), "\n")
print(as.data.frame(depends), row.names = FALSE)
cat("::endgroup::\n")
shell: Rscript {0}
- name: Restore (or define new) R package cache
if: matrix.config.dep == ''
uses: actions/cache@v3
with:
path: |
${{ env.R_LIBS_USER }}/*
!${{ env.R_LIBS_USER }}/pak
key: ${{ matrix.config.os }}-${{ steps.query.outputs.r-version }}-${{ matrix.config.r-pkg-cache }}-${{ hashFiles('.github/depends.Rds') }}
- name: Install missing package dependencies
if: matrix.config.dep == ''
run: |
# Install missing package dependencies
cat("::group::Install\n")
pak::pkg_install(c("deps::.", "any::sessioninfo", "any::rcmdcheck", "any::covr"), upgrade = FALSE, dependencies = c("Config/Needs/check", "all"))
# This is based on the minimum needed version, not the hash of what is available at RSPM
cat("::endgroup::\n")
cat("::group::Session info\n")
sessioninfo::session_info(pkgs = "installed", include_base = TRUE)
cat("::endgroup::\n")
shell: Rscript {0}
# raster, sf, terra and lwgeom from RSPM use older sysdeps than ubuntugis
- name: In the ubuntugis job, reinstall some pkgs from source if needed
if: matrix.config.qgis == 'ubuntugis'
run: |
# Rebuild and install sf, terra etc. if the RSPM binaries (or cached pkgs) don't load
cat("::group::sf\n")
if (!requireNamespace("sf", quietly = TRUE)) {
install.packages("sf", repos = "https://cloud.r-project.org")
}
cat("::endgroup::\n")
cat("::group::terra\n")
if (!requireNamespace("terra", quietly = TRUE)) {
install.packages("terra", repos = "https://cloud.r-project.org")
}
cat("::endgroup::\n")
cat("::group::raster\n")
if (!requireNamespace("raster", quietly = TRUE)) {
install.packages("raster", repos = "https://cloud.r-project.org")
}
cat("::endgroup::\n")
cat("::group::lwgeom (needed by stars)\n")
if (!requireNamespace("lwgeom", quietly = TRUE)) { # needed for stars
install.packages("lwgeom", repos = "https://cloud.r-project.org")
}
cat("::endgroup::\n")
cat("::group::Session info\n")
sessioninfo::session_info(pkgs = "installed", include_base = TRUE)
cat("::endgroup::\n")
shell: Rscript {0}
- name: Install hard R pkg dependencies only
if: matrix.config.dep == 'hard '
uses: r-lib/actions/setup-r-dependencies@v2
with:
dependencies: '"hard"'
cache: false
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check
- uses: r-lib/actions/check-r-package@v2
# run with CMD check because installing QGIS is expensive
- name: Test Coverage
if: matrix.config.qgis == 'ubuntu' && matrix.config.dep == ''
run: |
# Setup code coverage with Codecov
covr::codecov(quiet = FALSE)
shell: Rscript {0}
- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Show platform-info output
if: always()
run: find check -name 'platform-info.Rout*' -exec cat '{}' \; || true
shell: bash
- name: Upload check results
if: failure()
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.os }}_r-${{ matrix.config.r }}_qgis-${{ matrix.config.qgis }}_results
path: check