From 19a7bd19814b672f42c8a1806871ad45b5709c0f Mon Sep 17 00:00:00 2001 From: bschilder Date: Thu, 12 Oct 2023 02:01:46 +0100 Subject: [PATCH] upgrade docker steps --- action.yml | 127 +++++++++++++++++++++++--------------- inst/templates/Dockerfile | 16 ++--- 2 files changed, 86 insertions(+), 57 deletions(-) diff --git a/action.yml b/action.yml index 1064d5e8..4cce59ad 100644 --- a/action.yml +++ b/action.yml @@ -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. @@ -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 @@ -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 @@ -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 @@ -194,25 +194,25 @@ 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') @@ -220,25 +220,25 @@ runs: 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 = " "))') @@ -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 --- #### @@ -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 }} @@ -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: | @@ -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: | @@ -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"] @@ -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 @@ -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 }} @@ -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 @@ -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 (,,) #### @@ -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 @@ -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: @@ -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 }} diff --git a/inst/templates/Dockerfile b/inst/templates/Dockerfile index d0100c1d..2a003882 100644 --- a/inst/templates/Dockerfile +++ b/inst/templates/Dockerfile @@ -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 \ @@ -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