Browse code

Updated GA Worflow.

Robert Ivánek authored on 13/03/2023 10:46:32
Showing 1 changed files

... ...
@@ -38,7 +38,8 @@ env:
38 38
   run_covr: 'true'
39 39
   run_pkgdown: 'true'
40 40
   has_RUnit: 'false'
41
-  cache-version: 'cache-v2'
41
+  cache-version: 'cache-v1'
42
+  run_docker: 'false'
42 43
 
43 44
 jobs:
44 45
   build-check:
... ...
@@ -51,9 +52,11 @@ jobs:
51 52
       fail-fast: false
52 53
       matrix:
53 54
         config:
54
-          - { os: ubuntu-latest, r: '4.2', bioc: '3.16', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
55
+          - { os: ubuntu-latest, r: '4.2', bioc: '3.16', cont: "bioconductor/bioconductor_docker:RELEASE_3_16", rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest" }
55 56
           - { os: macOS-latest, r: '4.2', bioc: '3.16'}
56 57
           - { os: windows-latest, r: '4.2', bioc: '3.16'}
58
+          ## Check https://github.com/r-lib/actions/tree/master/examples
59
+          ## for examples using the http-user-agent
57 60
     env:
58 61
       R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
59 62
       RSPM: ${{ matrix.config.rspm }}
... ...
@@ -76,19 +79,20 @@ jobs:
76 79
       ## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml
77 80
       ## If they update their steps, we will also need to update ours.
78 81
       - name: Checkout Repository
79
-        uses: actions/checkout@v2
82
+        uses: actions/checkout@v3
80 83
 
81 84
       ## R is already included in the Bioconductor docker images
82 85
       - name: Setup R from r-lib
83 86
         if: runner.os != 'Linux'
84
-        uses: r-lib/actions/setup-r@master
87
+        uses: r-lib/actions/setup-r@v2
85 88
         with:
86 89
           r-version: ${{ matrix.config.r }}
90
+          http-user-agent: ${{ matrix.config.http-user-agent }}
87 91
 
88 92
       ## pandoc is already included in the Bioconductor docker images
89 93
       - name: Setup pandoc from r-lib
90 94
         if: runner.os != 'Linux'
91
-        uses: r-lib/actions/setup-pandoc@master
95
+        uses: r-lib/actions/setup-pandoc@v2
92 96
 
93 97
       - name: Query dependencies
94 98
         run: |
... ...
@@ -96,9 +100,9 @@ jobs:
96 100
           saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
97 101
         shell: Rscript {0}
98 102
 
99
-      - name: Cache R packages
103
+      - name: Restore R package cache
100 104
         if: "!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'"
101
-        uses: actions/cache@v2
105
+        uses: actions/cache@v3
102 106
         with:
103 107
           path: ${{ env.R_LIBS_USER }}
104 108
           key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }}
... ...
@@ -106,7 +110,7 @@ jobs:
106 110
 
107 111
       - name: Cache R packages on Linux
108 112
         if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' "
109
-        uses: actions/cache@v2
113
+        uses: actions/cache@v3
110 114
         with:
111 115
           path: /home/runner/work/_temp/Library
112 116
           key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }}
... ...
@@ -136,6 +140,9 @@ jobs:
136 140
           ## For installing usethis's dependency gert
137 141
           brew install libgit2
138 142
 
143
+          ## Required for tcltk
144
+          brew install xquartz --cask
145
+
139 146
       - name: Install Windows system dependencies
140 147
         if: runner.os == 'Windows'
141 148
         run: |
... ...
@@ -150,7 +157,7 @@ jobs:
150 157
 
151 158
       - name: Set BiocVersion
152 159
         run: |
153
-          BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE)
160
+          BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE, force = TRUE)
154 161
         shell: Rscript {0}
155 162
 
156 163
       - name: Install dependencies pass 1
... ...
@@ -162,22 +169,37 @@ jobs:
162 169
           ## https://github.com/r-lib/remotes/issues/296
163 170
           ## Ideally, all dependencies should get installed in the first pass.
164 171
 
172
+          ## Set the repos source depending on the OS
173
+          ## Alternatively use https://storage.googleapis.com/bioconductor_docker/packages/
174
+          ## though based on https://bit.ly/bioc2021-package-binaries
175
+          ## the Azure link will be the main one going forward.
176
+          gha_repos <- if(
177
+              .Platform$OS.type == "unix" && Sys.info()["sysname"] != "Darwin"
178
+          ) c(
179
+              "AnVIL" = "https://bioconductordocker.blob.core.windows.net/packages/3.17/bioc",
180
+              BiocManager::repositories()
181
+              ) else BiocManager::repositories()
182
+
183
+          ## For running the checks
184
+          message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
185
+          install.packages(c("rcmdcheck", "BiocCheck"), repos = gha_repos)
186
+
165 187
           ## Pass #1 at installing dependencies
188
+          ## This pass uses AnVIL-powered fast binaries
189
+          ## details at https://github.com/nturaga/bioc2021-bioconductor-binaries
190
+          ## The speed gains only apply to the docker builds.
166 191
           message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****'))
167
-          remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE)
192
+          remotes::install_local(dependencies = TRUE, repos = gha_repos, build_vignettes = FALSE, upgrade = TRUE)
168 193
         continue-on-error: true
169 194
         shell: Rscript {0}
170 195
 
171 196
       - name: Install dependencies pass 2
172 197
         run: |
173 198
           ## Pass #2 at installing dependencies
199
+          ## This pass does not use AnVIL and will thus update any packages
200
+          ## that have seen been updated in Bioconductor
174 201
           message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****'))
