Skip to content

Commit

Permalink
upgrade docker steps
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Oct 12, 2023
1 parent 7ce4579 commit 19a7bd1
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 57 deletions.
127 changes: 78 additions & 49 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ inputs:
description: >
Docker container registry.
Options include:
- ghcr.io/ : [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry}{GitHub Container Registry)
- docker.io/ : [DockerHub](https://hub.docker.com/)
default: 'ghcr.io/'
- ghcr.io : [GitHub Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry}{GitHub Container Registry)
- docker.io : [DockerHub](https://hub.docker.com/)
default: 'ghcr.io'
docker_user:
description: >
DockerHub username.
Expand Down Expand Up @@ -154,7 +154,7 @@ inputs:
runs:
using: 'composite'
steps:
- name: Set GitHub environment variables ️🌎
- name: 🌎 Set environment variables
run: |
echo "GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}" >> $GITHUB_ENV
echo "RGL_USE_NULL=TRUE" >> $GITHUB_ENV
Expand All @@ -168,7 +168,7 @@ runs:
uses: runforesight/workflow-telemetry-action@v1
continue-on-error: true

## Setup Miniconda 🐍
## 🐍 Setup Miniconda
- name: Setup Miniconda
if: inputs.miniforge_variant != 'false'
uses: conda-incubator/setup-miniconda@v2
Expand All @@ -183,7 +183,7 @@ runs:

## Set the R library to the directory matching the
## R packages cache step further below when running on Docker (Linux).
- name: Set R library home on Linux πŸ“š
- name: πŸ“š Set R library home on Linux
if: runner.os == 'Linux'
run: |
mkdir -p /__w/_temp/Library
Expand All @@ -194,51 +194,51 @@ runs:
## Most of these steps are the same as the ones in
## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml
## If they update their steps, we will also need to update ours.
- name: Checkout repository ⏬
- name: ⏬ Checkout repository
uses: actions/checkout@v4

## R/Bioc are already installed on the Bioc Docker container,
## and reinstalling them causes errors.
- name: Setup R and Bioconductor πŸ› 
- name: πŸ›  Setup R and Bioconductor
if: runner.os != 'Linux'
uses: grimbough/bioc-actions/setup-bioc@v1
with:
bioc-version: ${{ matrix.config.bioc }}

## pandoc is already included in the Bioconductor docker images
- name: Install Pandoc πŸ› 
- name: πŸ›  Install Pandoc
if: inputs.pandoc_version != 'false' && runner.os != 'Linux'
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: ${{ inputs.pandoc_version }}

- name: Query dependencies ❔
- name: ❔ Query dependencies
run: |
options(crayon.enabled = TRUE)
install.packages('remotes')
remotes::install_github("r-lib/remotes")
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}

- name: Restore R package cache 🏦
- name: 🏦 Restore R package cache
if: |
!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'
!contains(github.event.head_commit.message, '[nocache]') && runner.os != 'Linux'
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ inputs.cache_version }}-${{ runner.os }}-biocversion-${{ matrix.config.bioc }}-r-${{ matrix.config.r }}-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ inputs.cache_version }}-${{ runner.os }}-biocversion-${{ matrix.config.bioc }}-r-${{ matrix.config.r }}-

- name: Cache R packages on Linux 🏦
- name: 🏦 Cache R packages on Linux
if: |
!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux'
!contains(github.event.head_commit.message, '[nocache]') && runner.os == 'Linux'
uses: actions/cache@v3
with:
path: /home/runner/work/_temp/Library
key: ${{ inputs.cache_version }}-${{ runner.os }}-biocversion-${{ matrix.config.bioc }}-r-${{ matrix.config.r }}-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ inputs.cache_version }}-${{ runner.os }}-biocversion-${{ matrix.config.bioc }}-r-${{ matrix.config.r }}-

- name: Install Linux system dependencies πŸ› 
- name: πŸ›  Install Linux system dependencies
if: runner.os == 'Linux'
run: |
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 = " "))')
Expand All @@ -247,7 +247,7 @@ runs:
sudo apt-get install -y qpdf rsync
shell: bash {0}

- name: Install macOS system dependencies πŸ› 
- name: πŸ›  Install macOS system dependencies
if: runner.os == 'macOS'
run: |
#### --- Justifications for each package --- ####
Expand Down Expand Up @@ -276,21 +276,21 @@ runs:
echo "XML_CONFIG=/usr/local/opt/libxml2/bin/xml2-config" >> $GITHUB_ENV
shell: bash {0}

- name: Install Windows system dependencies πŸ› 
- name: πŸ›  Install Windows system dependencies
if: inputs.has_latex == 'true' && runner.os == 'Windows'
run: |
#### npm ####
npm install curl
shell: pwsh {0}

- name: Install latex πŸ› 
- name: πŸ›  Install latex
if: inputs.has_latex == 'true'
uses: r-lib/actions/setup-tinytex@v2
env:
TINYTEX_INSTALLER: ${{ inputs.tinytex_installer }}
TINYTEX_VERSION: ${{ inputs.tinytex_version }}

- name: Install latex packages πŸ› 
- name: πŸ›  Install latex packages
if: inputs.has_latex == 'true'
env:
tinytex_installer: ${{ inputs.tinytex_installer }}
Expand All @@ -304,7 +304,7 @@ runs:
tinytex::tlmgr_install(pkgs = extra_packages)
shell: Rscript {0}

- name: Install dependencies pass 1 πŸ› 
- name: πŸ›  Install dependencies pass 1
env:
timeout: ${{ inputs.timeout }}
run: |
Expand All @@ -318,7 +318,7 @@ runs:
continue-on-error: true
shell: Rscript {0}

- name: Install dependencies pass 2 πŸ› 
- name: πŸ›  Install dependencies pass 2
env:
timeout: ${{ inputs.timeout }}
run: |
Expand All @@ -328,28 +328,28 @@ runs:
remotes::install_local(repos=repos, dependencies=TRUE, build_vignettes=FALSE, upgrade=TRUE, force=TRUE)
shell: Rscript {0}

- name: Install RUnit (via BiocGenerics) πŸ› 
- name: πŸ›  Install RUnit (via BiocGenerics)
if: inputs.has_runit == 'true'
run: |
options(crayon.enabled = TRUE)
BiocManager::install("BiocGenerics")
shell: Rscript {0}

- name: Install covr πŸ› 
- name: πŸ›  Install covr
if: inputs.run_covr == 'true' && runner.os == 'Linux'
run: |
options(crayon.enabled = TRUE)
install.packages("covr")
shell: Rscript {0}

- name: Install pkgdown πŸ› 
- name: πŸ›  Install pkgdown
if: inputs.run_pkgdown == 'true' && runner.os == 'Linux'
run: |
options(crayon.enabled = TRUE)
install.packages("pkgdown")
shell: Rscript {0}

- name: Session info ℹ️
- name: ℹ️ Session info ️
run: |
options(width = 100, crayon.enabled = TRUE)
pkgs <- installed.packages()[,"Package"]
Expand All @@ -359,7 +359,7 @@ runs:
}, error = function(x){utils::sessionInfo()})
shell: Rscript {0}

- name: Run CMD check βœ…
- name: βœ… Run CMD check
if: inputs.run_rcmdcheck == 'true'
env:
_R_CHECK_CRAN_INCOMING_: false
Expand All @@ -381,13 +381,13 @@ runs:
check_dir = "check")
shell: Rscript {0}

- name: Reveal testthat details πŸ“‹
- name: πŸ“‹ Reveal testthat details
if: inputs.has_testthat == 'true'
run: |
find . -name testthat.Rout -exec cat '{}' ';'
shell: bash {0}

- name: Run RUnit tests (via BiocGenerics) πŸ“‹
- name: πŸ“‹ Run RUnit tests (via BiocGenerics)
if: inputs.has_runit == 'true'
env:
timeout: ${{ inputs.timeout }}
Expand All @@ -396,7 +396,7 @@ runs:
BiocGenerics:::testPackage()
shell: Rscript {0}

- name: Run BiocCheck βœ…
- name: βœ… Run BiocCheck
if: inputs.run_bioccheck == 'true'
env:
DISPLAY: 99.0
Expand All @@ -422,18 +422,18 @@ runs:
`no-check-bioc-help` = as_cran)
shell: Rscript {0}

- name: Test coverage πŸ“‹
- name: πŸ“‹ Test coverage
if: inputs.run_covr == 'true' && runner.os == 'Linux'
run: |
covr::codecov()
shell: Rscript {0}

- name: Install package πŸ› οΈ
- name: πŸ›  Install package ️
if: inputs.run_pkgdown == 'true' && runner.os == 'Linux'
run: R CMD INSTALL .
shell: bash {0}

- name: Get R package info ℹ️
- name: ℹ️ Get R package info
if: runner.os == 'Linux'
run: |
#### DockerHub repos must be lowercase (,,) ####
Expand All @@ -446,7 +446,7 @@ runs:
echo $version
shell: bash {0}

- name: Render README πŸ“¦
- name: πŸ“¦ Render README
if: inputs.run_pkgdown == 'true' && runner.os == 'Linux'
env:
DISPLAY: 99.0
Expand All @@ -458,14 +458,14 @@ runs:
}
shell: Rscript {0}

