Browse code

Add github actions

Steffen Neumann authored on 26/11/2021 21:38:42
Showing 2 changed files

1 1
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+*.html
0 2
new file mode 100644
... ...
@@ -0,0 +1,297 @@
1
+## Read more about GitHub actions the features of this GitHub Actions workflow
2
+## at https://lcolladotor.github.io/biocthis/articles/biocthis.html#use_bioc_github_action
3
+##
4
+## For more details, check the biocthis developer notes vignette at
5
+## https://lcolladotor.github.io/biocthis/articles/biocthis_dev_notes.html
6
+##
7
+## You can add this workflow to other packages using:
8
+## > biocthis::use_bioc_github_action()
9
+##
10
+## Using GitHub Actions exposes you to many details about how R packages are
11
+## compiled and installed in several operating system.s
12
+### If you need help, please follow the steps listed at
13
+## https://github.com/r-lib/actions#where-to-find-help
14
+##
15
+## If you found an issue specific to biocthis's GHA workflow, please report it
16
+## with the information that will make it easier for others to help you.
17
+## Thank you!
18
+
19
+## Acronyms:
20
+## * GHA: GitHub Action
21
+## * OS: operating system
22
+
23
+on:
24
+  push:
25
+  pull_request:
26
+
27
+name: R-CMD-check-bioc
28
+
29
+## These environment variables control whether to run GHA code later on that is
30
+## specific to testthat, covr, and pkgdown.
31
+##
32
+## If you need to clear the cache of packages, update the number inside
33
+## cache-version as discussed at https://github.com/r-lib/actions/issues/86.
34
+## Note that you can always run a GHA test without the cache by using the word
35
+## "/nocache" in the commit message.
36
+env:
37
+  has_testthat: 'true'
38
+  run_covr: 'true'
39
+  run_pkgdown: 'true'
40
+  has_RUnit: 'false'
41
+  has_BiocCheck: 'false'
42
+  cache-version: 'cache-v1'
43
+
44
+jobs:
45
+  build-check:
46
+    runs-on: ${{ matrix.config.os }}
47
+    name: ${{ matrix.config.os }} (${{ matrix.config.r }})
48
+    container: ${{ matrix.config.cont }}
49
+    ## Environment variables unique to this job.
50
+
51
+    strategy:
52
+      fail-fast: false
53
+      matrix:
54
+        config:
55
+          - { os: ubuntu-latest, r: 'devel', bioc: '3.15', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
56
+          - { os: macOS-latest, r: 'devel', bioc: '3.15'}
57
+          - { os: windows-latest, r: 'devel', bioc: '3.15'}
58
+    env:
59
+      R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
60
+      RSPM: ${{ matrix.config.rspm }}
61
+      NOT_CRAN: true
62
+      TZ: UTC
63
+      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64
+      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
65
+
66
+    steps:
67
+
68
+      ## Set the R library to the directory matching the
69
+      ## R packages cache step further below when running on Docker (Linux).
70
+      - name: Set R Library home on Linux
71
+        if: runner.os == 'Linux'
72
+        run: |
73
+          mkdir /__w/_temp/Library
74
+          echo ".libPaths('/__w/_temp/Library')" > ~/.Rprofile
75
+
76
+      ## Most of these steps are the same as the ones in
77
+      ## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml
78
+      ## If they update their steps, we will also need to update ours.
79
+      - name: Checkout Repository
80
+        uses: actions/checkout@v2
81
+
82
+      ## R is already included in the Bioconductor docker images
83
+      - name: Setup R from r-lib
84
+        if: runner.os != 'Linux'
85
+        uses: r-lib/actions/setup-r@master
86
+        with:
87
+          r-version: ${{ matrix.config.r }}
88
+
89
+      ## pandoc is already included in the Bioconductor docker images
90
+      - name: Setup pandoc from r-lib
91
+        if: runner.os != 'Linux'
92
+        uses: r-lib/actions/setup-pandoc@master
93
+
94
+      - name: Query dependencies
95
+        run: |
96
+          install.packages('remotes')
97
+          saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
98
+        shell: Rscript {0}
99
+
100
+      - name: Cache R packages
101
+        if: "!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'"
102
+        uses: actions/cache@v2
103
+        with:
104
+          path: ${{ env.R_LIBS_USER }}
105
+          key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }}
106
+          restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-
107
+
108
+      - name: Cache R packages on Linux
109
+        if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' "
110
+        uses: actions/cache@v2
111
+        with:
112
+          path: /home/runner/work/_temp/Library
113
+          key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }}
114
+          restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-
115
+
116
+      - name: Install Linux system dependencies
117
+        if: runner.os == 'Linux'
118
+        run: |
119
+          sysreqs=$(Rscript -e 'cat("apt-get update -y && apt-get install -y", paste(gsub("apt-get install -y ", "", remotes::system_requirements("ubuntu", "20.04")), collapse = " "))')
120
+          echo $sysreqs
121
+          sudo -s eval "$sysreqs"
122
+
123
+      - name: Install macOS system dependencies
124
+        if: matrix.config.os == 'macOS-latest'
125
+        run: |
126
+          ## Enable installing XML from source if needed
127
+          brew install libxml2
128
+          echo "XML_CONFIG=/usr/local/opt/libxml2/bin/xml2-config" >> $GITHUB_ENV
129
+
130
+          ## Required to install magick as noted at
131
+          ## https://github.com/r-lib/usethis/commit/f1f1e0d10c1ebc75fd4c18fa7e2de4551fd9978f#diff-9bfee71065492f63457918efcd912cf2
132
+          brew install imagemagick@6
133
+
134
+          ## For textshaping, required by ragg, and required by pkgdown
135
+          brew install harfbuzz fribidi
136
+
137
+          ## For installing usethis's dependency gert
138
+          brew install libgit2
139
+
140
+          ## required for ncdf4
141
+          ## brew install netcdf ## Does not work as it is compiled with gcc
142
+          ## Use pre-compiled libraries from https://mac.r-project.org/libs-4/
143
+          curl -O https://mac.r-project.org/libs-4/netcdf-4.7.4-darwin.17-x86_64.tar.gz
144
+          tar fvxzm netcdf-4.7.4-darwin.17-x86_64.tar.gz -C /
145
+          rm netcdf-4.7.4-darwin.17-x86_64.tar.gz
146
+          curl -O https://mac.r-project.org/libs-4/hdf5-1.12.0-darwin.17-x86_64.tar.gz
147
+          tar fvxzm hdf5-1.12.0-darwin.17-x86_64.tar.gz -C /
148
+          rm hdf5-1.12.0-darwin.17-x86_64.tar.gz
149
+          curl -O https://mac.r-project.org/libs-4/szip-2.1.1-darwin.17-x86_64.tar.gz
150
+          tar fvxzm szip-2.1.1-darwin.17-x86_64.tar.gz -C /
151
+          rm szip-2.1.1-darwin.17-x86_64.tar.gz
152
+
153
+      - name: Install Windows system dependencies
154
+        if: runner.os == 'Windows'
155
+        run: |
156
+          ## Edit below if you have any Windows system dependencies
157
+        shell: Rscript {0}
158
+
159
+      - name: Install BiocManager
160
+        run: |
161
+          message(paste('****', Sys.time(), 'installing BiocManager ****'))
162
+          remotes::install_cran("BiocManager")
163
+        shell: Rscript {0}
164
+
165
+      - name: Set BiocVersion
166
+        run: |
167
+          BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE)
168
+        shell: Rscript {0}
169
+
170
+      - name: Install dependencies pass 1
171
+        run: |
172
+          ## Try installing the package dependencies in steps. First the local
173
+          ## dependencies, then any remaining dependencies to avoid the
174
+          ## issues described at
175
+          ## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html
176
+          ## https://github.com/r-lib/remotes/issues/296
177
+          ## Ideally, all dependencies should get installed in the first pass.
178
+
179
+          ## Pass #1 at installing dependencies
180
+          message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****'))
181
+          remotes::install_local(dependencies = TRUE, repos =
182
+          BiocManager::repositories(), build_vignettes = FALSE, upgrade = TRUE)
183
+
184
+          BiocManager::install(c("rmarkdown", "BiocStyle"))
185
+        continue-on-error: true
186
+        shell: Rscript {0}
187
+
188
+      - name: Install dependencies pass 2
189
+        run: |
190
+          ## Pass #2 at installing dependencies
191
+          message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****'))
192
+          remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = FALSE, upgrade = TRUE)
193
+
194
+          ## Manually install packages that seem to be skipped.
195
+          message(paste('****', Sys.time(), 'force installation of selected packages  ****'))
196
+          BiocManager::install(c("faahKO"))
197
+          BiocManager::install("lgatto/ProtGenerics")
198
+          BiocManager::install("lgatto/MSnbase")
199
+          ## BiocManager::install("sneumann/mzR")
200
+          BiocManager::install("RforMassSpectrometry/Spectra")
201
+          BiocManager::install("RforMassSpectrometry/MsBackendMgf")
202
+          BiocManager::install("magick")
203
+
204
+          ## For running the checks
205
+          message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
206
+          remotes::install_cran("rcmdcheck")
207
+          BiocManager::install(c("BiocCheck", "DBI"))
208
+        shell: Rscript {0}
209
+
210
+      - name: Install BiocGenerics
211
+        if:  env.has_RUnit == 'true'
212
+        run: |
213
+          ## Install BiocGenerics
214
+          BiocManager::install("BiocGenerics")
215
+        shell: Rscript {0}
216
+
217
+      - name: Install covr
218
+        if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux'
219
+        run: |
220
+          remotes::install_cran("covr")
221
+        shell: Rscript {0}
222
+
223
+      - name: Install pkgdown
224
+        if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
225
+        run: |
226
+          remotes::install_github("r-lib/pkgdown")
227
+        shell: Rscript {0}
228
+
229
+      - name: Session info
230
+        run: |
231
+          options(width = 100)
232
+          pkgs <- installed.packages()[, "Package"]
233
+          sessioninfo::session_info(pkgs, include_base = TRUE)
234
+        shell: Rscript {0}
235
+
236
+      - name: Run CMD check
237
+        env:
238
+          _R_CHECK_CRAN_INCOMING_: false
239
+        run: |
240
+          rcmdcheck::rcmdcheck(
241
+              args = c("--no-build-vignettes", "--no-manual", "--timings"),
242
+              build_args = c("--no-manual", "--no-resave-data"),
243
+              error_on = "warning",
244
+              check_dir = "check"
245
+          )
246
+        shell: Rscript {0}
247
+
248
+      ## Might need an to add this to the if:  && runner.os == 'Linux'
249
+      - name: Reveal testthat details
250
+        if:  env.has_testthat == 'true'
251
+        run: find . -name testthat.Rout -exec cat '{}' ';'
252
+
253
+      - name: Run RUnit tests
254
+        if:  env.has_RUnit == 'true'
255
+        run: |
256
+          BiocGenerics:::testPackage()
257
+        shell: Rscript {0}
258
+
259
+      - name: Run BiocCheck
260
+        if:  env.has_BiocCheck == 'true'
261
+        run: |
262
+          BiocCheck::BiocCheck(
263
+              dir('check', 'tar.gz$', full.names = TRUE),
264
+              `quit-with-status` = TRUE,
265
+              `no-check-R-ver` = TRUE,
266
+              `no-check-bioc-help` = TRUE
267
+          )
268
+        shell: Rscript {0}
269
+
270
+      - name: Test coverage
271
+        if: github.ref == 'refs/heads/master' && env.run_covr == 'true' && runner.os == 'Linux'
272
+        run: |
273
+          covr::codecov()
274
+        shell: Rscript {0}
275
+
276
+      - name: Install package
277
+        if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
278
+        run: R CMD INSTALL .
279
+
280
+      - name: Deploy package
281
+        if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
282
+        run: |
283
+          git config --local user.email "actions@github.com"
284
+          git config --local user.name "GitHub Actions"
285
+          Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)"
286
+        shell: bash {0}
287
+        ## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE)
288
+        ## at least one locally before this will work. This creates the gh-pages
289
+        ## branch (erasing anything you haven't version controlled!) and
290
+        ## makes the git history recognizable by pkgdown.
291
+
292
+      - name: Upload check results
293
+        if: failure()
294
+        uses: actions/upload-artifact@master
295
+        with:
296
+          name: ${{ runner.os }}-biocversion-devel-r-devel-results
297
+          path: check