Skip to content

Instantly share code, notes, and snippets.

@lcolladotor
Last active April 18, 2020 21:01
Show Gist options
  • Save lcolladotor/bfe6e309fc13c219dfd8f6616a681013 to your computer and use it in GitHub Desktop.
Save lcolladotor/bfe6e309fc13c219dfd8f6616a681013 to your computer and use it in GitHub Desktop.
## Read more about GitHub actions at
## https://www.tidyverse.org/blog/2020/04/usethis-1-6-0/
## which will lead you to
## https://github.com/r-lib/actions/tree/master/examples.
## Also check the reference manual at
## https://help.github.com/en/actions
## I also found this work in progress book
## https://ropenscilabs.github.io/actions_sandbox/
## as well as these two other GitHub actions config files
## https://github.com/seandavi/BiocActions/blob/master/.github/workflows/main.yml
## https://github.com/csoneson/dreval/blob/master/.github/workflows/R-CMD-check.yaml
## See also this blog post
## https://seandavi.github.io/post/learning-github-actions/
on:
push:
branches:
- master
- 'RELEASE_*'
pull_request:
branches:
- master
- 'RELEASE_*'
name: R-CMD-check-bioc
jobs:
define-docker-info:
runs-on: ubuntu-latest
outputs:
imagename: ${{ steps.findinfo.outputs.imagename }}
biocversion: ${{ steps.findinfo.outputs.biocversion }}
steps:
- id: findinfo
run: |
## Find what branch we are working on
if echo "$GITHUB_REF" | grep -q "master"; then
biocversion="devel"
elif echo "$GITHUB_REF" | grep -q "RELEASE_"; then
biocversion="$(basename -- $GITHUB_REF | tr '[:upper:]' '[:lower:]')"
fi
## Define the image name and print the info
imagename="bioconductor/bioconductor_docker:${biocversion}"
echo $imagename
echo $biocversion
## Save the info for the next job
echo "::set-output name=imagename::${imagename}"
echo "::set-output name=biocversion::${biocversion}"
R-CMD-check-bioc:
runs-on: ubuntu-latest
needs: define-docker-info
name: ubuntu-latest (r-biocdocker bioc-${{ needs.define-docker-info.outputs.biocversion }})
outputs:
rversion: ${{ steps.findrversion.outputs.rversion }}
biocversionnum: ${{ steps.findrversion.outputs.biocversionnum }}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
TZ: UTZ
NOT_CRAN: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
container:
image: ${{ needs.define-docker-info.outputs.imagename }}
volumes:
- /home/runner/work/_temp/Library:/usr/local/lib/R/host-site-library
steps:
- uses: actions/checkout@v2
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}
- name: Cache R packages
uses: actions/cache@v1
with:
path: /home/runner/work/_temp/Library
key: ${{ runner.os }}-r-biocdocker-bioc-${{ needs.define-docker-info.outputs.biocversion }}-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-r-biocdocker-bioc-${{ needs.define-docker-info.outputs.biocversion }}-
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
remotes::install_cran("BiocManager")
BiocManager::install("BiocCheck")
## Copy all the installed packages to a location where BiocCheck
## will find them later. This is needed when running biocdocker
## with the shared volume.
libs <- .libPaths()
message(paste(Sys.time(), 'current R library paths:'))
print(libs)
if(length(libs) > 1) {
sapply(dir(libs[1], full.names = TRUE), file.copy, to = libs[2], recursive = TRUE)
}
shell: Rscript {0}
- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: |
rcmdcheck::rcmdcheck(
args = c("--no-build-vignettes", "--no-manual", "--timings"),
build_args = c("--no-manual", "--no-resave-data"),
error_on = "warning",
check_dir = "check"
)
shell: Rscript {0}
- name: Reveal testthat details
run: find . -name testthat.Rout -exec cat '{}' ';'
- name: BiocCheck
run: |
R CMD BiocCheck --no-check-R-ver --no-check-bioc-help check/*.tar.gz
## For more options check http://bioconductor.org/packages/release/bioc/vignettes/BiocCheck/inst/doc/BiocCheck.html
- name: Install covr and pkgdown
if: github.ref == 'refs/heads/master'
run: |
if (!requireNamespace("covr", quietly = TRUE))
remotes::install_cran("covr")
if (!requireNamespace("pkgdown", quietly = TRUE))
remotes::install_dev("pkgdown")
shell: Rscript {0}
- name: Install package
if: github.ref == 'refs/heads/master'
run: R CMD INSTALL .
- name: Deploy package
if: github.ref == 'refs/heads/master'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)"
shell: bash {0}
## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE)
## at least one locally before this will work. This creates the gh-pages
## branch (erasing anything you haven't version controlled!) and
## makes the git history recognizable by pkgdown.
- name: Test coverage
if: github.ref == 'refs/heads/master'
run: |
covr::codecov()
shell: Rscript {0}
- id: findrversion
run: |
## Find what branch we are working on
if echo "$GITHUB_REF" | grep -q "master"; then
biocversion="devel"
elif echo "$GITHUB_REF" | grep -q "RELEASE_"; then
biocversion="release"
fi
## Define the R and Bioconductor version numbers
biocversionnum=$(Rscript -e "info <- BiocManager:::.version_map_get_online('https://bioconductor.org/config.yaml'); res <- subset(info, BiocStatus == '${biocversion}')[, 'Bioc']; cat(as.character(res))")
rversion=$(Rscript -e "info <- BiocManager:::.version_map_get_online('https://bioconductor.org/config.yaml'); res <- subset(info, BiocStatus == '${biocversion}')[, 'R']; cat(as.character(res))")
## I might need this for now until R 4.0 is out (try without it first)
if echo "$rversion" | grep -q "4.0"; then
rversion="devel"
fi
## Print the results
echo $biocversion
echo $biocversionnum
echo $rversion
## Save the info for the next job
echo "::set-output name=rversion::${rversion}"
echo "::set-output name=biocversionnum::${biocversionnum}"
shell:
bash {0}
- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r-biocdocker-bioc-${{ needs.define-docker-info.outputs.biocversion }}-results
path: check
R-CMD-check-r-lib:
runs-on: ${{ matrix.config.os }}
needs: [define-docker-info, R-CMD-check-bioc]
name: ${{ matrix.config.os }} (r-${{ needs.R-CMD-check-bioc.outputs.rversion }} bioc-${{ needs.define-docker-info.outputs.biocversion }})
strategy:
fail-fast: false
matrix:
config:
# ## Un-comment in case you also want to run other versions
# - {os: windows-latest}
- {os: macOS-latest}
# - {os: ubuntu-16.04, rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
BIOCVERSIONNUM: ${{ needs.R-CMD-check-bioc.outputs.biocversionnum }}
steps:
- uses: actions/checkout@v2
- name: Setup R from r-lib
uses: r-lib/actions/setup-r@master
with:
r-version: ${{ needs.R-CMD-check-bioc.outputs.rversion }}
- name: Setup pandoc from r-lib
uses: r-lib/actions/setup-pandoc@master
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}
- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ needs.R-CMD-check-bioc.outputs.rversion }}-bioc-${{ needs.define-docker-info.outputs.biocversion }}-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-r-${{ needs.R-CMD-check-bioc.outputs.rversion }}-bioc-${{ needs.define-docker-info.outputs.biocversion }}-
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install macOS system dependencies
if: matrix.config.os == 'macOS-latest' && needs.R-CMD-check-bioc.outputs.rversion == 'devel'
# the xml2 thing is a hack / experiment
run: |
brew install imagemagick@6
Rscript -e "remotes::install_github('r-lib/xml2')"
- name: Install BiocManager
run: |
remotes::install_cran("BiocManager")
shell: Rscript {0}
- name: Set BiocVersion
run: |
BiocManager::install(version = Sys.getenv('BIOCVERSIONNUM'))
shell: Rscript {0}
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
BiocManager::install("BiocCheck")
shell: Rscript {0}
- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: |
rcmdcheck::rcmdcheck(
args = c("--no-build-vignettes", "--no-manual", "--timings"),
build_args = c("--no-manual", "--no-resave-data"),
error_on = "warning",
check_dir = "check"
)
shell: Rscript {0}
- name: Reveal testthat details
run: find . -name testthat.Rout -exec cat '{}' ';'
- name: BiocCheck
run: |
R CMD BiocCheck --no-check-R-ver --no-check-bioc-help check/*.tar.gz
## For more options check http://bioconductor.org/packages/release/bioc/vignettes/BiocCheck/inst/doc/BiocCheck.html
- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r-${{ needs.R-CMD-check-bioc.outputs.rversion }}-bioc-${{ needs.define-docker-info.outputs.biocversion }}-results
path: check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment