Skip to content

Commit 0d81542

Browse files
committed
adding Bioconductor dependency for github.io
1 parent b306b04 commit 0d81542

File tree

2 files changed

+378
-4
lines changed

2 files changed

+378
-4
lines changed

.github/workflows/check-bioc.yml

Lines changed: 374 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,374 @@
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: 'false'
38+
run_covr: 'false'
39+
run_pkgdown: 'false'
40+
has_RUnit: 'false'
41+
cache-version: 'cache-v1'
42+
run_docker: 'false'
43+
bioc_version: 'bioc-release'
44+
## Valid options are:
45+
## "bioc-release"
46+
## "bioc-devel"
47+
## or a specific number like "3.20"
48+
49+
jobs:
50+
bioc-config:
51+
runs-on: ubuntu-latest
52+
outputs:
53+
matrix: ${{ steps.set-bioc-matrix.outputs.matrix }}
54+
steps:
55+
## Adapted from
56+
## https://runs-on.com/github-actions/the-matrix-strategy/#dynamic-matrix-generation
57+
- id: set-bioc-matrix
58+
run: |
59+
bioc=$(curl -L https://bioconductor.org/config.yaml)
60+
if [[ "$bioc_version" == "bioc-release" ]]; then
61+
echo "Finding the latest BioC release version and the corresponding R version"
62+
biocversion=$(echo "$bioc" | grep "release_version: " | grep -Eo "[0-9]{1}\.[0-9]{2}")
63+
rversion=$(echo "$bioc" | grep "r_version_associated_with_release: " | grep -Eo "[0-9]{1}\.[0-9]{1}")
64+
biocmajor=$(echo "$biocversion" | cut -c 1-1)
65+
biocminor=$(echo "$biocversion" | cut -c 3-4)
66+
bioccont=$(echo "bioconductor/bioconductor_docker:RELEASE_${biocmajor}_${biocminor}")
67+
elif [[ "$bioc_version" == "bioc-devel" ]]; then
68+
echo "Finding the latest BioC devel version and the corresponding R version"
69+
biocversion=$(echo "$bioc" | grep "devel_version: " | grep -Eo "[0-9]{1}\.[0-9]{2}")
70+
rversion_release=$(echo "$bioc" | grep "r_version_associated_with_release: " | grep -Eo "[0-9]{1}\.[0-9]{1}")
71+
rversion_devel=$(echo "$bioc" | grep "r_version_associated_with_devel: " | grep -Eo "[0-9]{1}\.[0-9]{1}")
72+
if [[ "$rversion_release" == "$rversion_devel" ]]; then
73+
rversion=$(echo "$rversion_devel")
74+
else
75+
rversion="devel"
76+
fi
77+
bioccont="bioconductor/bioconductor_docker:devel"
78+
else
79+
echo "Finding the the R version for bioc version ${bioc_version}"
80+
biocversion=$(echo "$bioc_version")
81+
rversion=$(echo "$bioc" | sed -En "/r_ver_for_bioc_ver/,/release_dates/p" | grep "$bioc_version\":" | grep -Eo ": \"[0-9]{1}\.[0-9]{1}" | grep -Eo "[0-9]{1}\.[0-9]{1}")
82+
biocmajor=$(echo "$biocversion" | cut -c 1-1)
83+
biocminor=$(echo "$biocversion" | cut -c 3-4)
84+
bioccont=$(echo "bioconductor/bioconductor_docker:RELEASE_${biocmajor}_${biocminor}")
85+
fi
86+
echo "Found these settings:"
87+
echo "Bioconductor version: $biocversion, R version: $rversion, Bioconductor docker name: $bioccont"
88+
echo "matrix={ \"config\": [{\"os\" : \"ubuntu-latest\", \"r\" : \"${rversion}\", \"bioc\" : \"${biocversion}\", \"cont\" : \"${bioccont}\"} , {\"os\" : \"macOS-latest\", \"r\" : \"${rversion}\", \"bioc\" : \"${biocversion}\"} , {\"os\" : \"windows-latest\", \"r\" : \"${rversion}\", \"bioc\" : \"${biocversion}\" }] }" >> "$GITHUB_OUTPUT"
89+
## If an OS is failing and you don't want to test it, manually remove it from the 'matrix' JSON entries above
90+
91+
build-check:
92+
needs: bioc-config
93+
strategy:
94+
fail-fast: false
95+
matrix: ${{fromJson(needs.bioc-config.outputs.matrix)}}
96+
runs-on: ${{ matrix.config.os }}
97+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
98+
container: ${{ matrix.config.cont }}
99+
env:
100+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
101+
NOT_CRAN: true
102+
TZ: UTC
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
105+
106+
steps:
107+
108+
## Most of these steps are the same as the ones in
109+
## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml
110+
## If they update their steps, we will also need to update ours.
111+
- name: Checkout Repository
112+
uses: actions/checkout@v3
113+
114+
## R is already included in the Bioconductor docker images
115+
- name: Setup R from r-lib
116+
if: runner.os != 'Linux'
117+
uses: r-lib/actions/setup-r@v2
118+
with:
119+
r-version: ${{ matrix.config.r }}
120+
http-user-agent: ${{ matrix.config.http-user-agent }}
121+
122+
## pandoc is already included in the Bioconductor docker images
123+
- name: Setup pandoc from r-lib
124+
if: runner.os != 'Linux'
125+
uses: r-lib/actions/setup-pandoc@v2
126+
127+
## Create the path that will be used for caching packages on Linux
128+
- name: Create R_LIBS_USER on Linux
129+
if: runner.os == 'Linux'
130+
run: |
131+
R_LIBS_USER=/__w/_temp/Library
132+
echo "R_LIBS_USER=$R_LIBS_USER" >> "$GITHUB_ENV"
133+
mkdir -p $R_LIBS_USER
134+
135+
## Use cached R packages
136+
- name: Restore R package cache
137+
if: "!contains(github.event.head_commit.message, '/nocache')"
138+
uses: actions/cache@v4
139+
with:
140+
path: ${{ env.R_LIBS_USER }}
141+
key: ${{ matrix.config.os }}-${{ matrix.config.r }}-${{ matrix.config.bioc }}-${{ inputs.cache-version }}
142+
restore-keys: ${{ matrix.config.os }}-${{ matrix.config.r }}-${{ matrix.config.bioc }}--${{ inputs.cache-version }}
143+
144+
## remotes is needed for isntalling the Linux system dependencies
145+
## as well as other R packages later on.
146+
- name: Install remotes
147+
run: |
148+
message(paste('****', Sys.time(), 'installing remotes ****'))
149+
install.packages('remotes')
150+
shell: Rscript {0}
151+
152+
## This will work again once https://github.com/r-lib/remotes/commit/0e4e23051041d9f1b15a5ab796defec31af6190d
153+
## makes it to the CRAN version of remotes
154+
155+
# - name: Install Linux system dependencies
156+
# if: runner.os == 'Linux'
157+
# run: |
158+
# sysreqs=$(Rscript -e 'cat("apt-get update -y && apt-get install -y", paste(gsub("apt-get install -y ", "", remotes::system_requirements("ubuntu", "24.04")), collapse = " "))')
159+
# echo $sysreqs
160+
# sudo -s eval "$sysreqs"
161+
162+
- name: Install macOS system dependencies
163+
if: matrix.config.os == 'macOS-latest'
164+
run: |
165+
## Enable installing XML from source if needed
166+
brew install libxml2
167+
echo "XML_CONFIG=/usr/local/opt/libxml2/bin/xml2-config" >> $GITHUB_ENV
168+
169+
## Required to install magick as noted at
170+
## https://github.com/r-lib/usethis/commit/f1f1e0d10c1ebc75fd4c18fa7e2de4551fd9978f#diff-9bfee71065492f63457918efcd912cf2
171+
brew install imagemagick@6
172+
173+
## For textshaping, required by ragg, and required by pkgdown
174+
brew install harfbuzz fribidi
175+
176+
## For installing usethis's dependency gert
177+
brew install libgit2
178+
179+
## Required for tcltk
180+
brew install xquartz --cask
181+
182+
- name: Install Windows system dependencies
183+
if: runner.os == 'Windows'
184+
run: |
185+
## Edit below if you have any Windows system dependencies
186+
shell: Rscript {0}
187+
188+
- name: Install BiocManager
189+
run: |
190+
message(paste('****', Sys.time(), 'installing BiocManager ****'))
191+
remotes::install_cran("BiocManager")
192+
shell: Rscript {0}
193+
194+
- name: Set BiocVersion
195+
run: |
196+
BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE, force = TRUE)
197+
shell: Rscript {0}
198+
199+
- name: Install dependencies pass 1
200+
run: |
201+
## Try installing the package dependencies in steps. First the local
202+
## dependencies, then any remaining dependencies to avoid the
203+
## issues described at
204+
## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html
205+
## https://github.com/r-lib/remotes/issues/296
206+
## Ideally, all dependencies should get installed in the first pass.
207+
208+
## For running the checks
209+
message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****'))
210+
install.packages(c("rcmdcheck", "BiocCheck"), repos = BiocManager::repositories())
211+
212+
## Pass #1 at installing dependencies
213+
message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****'))
214+
remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = FALSE, upgrade = TRUE)
215+
continue-on-error: true
216+
shell: Rscript {0}
217+
218+
- name: Install dependencies pass 2
219+
run: |
220+
## Pass #2 at installing dependencies
221+
message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****'))
222+
remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE, force = TRUE)
223+
shell: Rscript {0}
224+
225+
- name: Install BiocGenerics
226+
if: env.has_RUnit == 'true'
227+
run: |
228+
## Install BiocGenerics
229+
BiocManager::install("BiocGenerics")
230+
shell: Rscript {0}
231+
232+
- name: Install covr
233+
if: github.ref == 'refs/heads/devel' && env.run_covr == 'true' && runner.os == 'Linux'
234+
run: |
235+
remotes::install_cran("covr")
236+
shell: Rscript {0}
237+
238+
- name: Install pkgdown
239+
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
240+
run: |
241+
remotes::install_cran("pkgdown")
242+
shell: Rscript {0}
243+
244+
- name: Session info
245+
run: |
246+
options(width = 100)
247+
pkgs <- installed.packages()[, "Package"]
248+
sessioninfo::session_info(pkgs, include_base = TRUE)
249+
shell: Rscript {0}
250+
251+
- name: Run CMD check
252+
env:
253+
_R_CHECK_CRAN_INCOMING_: false
254+
DISPLAY: 99.0
255+
run: |
256+
options(crayon.enabled = TRUE)
257+
rcmdcheck::rcmdcheck(
258+
args = c("--no-manual", "--no-vignettes", "--timings"),
259+
build_args = c("--no-manual", "--keep-empty-dirs", "--no-resave-data"),
260+
error_on = "warning",
261+
check_dir = "check"
262+
)
263+
shell: Rscript {0}
264+
265+
## Might need an to add this to the if: && runner.os == 'Linux'
266+
- name: Reveal testthat details
267+
if: env.has_testthat == 'true'
268+
run: find . -name testthat.Rout -exec cat '{}' ';'
269+
270+
- name: Run RUnit tests
271+
if: env.has_RUnit == 'true'
272+
run: |
273+
BiocGenerics:::testPackage()
274+
shell: Rscript {0}
275+
276+
- name: Run BiocCheck
277+
env:
278+
DISPLAY: 99.0
279+
run: |
280+
BiocCheck::BiocCheck(
281+
dir('check', 'tar.gz$', full.names = TRUE),
282+
`quit-with-status` = TRUE,
283+
`no-check-R-ver` = TRUE,
284+
`no-check-bioc-help` = TRUE
285+
)
286+
shell: Rscript {0}
287+
288+
- name: Test coverage
289+
if: github.ref == 'refs/heads/devel' && env.run_covr == 'true' && runner.os == 'Linux'
290+
run: |
291+
covr::codecov(coverage = covr::package_coverage(type = "all"))
292+
shell: Rscript {0}
293+
294+
- name: Install package
295+
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
296+
run: R CMD INSTALL .
297+
298+
- name: Build pkgdown site
299+
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
300+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
301+
shell: Rscript {0}
302+
## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE)
303+
## at least one locally before this will work. This creates the gh-pages
304+
## branch (erasing anything you haven't version controlled!) and
305+
## makes the git history recognizable by pkgdown.
306+
307+
- name: Install deploy dependencies
308+
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
309+
run: |
310+
apt-get update && apt-get -y install rsync
311+
312+
- name: Deploy pkgdown site to GitHub pages 🚀
313+
if: github.ref == 'refs/heads/devel' && env.run_pkgdown == 'true' && runner.os == 'Linux'
314+
uses: JamesIves/github-pages-deploy-action@releases/v4
315+
with:
316+
clean: false
317+
branch: gh-pages
318+
folder: docs
319+
320+
- name: Upload check results
321+
if: failure()
322+
uses: actions/upload-artifact@master
323+
with:
324+
name: ${{ runner.os }}-${{ matrix.config.r }}-${{ matrix.config.bioc }}-results
325+
path: check
326+
327+
328+
## Code adapted from
329+
## https://github.com/waldronlab/cBioPortalData/blob/e0440a4445f0cc731e426363a76faa22ee5e0f9d/.github/workflows/devel_check_dock.yml#L65-L92
330+
docker-build-and-push:
331+
runs-on: ubuntu-latest
332+
needs: build-check
333+
steps:
334+
- name: Checkout Repository
335+
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
336+
uses: actions/checkout@v3
337+
338+
- name: Register repo name
339+
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
340+
id: reg_repo_name
341+
run: |
342+
echo CONT_IMG_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
343+
344+
- name: Set up QEMU
345+
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
346+
uses: docker/setup-qemu-action@v2
347+
348+
- name: Set up Docker Buildx
349+
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
350+
uses: docker/setup-buildx-action@v2
351+
352+
- name: Login to Docker Hub
353+
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
354+
uses: docker/login-action@v2
355+
with:
356+
username: ${{ secrets.DOCKERHUB_USERNAME }}
357+
password: ${{ secrets.DOCKERHUB_TOKEN }}
358+
## Note that DOCKERHUB_TOKEN is really a token for your dockerhub
359+
## account, not your actual dockerhub account password. You can get it
360+
## from https://hub.docker.com/settings/security.
361+
## Check https://github.com/docker/build-push-action/tree/v4.0.0
362+
## for more details.
363+
## Alternatively, try checking
364+
## https://seandavi.github.io/BuildABiocWorkshop/articles/HOWTO_BUILD_WORKSHOP.html.
365+
366+
- name: Build and Push Docker
367+
if: "!contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel' && success()"
368+
uses: docker/build-push-action@v4
369+
with:
370+
context: .
371+
push: true
372+
tags: >
373+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:latest,
374+
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel

0 commit comments

Comments
 (0)