175
-          remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE)
176
-
177
-          ## For running the checks
178
-          message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
179
-          remotes::install_cran("rcmdcheck")
180
-          BiocManager::install("BiocCheck")
202
+          remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE, force = TRUE)
181 203
         shell: Rscript {0}
182 204
 
183 205
       - name: Install BiocGenerics
... ...
@@ -196,7 +218,7 @@ jobs:
196 218
       - name: Install pkgdown
197 219
         if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
198 220
         run: |
199
-          remotes::install_cran("pkgdown")
221
+          remotes::install_github("r-lib/pkgdown")
200 222
         shell: Rscript {0}
201 223
 
202 224
       - name: Session info
... ...
@@ -209,10 +231,12 @@ jobs:
209 231
       - name: Run CMD check
210 232
         env:
211 233
           _R_CHECK_CRAN_INCOMING_: false
234
+          DISPLAY: 99.0
212 235
         run: |
236
+          options(crayon.enabled = TRUE)
213 237
           rcmdcheck::rcmdcheck(
214
-              args = c("--no-build-vignettes", "--no-manual", "--timings"),
215
-              build_args = c("--no-manual", "--no-resave-data"),
238
+              args = c("--no-manual", "--no-vignettes", "--timings"),
239
+              build_args = c("--no-manual", "--keep-empty-dirs", "--no-resave-data"),
216 240
               error_on = "warning",
217 241
               check_dir = "check"
218 242
           )
... ...
@@ -230,13 +254,15 @@ jobs:
230 254
         shell: Rscript {0}
231 255
 
232 256
       - name: Run BiocCheck
257
+        env:
258
+          DISPLAY: 99.0
233 259
         run: |
234 260
           BiocCheck::BiocCheck(
235 261
               dir('check', 'tar.gz$', full.names = TRUE),
236 262
               `quit-with-status` = TRUE,
237 263
               `no-check-R-ver` = TRUE,
238
-              `no-check-pkg-size` = TRUE,
239
-              `no-check-bioc-help` = TRUE
264
+              `no-check-bioc-help` = TRUE,
265
+              `no-check-pkg-size` = TRUE
240 266
           )
241 267
         shell: Rscript {0}
242 268
 
... ...
@@ -250,24 +276,80 @@ jobs:
250 276
         if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
251 277
         run: R CMD INSTALL .
252 278
 
253
-      - name: work around permission issue (since Apr 2022)
254
-        run: git config --global --add safe.directory /__w/Gviz/Gviz
255
-
256
-      - name: Deploy package
279
+      - name: Build pkgdown site
257 280
         if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
258
-        run: |
259
-          git config --local user.email "actions@github.com"
260
-          git config --local user.name "GitHub Actions"
261
-          Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)"
262
-        shell: bash {0}
281
+        run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
282
+        shell: Rscript {0}
263 283
         ## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE)
264 284
         ## at least one locally before this will work. This creates the gh-pages
265 285
         ## branch (erasing anything you haven't version controlled!) and
266 286
         ## makes the git history recognizable by pkgdown.
267 287
 
288
+      - name: Install deploy dependencies
289
+        if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
290
+        run: |
291
+          apt-get update && apt-get -y install rsync
292
+
293
+      - name: Deploy pkgdown site to GitHub pages 🚀
294
+        if: github.ref == 'refs/heads/master' && env.run_pkgdown == 'true' && runner.os == 'Linux'
295
+        uses: JamesIves/github-pages-deploy-action@releases/v4
296
+        with:
297
+          clean: false
298
+          branch: gh-pages
299
+          folder: docs
300
+
268 301
       - name: Upload check results
269 302
         if: failure()
270 303
         uses: actions/upload-artifact@master
271 304
         with:
272 305
           name: ${{ runner.os }}-biocversion-devel-r-devel-results
273 306
           path: check
307
+
308
+
309
+  ## Code adapted from
310
+  ## https://github.com/waldronlab/cBioPortalData/blob/e0440a4445f0cc731e426363a76faa22ee5e0f9d/.github/workflows/devel_check_dock.yml#L65-L92
311
+  docker-build-and-push:
312
+    runs-on: ubuntu-latest
313
+    needs: build-check
314
+    steps:
315
+      - name: Checkout Repository
316
+        if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/master' "
317
+        uses: actions/checkout@v3
318
+
319
+      - name: Register repo name
320
+        if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/master' "
321
+        id: reg_repo_name
322
+        run: |
323
+          echo CONT_IMG_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
324
+
325
+      - name: Set up QEMU
326
+        if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/master' "
327
+        uses: docker/setup-qemu-action@v2
328
+
329
+      - name: Set up Docker Buildx
330
+        if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/master' "
331
+        uses: docker/setup-buildx-action@v2
332
+
333
+      - name: Login to Docker Hub
334
+        if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/master' "
335
+        uses: docker/login-action@v2
336
+        with:
337
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
338
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
339
+      ## Note that DOCKERHUB_TOKEN is really a token for your dockerhub
340
+      ## account, not your actual dockerhub account password. You can get it
341
+      ## from https://hub.docker.com/settings/security.
342
+      ## Check https://github.com/docker/build-push-action/tree/v4.0.0
343
+      ## for more details.
344
+      ## Alternatively, try checking
345
+      ## https://seandavi.github.io/BuildABiocWorkshop/articles/HOWTO_BUILD_WORKSHOP.html.
346
+
347
+      - name: Build and Push Docker
348
+        if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/master' && success()"
349
+        uses: docker/build-push-action@v4
350
+        with:
351
+          context: .
352
+          push: true
353
+          tags: >
354
+            ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:latest,
355
+            ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel