update vignettes (part 2) #274
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
- devel | |
name: check-bioc | |
jobs: | |
build-check: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | |
container: ${{ matrix.config.cont }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { os: ubuntu-latest, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
RSPM: ${{ matrix.config.rspm }} | |
NOT_CRAN: true | |
TZ: UTC | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Setup R from r-lib | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r }} | |
- name: Setup pandoc from r-lib | |
uses: r-lib/actions/setup-pandoc@v2 | |
- name: Query dependencies | |
uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
extra-packages: any::rcmdcheck | |
needs: check | |
- name: Install Linux system dependencies | |
if: runner.os == 'Linux' | |
run: | | |
Rscript -e 'install.packages("remotes")' | |
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 = " "))') | |
echo $sysreqs | |
sudo -s eval "$sysreqs" | |
# SpatialExperiment (magick) dependency | |
sudo apt-get install -y libmagick++-dev | |
- name: Install BiocManager | |
run: | | |
message(paste('****', Sys.time(), 'installing BiocManager ****')) | |
remotes::install_cran("BiocManager") | |
shell: Rscript {0} | |
- name: Set BiocVersion | |
run: | | |
BiocManager::install(ask = FALSE) | |
shell: Rscript {0} | |
- name: Install remaining dependencies pass 1 | |
run: | | |
## Try installing the package dependencies in steps. First the local | |
## dependencies, then any remaining dependencies to avoid the | |
## issues described at | |
## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html | |
## https://github.com/r-lib/remotes/issues/296 | |
## Ideally, all dependencies should get installed in the first pass. | |
## Pass #1 at installing dependencies | |
message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****')) | |
remotes::install_deps(dependencies = TRUE, repos = BiocManager::repositories(), upgrade = "always") | |
continue-on-error: true | |
shell: Rscript {0} | |
- name: Install remaining dependencies pass 2 | |
run: | | |
## Pass #2 at installing dependencies | |
message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****')) | |
remotes::install_deps(dependencies = TRUE, repos = BiocManager::repositories(), upgrade = "always") | |
## For producing vignette pdf output | |
remotes::install_cran(c("tinytex", "igraph", "magick")) | |
tinytex::install_tinytex() | |
tinytex::tlmgr_update() | |
tinytex::tlmgr_install("pdfcrop") | |
## For running the checks | |
message(paste('****', Sys.time(), 'installing BiocCheck ****')) | |
BiocManager::install("BiocCheck") | |
shell: Rscript {0} | |
- name: Session info | |
run: | | |
options(width = 100) | |
pkgs <- installed.packages()[, "Package"] | |
sessioninfo::session_info(pkgs, include_base = TRUE) | |
shell: Rscript {0} | |
- name: Run BiocCheck | |
run: | | |
BiocCheck::BiocCheck( | |
`quit-with-status` = TRUE, | |
`no-check-R-ver` = TRUE, | |
`no-check-bioc-help` = TRUE | |
) | |
shell: Rscript {0} | |
# - name: Test coverage | |
# if: github.ref == 'refs/heads/master' && runner.os == 'Linux' | |
# run: | | |
# covr::codecov() | |
# shell: Rscript {0} | |
- name: Install package | |
if: github.ref == 'refs/heads/master' && runner.os == 'Linux' | |
run: R CMD INSTALL . | |
- name: Set up package deployment | |
if: github.ref == 'refs/heads/master' && runner.os == 'Linux' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
shell: bash {0} | |
## Changing package deployment to make the necessary changes to the vignette files | |
- name: Deploy package | |
if: github.ref == 'refs/heads/master' && runner.os == 'Linux' | |
run: | | |
BiocManager::install(c("decoupleR", "SpatialExperiment"), ask = FALSE) | |
install.packages(c("pkgdown", "sctransform")) | |
install.packages(c("stringi", "ridge"), type="source", repos="https://cloud.r-project.org/") | |
BiocManager::install("OmnipathR", ask=FALSE) | |
install.packages(c("janitor", "reticulate", "Seurat", "SeuratObject")) | |
## modified from pkgdown::deploy_to_branch | |
deploy_to_branch_mod <- function(pkg = ".", commit_message = pkgdown:::construct_commit_message(pkg), | |
clean = TRUE, branch = "gh-pages", remote = "origin", github_pages = (branch == | |
"gh-pages"), ...) | |
{ | |
dest_dir <- fs::dir_create(fs::file_temp()) | |
on.exit(fs::dir_delete(dest_dir)) | |
if (!pkgdown:::git_has_remote_branch(remote, branch)) { | |
old_branch <- pkgdown:::git_current_branch() | |
pkgdown:::git("checkout", "--orphan", branch) | |
pkgdown:::git("rm", "-rf", "--quiet", ".") | |
pkgdown:::git("commit", "--allow-empty", "-m", sprintf("init %s branch", | |
branch)) | |
pkgdown:::git("push", remote, paste0("HEAD:", branch)) | |
pkgdown:::git("checkout", old_branch) | |
} | |
pkgdown:::git("remote", "set-branches", remote, branch) | |
pkgdown:::git("fetch", remote, branch) | |
pkgdown:::github_worktree_add(dest_dir, remote, branch) | |
on.exit(pkgdown:::github_worktree_remove(dest_dir), add = TRUE) | |
pkg <- pkgdown::as_pkgdown(pkg, override = list(destination = dest_dir)) | |
if (clean) { | |
cli::rule("Cleaning files from old site", line = 1) | |
pkgdown::clean_site(pkg) | |
} | |
pkgdown::build_site(pkg, devel = FALSE, preview = FALSE, install = FALSE, | |
...) | |
unlink(paste0(dest_dir, c("/reference/.misty.temp", "/reference/results")), recursive = TRUE) | |
if (github_pages) { | |
pkgdown:::build_github_pages(pkg) | |
} | |
pkgdown:::github_push(dest_dir, commit_message, remote, branch) | |
invisible() | |
} | |
pkg <- pkgdown::as_pkgdown(pkg = ".") | |
vignettes <- pkg$vignettes$file_in | |
original <- purrr::map(vignettes, function(vignette){ | |
content <- rmarkdown:::partition_yaml_front_matter(xfun::read_utf8(vignette)) | |
rmd.front <- content$front_matter | |
from.to <- (grep("(output:|vignette:)", rmd.front)) | |
rmd.front <- rmd.front[-seq(from.to[1]+1, from.to[2]-1)] | |
rmd.front[from.to[1]] <- "output:\n BiocStyle::html_document:\n toc_float: true\n df_print: kable" | |
rmd.front <- sub("- Jožef", " <br/>Jožef", rmd.front) | |
rmd.body <- content$body | |
xfun::write_utf8(c(rmd.front, rmd.body), vignette) | |
content | |
}) | |
deploy_to_branch_mod(new_process = FALSE) | |
purrr::walk2(original, vignettes, ~xfun::write_utf8(c(.x$front_matter, .x$body), .y)) | |
shell: Rscript {0} | |
##Dockerize | |
- | |
name: Login to DockerHub | |
if: "!contains(github.event.head_commit.message, '/nodocker') && runner.os == 'Linux'" | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Build and push master | |
if: "!contains(github.event.head_commit.message, '/nodocker') && runner.os == 'Linux' && github.ref == 'refs/heads/master'" | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: tanevski/mistyr:master,tanevski/mistyr:latest | |
- | |
name: Build and push other | |
if: "!contains(github.event.head_commit.message, '/nodocker') && runner.os == 'Linux' && github.ref == 'refs/heads/devel'" | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: tanevski/mistyr:devel | |