- name: Build pkgdown site πŸ“¦
- name: πŸ“¦ Build pkgdown site
if: inputs.run_pkgdown == 'true' && runner.os == 'Linux'
run: |
options(crayon.enabled = TRUE)
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy pkgdown site to GitHub pages πŸ“¦ πŸš€
- name: πŸ“¦πŸš€ Deploy pkgdown site to GitHub pages
if: inputs.run_pkgdown == 'true' && runner.os == 'Linux'
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
Expand All @@ -474,32 +474,61 @@ runs:
folder: docs
token: ${{ inputs.GITHUB_TOKEN }}

- name: Upload check results ⏫
- name: ⏫ Upload check results
if: failure()
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-biocversion-${{ matrix.config.bioc }}-r-${{ matrix.config.r }}-results
path: check

## DockerHub steps
- name: Create Docker file 🐳
#### Docker registry steps ####
- name: πŸ³πŸ›  Set up Docker Buildx
if: |
(!contains(github.event.head_commit.message, '/nodocker')) && inputs.run_docker == 'true' && runner.os == 'Linux'
(!contains(github.event.head_commit.message, '[nodocker]')) && inputs.run_docker == 'true' && runner.os == 'Linux'
uses: docker/setup-buildx-action@v3

- name: πŸ³πŸ›  Set up QEMU
if: |
(!contains(github.event.head_commit.message, '[nodocker]')) && inputs.run_docker == 'true' && runner.os == 'Linux'
uses: docker/setup-qemu-action@v3

- name: πŸ³πŸ” Log in to the Github Container registry - ghcr.io
if : |
(!contains(github.event.head_commit.message, '[nodocker]')) && inputs.run_docker == 'true' && runner.os == 'Linux' && inputs.docker_registry == 'ghcr.io'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ env.owner }}
password: ${{ inputs.GITHUB_TOKEN }}

- name: πŸ³πŸ” Log in to the Github Container registry - docker.io
if: |
(!contains(github.event.head_commit.message, '[nodocker]')) && inputs.run_docker == 'true' && runner.os == 'Linux' && inputs.docker_registry == 'docker.io'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.docker_user }}
password: ${{ inputs.DOCKER_TOKEN }}

- name: 🐳✏️ Create Docker file
if: |
(!contains(github.event.head_commit.message, '[nodocker]')) && inputs.run_docker == 'true' && runner.os == 'Linux'
run: |
options(crayon.enabled = TRUE)
if(!require("rworkflows", quietly=TRUE)) remotes::install_github("neurogenomics/rworkflows")
path <- rworkflows::use_dockerfile()
shell: Rscript {0}

- name: Build and push to Docker registry 🐳 πŸš€
- name: πŸ³πŸš€ Build and push to Docker registry
if: |
(!contains(github.event.head_commit.message, '/nodocker')) && inputs.run_docker == 'true' && runner.os == 'Linux'
uses: docker/build-push-action@v1
(!contains(github.event.head_commit.message, '[nodocker]')) && inputs.run_docker == 'true' && runner.os == 'Linux'
uses: docker/build-push-action@v5
with:
username: ${{ inputs.docker_user }}
password: ${{ inputs.DOCKER_TOKEN }}
repository: ${{ inputs.docker_registry }}/${{ inputs.docker_org }}/${{ env.packageName }}
tag_with_ref: true
tag_with_sha: false
tags: ${{ env.packageVersion }},latest
build_args: PKG=${{ env.packageNameOrig }}
repository:
push: true
tags: |
${{ inputs.docker_registry }}/${{ inputs.docker_org }}/${{ env.packageName }}:${{ env.packageVersion }},
${{ inputs.docker_registry }}/${{ inputs.docker_org }}/${{ env.packageName }}:latest
build_args: |
PKG=${{ env.packageNameOrig }},
CONT=${{ matrix.config.cont }}
16 changes: 8 additions & 8 deletions inst/templates/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# and you can set the password to whatever you like,
#
# This DockerFile was partly adapted from the [scFlow Dockerfile](https://github.com/combiz/scFlow/blob/master/Dockerfile).
FROM bioconductor/bioconductor_docker:devel
FROM $CONT
RUN apt-get update && \
apt-get install -y \
git-core \
Expand All @@ -29,13 +29,13 @@ RUN apt-get update && \
make pandoc \
pandoc-citeproc \
zlib1g-dev \
xfonts-100dpi \
xfonts-75dpi \
biber \
libsbml5-dev \
qpdf \
cmake \
&& apt-get clean \
xfonts-100dpi \
xfonts-75dpi \
biber \
libsbml5-dev \
qpdf \
cmake \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create a buildzone folder named after the R package
# BiocCheck requires the buildzone to have the same name as the R package
Expand Down

0 comments on commit 19a7bd1

Please sign in to comment.