├── CITATION.cff ├── .github └── workflows │ ├── trigger-tests.yml │ └── update-version-map.yml ├── setup-bioc ├── bioc-version-check.sh ├── bioc-version-map.csv ├── get-r-version.sh ├── get-r-version.R ├── README.md ├── create-version-map.R └── action.yml ├── LICENSE ├── run-BiocCheck ├── action.yml ├── run-bioc-check.R └── README.md ├── use-bioc-caches ├── README.md └── action.yml └── README.md /CITATION.cff: -------------------------------------------------------------------------------- 1 | cff-version: 1.1.0 2 | message: "If you use this software, please cite it using these metadata." 3 | authors: 4 | - family-names: Smith 5 | given-names: Mike L. 6 | orcid: "https://orcid.org/0000-0002-7800-3848" 7 | title: "Github Actions for Bioconductor" 8 | version: 1.0.0 9 | date-released: 2022-02-18 10 | license: "MIT" 11 | repository-code: "https://github.com/grimbough/bioc-actions" 12 | -------------------------------------------------------------------------------- /.github/workflows/trigger-tests.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - 'v1' 5 | workflow_dispatch: 6 | 7 | name: Trigger Test Workflows 8 | 9 | jobs: 10 | trigger-tests: 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Trigger example package build 15 | env: 16 | TOKEN: ${{ secrets.MY_TOKEN }} 17 | run: | 18 | curl -X POST -H "Authorization: token $TOKEN" "https://api.github.com/repos/grimbough/biocActionsExamples/actions/workflows/example-workflow.yml/dispatches" -d '{"ref":"main"}' -------------------------------------------------------------------------------- /setup-bioc/bioc-version-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## This script mostly exists to convert the string "release" to the numeric version 4 | ## number of the current Bioconductor release. This is because BiocManager::install() 5 | ## does not accept the string "release" to it's version argument. 6 | 7 | BIOC=$1 8 | 9 | if [[ $BIOC =~ ^3\.[0-9]{1,2}$ || $BIOC == 'devel' || $BIOC == 'release' ]]; then 10 | if [[ ${BIOC} == 'release' ]]; then 11 | echo '3.15'; 12 | else 13 | echo ${BIOC}; 14 | fi 15 | else 16 | echo -e "Invalid Bioconductor version supplied.\nMust be one of 'devel', 'release' or a number of the format 3.xy e.g. '3.15'"; 17 | exit 1; 18 | fi 19 | -------------------------------------------------------------------------------- /setup-bioc/bioc-version-map.csv: -------------------------------------------------------------------------------- 1 | bioc_version,bioc_version_explicit,r_version,rtools 2 | 1.6,1.6,2.1,35 3 | 1.7,1.7,2.2,35 4 | 1.8,1.8,2.3,35 5 | 1.9,1.9,2.4,35 6 | 2.0,2.0,2.5,35 7 | 2.1,2.1,2.6,35 8 | 2.2,2.2,2.7,35 9 | 2.3,2.3,2.8,35 10 | 2.4,2.4,2.9,35 11 | 2.5,2.5,2.10,35 12 | 2.6,2.6,2.11,35 13 | 2.7,2.7,2.12,35 14 | 2.8,2.8,2.13,35 15 | 2.9,2.9,2.14,35 16 | 2.10,2.10,2.15,35 17 | 2.11,2.11,2.15,35 18 | 2.12,2.12,3.0,35 19 | 2.13,2.13,3.0,35 20 | 2.14,2.14,3.1,35 21 | 3.0,3.0,3.1,35 22 | 3.1,3.1,3.2,35 23 | 3.2,3.2,3.2,35 24 | 3.3,3.3,3.3,35 25 | 3.4,3.4,3.3,35 26 | 3.5,3.5,3.4,35 27 | 3.6,3.6,3.4,35 28 | 3.7,3.7,3.5,35 29 | 3.8,3.8,3.5,35 30 | 3.9,3.9,3.6,35 31 | 3.10,3.10,3.6,35 32 | 3.11,3.11,4.0,40 33 | 3.12,3.12,4.0,40 34 | 3.13,3.13,4.1,40 35 | 3.14,3.14,4.1,40 36 | 3.15,3.15,4.2,42 37 | 3.16,3.16,4.2,42 38 | 3.17,3.17,4.3,43 39 | 3.18,3.18,4.3,43 40 | 3.19,3.19,4.4,44 41 | 3.20,3.20,4.4,44 42 | 3.21,3.21,4.5,45 43 | 3.22,3.22,4.5,45 44 | 3.23,3.23,devel,45 45 | release,3.22,4.5,45 46 | devel,3.23,devel,45 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Mike L. Smith 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /setup-bioc/get-r-version.sh: -------------------------------------------------------------------------------- 1 | abspath() { 2 | if [[ -d "$1" ]] 3 | then 4 | pushd "$1" >/dev/null 5 | pwd 6 | popd >/dev/null 7 | elif [[ -e "$1" ]] 8 | then 9 | pushd "$(dirname "$1")" >/dev/null 10 | echo "$(pwd)/$(basename "$1")" 11 | popd >/dev/null 12 | else 13 | echo "$1" does not exist! >&2 14 | exit 1 15 | fi 16 | } 17 | 18 | mapping_file=$1 19 | 20 | if readlink -f $mapping_file &> /dev/null 21 | then 22 | mapping_file_full=$(readlink -f $mapping_file) 23 | else 24 | mapping_file_full=$(abspath $mapping_file); 25 | fi 26 | 27 | bioc_version=`echo $2 | tr '[:upper:]' '[:lower:]'` 28 | selection=`echo $3 | tr '[:upper:]' '[:lower:]'` 29 | 30 | line=`grep ^$bioc_version, $mapping_file_full` 31 | 32 | if [ $selection = "bioc_version_explicit" ]; then 33 | result=`echo $line | cut -d, -f 2 -` 34 | elif [ $selection = "r_version" ]; then 35 | result=`echo $line | cut -d, -f 3 -` 36 | elif [ $selection = "rtools" ]; then 37 | result=`echo $line | cut -d, -f 4 -` 38 | else 39 | echo "Unknown column selected" 40 | exit 1 41 | fi 42 | 43 | echo $result 44 | exit 0 45 | -------------------------------------------------------------------------------- /setup-bioc/get-r-version.R: -------------------------------------------------------------------------------- 1 | 2 | input_arguments <- commandArgs(trailingOnly=TRUE) 3 | 4 | if (length(input_arguments) != 3) { 5 | stop("Three arguments must be supplied.", call.=FALSE) 6 | } else { 7 | mapping_file <- normalizePath( input_arguments[1] ) 8 | bioc_version <- tolower( input_arguments[2] ) 9 | selection <- tolower( input_arguments[3] ) 10 | } 11 | 12 | ## Check file exists and then read it 13 | if(!file.exists(mapping_file)) { 14 | stop("Unable to find the map file: ", mapping_file) 15 | } else { 16 | version_map <- read.csv(file = mapping_file) 17 | } 18 | 19 | ## Check the given Bioc version is valid 20 | if(!(bioc_version %in% version_map[[ 'bioc_version' ]])) { 21 | stop("Unknown Bioconductor version: ", bioc_version) 22 | } else { 23 | row_idx <- which(version_map[[ 'bioc_version' ]] == bioc_version) 24 | } 25 | 26 | ## Check our selection is a valid column name 27 | if(!(selection %in% colnames(version_map))) { 28 | stop("Unknown selection argument: ", selection, 29 | "\nValid options are: ", 30 | paste(tail(colnames(version_map), n = -1), collapse = ' ')) 31 | } else { 32 | result <- version_map[ row_idx, selection ] 33 | } 34 | 35 | ## print results to screen 36 | cat(result) 37 | 38 | quit(save = "no", status = 0) -------------------------------------------------------------------------------- /setup-bioc/README.md: -------------------------------------------------------------------------------- 1 | # Setup R & Bioconductor 2 | 3 | GitHub Action to install the appropriate version of R for a given version of Bioconductor. 4 | 5 | ## Motivation 6 | 7 | Releases of Bioconductor are tied to specific versions of R. However, because Bioconductors' release cycle is 6 monthly and R's is annual, it can be tricky to keep GitHub Actions Workflows using the appropriate versions. This action tries to simplify this by automatically installing the correct version of R (and Rtools) for a given Bioconductor version. 8 | 9 | The action will also install the `Renviron.bioc` file used by the Bioconductor Build System to enable settings that will cause `R CMD check` to throw an error, but which are not activated by default. The current version of this file for the devel branch can be found at https://bioconductor.org/checkResults/devel/bioc-LATEST/Renviron.bioc 10 | 11 | ## Inputs 12 | 13 | - `bioc-version`: (**Required**) The version of Bioconductor to use. Default value is `devel`. This argument will also accept the string `release` as well as specific version numbers e.g. `3.15`. 14 | - `bioc-mirror`: (*Optional*) The mirror to download Bioconductor packages from. If this option is not supplied then `https://www.bioconductor.org` will be used. 15 | 16 | ## Example usage 17 | 18 | ```yaml 19 | - name: Setup R and Bioconductor 20 | uses: grimbough/bioc-actions/setup-bioc@v1 21 | with: 22 | bioc-version: devel 23 | bioc-mirror: https://ftp.gwdg.de/pub/misc/bioconductor 24 | ``` 25 | -------------------------------------------------------------------------------- /run-BiocCheck/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Run BiocCheck' 2 | inputs: 3 | package-directory: 4 | description: 'Specify the location of the package to check if it is not in the working directory.' 5 | required: false 6 | default: '.' 7 | error-on: 8 | description: 'Specify the level of issue that should cause the action to fail.' 9 | required: false 10 | default: 'error' 11 | arguments: 12 | description: 'Arguments provided to BiocCheck() to disable specific tests.' 13 | required: false 14 | default: '' 15 | runs: 16 | using: "composite" 17 | steps: 18 | 19 | - name: Test for docker 20 | run: | 21 | ## Test whether we're in a Bioc Docker Container 22 | if [[ ! -z ${BIOCONDUCTOR_DOCKER_VERSION} ]]; then 23 | echo IN_BIOC_DOCKER=true >> ${GITHUB_ENV}; 24 | else 25 | echo IN_BIOC_DOCKER=false >> ${GITHUB_ENV}; 26 | fi 27 | shell: bash 28 | 29 | - name: Install system dependencies 30 | if: ${{ (runner.os == 'Linux') && (env.IN_BIOC_DOCKER == 'false') }} 31 | run: | 32 | sudo apt-get update && sudo apt-get -y -qq install libcurl4-openssl-dev 33 | shell: bash 34 | 35 | - run: | 36 | if(!requireNamespace("BiocManager", quietly = TRUE)) { install.packages("BiocManager", quiet = TRUE) } 37 | BiocManager::install('BiocCheck', quiet = TRUE, upgrade = FALSE, ask = FALSE) 38 | shell: Rscript {0} 39 | 40 | - run: | 41 | Rscript --vanilla "${GITHUB_ACTION_PATH}/run-bioc-check.R" "${{ inputs.package-directory }}" "${{ inputs.error-on }}" ${{ inputs.arguments }} 42 | shell: bash 43 | -------------------------------------------------------------------------------- /run-BiocCheck/run-bioc-check.R: -------------------------------------------------------------------------------- 1 | ## We're expecting at least two arguments. 2 | ## 1. The package directory to be checked 3 | ## 2. The condition under which BiocCheck should be deemed to have failed. 4 | ## One of "error", "warning", "note", "never". 5 | ## 3. Any further arguments are optional and should be passed to BiocCheck 6 | input_arguments <- commandArgs(trailingOnly=TRUE) 7 | 8 | if (length(input_arguments) < 2) { 9 | stop("At least two argument must be supplied.", call.=FALSE) 10 | } else { 11 | dir <- input_arguments[1] 12 | error_on <- input_arguments[2] 13 | if(length(input_arguments) > 2) { 14 | bioccheck_args <- unlist(strsplit(tail(input_arguments, -2), "[[:space:],]+")) 15 | } else { 16 | bioccheck_args <- NULL 17 | } 18 | } 19 | 20 | if(!error_on %in% c("error", "warning", "note", "never")) { 21 | message("error on argument should be one of: 'error', 'warning', 'note', 'never'") 22 | error_on <- "never" 23 | } 24 | 25 | ## strip leading "--" from arguments 26 | args_list <- as.list(rep(TRUE, length(bioccheck_args))) 27 | names(args_list) <- gsub(x = bioccheck_args, pattern = "--", replacement = "", fixed = TRUE) 28 | 29 | ## run BiocCheck 30 | check_results <- do.call(BiocCheck::BiocCheck, 31 | c(list(package = dir, checkDir = dirname(dir), 32 | debug = FALSE, callr = FALSE), 33 | args_list)) 34 | 35 | status <- switch(error_on, 36 | error = length(check_results$error), 37 | warning = length(check_results$warning), 38 | note = length(check_results$note), 39 | never = 0) 40 | 41 | quit(save = "no", status = status) -------------------------------------------------------------------------------- /.github/workflows/update-version-map.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_dispatch: 3 | schedule: 4 | # should run at midnight on the first day of each month 5 | - cron: '0 0 1 * *' 6 | 7 | name: Update Version Map 8 | 9 | jobs: 10 | update-map: 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | 15 | - name: Make library folder 16 | run: | 17 | echo "R_LIBS_USER=${{ runner.temp }}/R-lib" >> $GITHUB_ENV 18 | mkdir -p ${{ runner.temp }}/R-lib 19 | shell: bash 20 | 21 | - name: Checkout github repo 22 | uses: actions/checkout@v2 23 | with: 24 | fetch-depth: 0 25 | 26 | - name: Install BiocManager 27 | run: | 28 | .libPaths() 29 | install.packages('BiocManager', repos = 'https://cran.rstudio.com/') 30 | shell: Rscript {0} 31 | 32 | - name: Run update 33 | run: Rscript ${{ github.workspace }}/setup-bioc/create-version-map.R 34 | shell: bash 35 | working-directory: ${{ github.workspace }}/setup-bioc 36 | 37 | - name: Commit updated version map 38 | run: | 39 | git config --local user.email "action@github.com" 40 | git config --local user.name "GitHub Action" 41 | git add setup-bioc/bioc-version-map.csv 42 | git commit -m "`date +%B` update" || echo "No changes to commit" 43 | git push origin v1-branch || echo "No changes to commit" 44 | git tag -d v1 && git tag v1 && git push origin :v1 && git push origin v1 45 | 46 | - name: Update tag test 47 | uses: phish108/autotag-action@1.1.37 48 | id: taggerTest 49 | with: 50 | github-token: ${{ secrets.GITHUB_TOKEN }} 51 | branch: v1-branch 52 | dry-run: 'true' 53 | -------------------------------------------------------------------------------- /use-bioc-caches/README.md: -------------------------------------------------------------------------------- 1 | # Use Bioconductor Caches 2 | 3 | Make use of cached Bioconductor resources between workflow runs. 4 | 5 | ## Motivation 6 | 7 | Several Bioconductor packages (e.g. [ExperimentHub](https://bioconductor.org/packages/ExperimentHu), [AnnotationHub](https://bioconductor.org/packages/AnnotaionHub), [BiocFileCache](https://bioconductor.org/packages/BiocFileCache)) will cache files to save time repeatedly downloading large datasets in vignettes, workflows etc. 8 | 9 | This action will initialise a directory under which package specific caches will be created, and sets environment variables that will provide the locations to R sessions used later in a workflow. It will then use [action/cache](https://github.com/actions/cache) to retain and restore the cache between workflow runs. 10 | 11 | Currently supported packages are: 12 | - ExperimentHub 13 | - AnnotationHub 14 | - BiocFileCache 15 | - biomaRt 16 | 17 | ## Inputs 18 | 19 | - `cache-version`: (*Optional*) A version number to be included in the cache key. Default value of `'1'`. This argument can be used to invalidate the existing cache. Pass a new number and a new cache will be used. 20 | - `cache-directory`: (*Optional*) Path to the location of the cache folders. Use this if you want to control where caches are created on the runner. If left blank the output from `tools::R_user_dir(package = "bioc_cache", which = "cache")` will be used. 21 | 22 | ## Example usage 23 | 24 | This action assumes a version of R (>= 4.0) is installed as well as the **BiocManager** manager package. It will fail if that is not the case. Using [bioc-actions/setup-bioc](https://github.com/grimbough/bioc-actions/tree/v1/setup-bioc) will satisfy these conditions. 25 | 26 | ```yaml 27 | - name: Use Bioc Caches 28 | uses: grimbough/bioc-actions/use-bioc-caches@v1 29 | with: 30 | cache-version: '1' 31 | ``` 32 | -------------------------------------------------------------------------------- /run-BiocCheck/README.md: -------------------------------------------------------------------------------- 1 | # Run BiocCheck 2 | 3 | GitHub Action to test an R package using [BiocCheck](https://bioconductor.org/packages/BiocCheck/). 4 | 5 | The Bioconductor project has some extra checks in addition to the usual `R CMD check` that must be passed as part of the package submission process. This action allows the `BiocCheck()` function to be deployed on a specified package folder. 6 | 7 | ## Inputs 8 | 9 | - `package-directory`: (*Optional*) Specify the location of the package to check if it is not in the working directory. 10 | - `error-on`: (*Optional*) Specify the conditions under which the action will report a failure. Can be set to one of: `error`, `warning`, `note`, or `never`. The first three options will cause the action to return a failure if `BiocCheck()` reports one or more issues of the corresponding severity. The option `never` will allow the action complete successfully whatever `BiocCheck()` reports. The default value if this argument is not specified is `error`. 11 | - `arguments`: (*Optional*) Arguments that should be passed to `BiocCheck()` to disable specific tests. These should be provided as they were command line arguments, with multiple options separated by a space e.g. '`--no-check-bioc-views --no-check-bioc-help`'. See the [BiocCheck vignette](https://bioconductor.org/packages/release/bioc/vignettes/BiocCheck/inst/doc/BiocCheck.html#using-bioccheck) for all possible options. 12 | 13 | ## Example usage 14 | 15 | This action assumes you have R installed on the runner. This is true by default all Github hosted runners. Alternatively [bioc-actions/setup-bioc](https://github.com/grimbough/bioc-actions/tree/v1/setup-bioc) or [r-lib/actions/setup-r](https://github.com/r-lib/actions/tree/v2/setup-r) could be used to install a specific version. 16 | 17 | ```yaml 18 | - name: Run BiocCheck 19 | uses: grimbough/bioc-actions/run-BiocCheck@v1 20 | with: 21 | working-directory: examplePKG 22 | error-on: 'never' 23 | arguments: '--no-check-bioc-views --no-check-bioc-help' 24 | ``` 25 | -------------------------------------------------------------------------------- /setup-bioc/create-version-map.R: -------------------------------------------------------------------------------- 1 | map <- BiocManager:::.version_map() 2 | map <- map[,c("Bioc", "R", "BiocStatus")] 3 | 4 | idx_release <- which(map$BiocStatus == "release") 5 | idx_devel <- which(map$BiocStatus == "devel") 6 | idx_future <- which(map$BiocStatus == "future") 7 | 8 | ## remove the future entry 9 | map <- map[-idx_future,] 10 | 11 | bioc_version <- c(as.character(map$Bioc), 'release', 'devel') 12 | r_version <- c(map$R, map$R[ c(idx_release, idx_devel) ]) 13 | bioc_version_explicit <- c(as.character(map$Bioc), 14 | as.character(map$Bioc)[ c(idx_release, idx_devel) ]) 15 | 16 | ## assign appropriate Rtools version 17 | rtools <- rep("35", length(r_version)) 18 | rtools[ r_version >= package_version('4.0') & r_version <= package_version('4.1') ] <- "40" 19 | rtools[ r_version == package_version('4.2') ] <- "42" 20 | rtools[ r_version == package_version('4.3') ] <- "43" 21 | rtools[ r_version == package_version('4.4') ] <- "44" 22 | rtools[ r_version >= package_version('4.5') ] <- "45" 23 | 24 | res <- data.frame( 25 | bioc_version, 26 | bioc_version_explicit, 27 | r_version, 28 | rtools 29 | ) 30 | 31 | ## we need to use the word "devel" rather than specifying a version number 32 | ## when using r-lib/setup-r to install the devel version of R 33 | currentR <- readLines("https://api.r-hub.io/rversions/r-release", warn = FALSE) 34 | currentR <- gsub(".*version.*([0-9]\\.[0-9]+\\.[0-9]+).*", "\\1", x = currentR) 35 | currentR <- as.numeric_version(currentR) 36 | 37 | nextR <- readLines("https://api.r-hub.io/rversions/r-next", warn = FALSE) 38 | nextR <- gsub(".*version.*([0-9]\\.[0-9]+\\.[0-9]+).*", "\\1", x = nextR) 39 | nextR <- as.numeric_version(nextR) 40 | 41 | ## For "non-release" R versions, figure out whether they should be "next" 42 | ## or "devel" 43 | nonrelease_R_idx <- which(res$r_version > currentR) 44 | next_R_idx <- intersect(nonrelease_R_idx, which(res$r_version == nextR)) 45 | devel_R_idx <- setdiff(nonrelease_R_idx, next_R_idx) 46 | 47 | res$r_version <- as.character(res$r_version) 48 | res$r_version[next_R_idx] <- "next" 49 | res$r_version[devel_R_idx] <- "devel" 50 | 51 | write.csv(x = res, file = "bioc-version-map.csv", quote = FALSE, row.names = FALSE) 52 | -------------------------------------------------------------------------------- /setup-bioc/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Setup R & Bioconductor' 2 | inputs: 3 | bioc-version: 4 | description: 'Version of Bioconductor' 5 | required: true 6 | default: 'devel' 7 | bioc-mirror: 8 | description: '' 9 | required: false 10 | default: 'https://www.bioconductor.org' 11 | use-public-rspm: 12 | description: 'Should the public Rstudio Package Manager be used to install packages.' 13 | required: false 14 | default: true 15 | Ncpus: 16 | description: 'Set the R option `Ncpus` to this value.' 17 | required: false 18 | default: 3 19 | runs: 20 | using: "composite" 21 | steps: 22 | 23 | - id: find-versions 24 | run: | 25 | RVERSION=$(bash "${GITHUB_ACTION_PATH}/get-r-version.sh" "${GITHUB_ACTION_PATH}/bioc-version-map.csv" ${{ inputs.bioc-version }} r_version) 26 | RTOOLS=$(bash "${GITHUB_ACTION_PATH}/get-r-version.sh" "${GITHUB_ACTION_PATH}/bioc-version-map.csv" ${{ inputs.bioc-version }} rtools) 27 | BIOCVERSION=$(bash "${GITHUB_ACTION_PATH}/get-r-version.sh" "${GITHUB_ACTION_PATH}/bioc-version-map.csv" ${{ inputs.bioc-version }} bioc_version_explicit) 28 | echo "r-version=$(echo ${RVERSION})" >> $GITHUB_OUTPUT 29 | echo "rtools-version=$(echo ${RTOOLS})" >> $GITHUB_OUTPUT 30 | echo "bioc-version=$(echo ${BIOCVERSION})" >> $GITHUB_OUTPUT 31 | echo "R_BIOC_VERSION=${BIOCVERSION}" >> $GITHUB_ENV 32 | shell: bash 33 | 34 | - uses: r-lib/actions/setup-r@v2 35 | with: 36 | r-version: ${{ steps.find-versions.outputs.r-version }} 37 | Ncpus: ${{ inputs.Ncpus }} 38 | use-public-rspm: ${{ inputs.use-public-rspm }} 39 | rtools-version: ${{ steps.find-versions.outputs.rtools-version }} 40 | 41 | - name: Download Renviron 42 | run: | 43 | download.file('https://bioconductor.org/checkResults/${{ inputs.bioc-version }}/bioc-LATEST/Renviron.bioc', destfile = '~/.Renviron', mode = 'wb') 44 | shell: Rscript {0} 45 | 46 | - name: Setting Bioconductor mirror 47 | run: | 48 | write('options(BioC_mirror = "${{ inputs.bioc-mirror }}")', file = '~/.Rprofile', append = TRUE) 49 | shell: Rscript {0} 50 | 51 | - name: Install and initialize BiocManager 52 | run: | 53 | install.packages(c("BiocManager", "remotes"), quiet = TRUE) 54 | BiocManager::install(version = "${{ steps.find-versions.outputs.bioc-version }}", ask = FALSE) 55 | shell: Rscript {0} 56 | -------------------------------------------------------------------------------- /use-bioc-caches/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Use Bioconductor Caches' 2 | inputs: 3 | cache-version: 4 | description: 'Used to invalidate the existing cache. Pass a new number and a new cache will be used.' 5 | required: false 6 | default: 1 7 | cache-directory: 8 | description: 'Path to the location of the cache folders. Use this if you want to control where caches are created on the runner. If left blank the output from `tools::R_user_dir(package = "bioc_cache", which = "cache")` will be used.' 9 | required: false 10 | default: '' 11 | 12 | runs: 13 | using: "composite" 14 | steps: 15 | - name: Install system dependencies 16 | if: runner.os == 'Linux' 17 | run: sudo apt-get -y -qq install libcurl4-openssl-dev 18 | shell: bash 19 | 20 | - id: set-cache-location 21 | run: | 22 | ## determine location of caches 23 | if [[ '${{ inputs.cache-directory }}' == '' ]]; then 24 | CACHE_PATH=$(Rscript -e 'cat(tools::R_user_dir(package = "bioc_cache", which = "cache"))') 25 | else 26 | CACHE_PATH=${{ inputs.cache-directory }} 27 | fi 28 | mkdir -p ${CACHE_PATH} 29 | echo "cache-path=$(echo ${CACHE_PATH})" >> $GITHUB_OUTPUT 30 | shell: bash 31 | 32 | - id: cache-keys 33 | run: | 34 | BIOC_VERSION=$(Rscript -e 'cat(as.character(BiocManager::version()))') 35 | DATE=$(date --utc +%D) 36 | echo "bioc-version=$(echo ${BIOC_VERSION})" >> $GITHUB_OUTPUT 37 | echo "date=$(echo ${DATE})" >> $GITHUB_OUTPUT 38 | shell: bash 39 | 40 | - uses: actions/cache@v2 41 | with: 42 | path: ${{ steps.set-cache-location.outputs.cache-path }} 43 | key: BiocCache-v${{ steps.cache-keys.outputs.bioc-version }}-${{ steps.cache-keys.outputs.date }}-${{ inputs.cache-version }} 44 | restore-keys: | 45 | BiocCache-v${{ steps.cache-keys.outputs.bioc-version }}-${{ steps.cache-keys.outputs.date }}- 46 | BiocCache-v${{ steps.cache-keys.outputs.bioc-version }}- 47 | BiocCache- 48 | 49 | - name: Setting Enviroment Variables 50 | run: | 51 | echo BFC_CACHE=${{ steps.set-cache-location.outputs.cache-path }}/BiocFileCache >> $GITHUB_ENV 52 | echo EXPERIMENT_HUB_CACHE=${{ steps.set-cache-location.outputs.cache-path }}/ExperimentHub >> $GITHUB_ENV 53 | echo ANNOTATION_HUB_CACHE=${{ steps.set-cache-location.outputs.cache-path }}/AnnotationHub >> $GITHUB_ENV 54 | echo BIOMART_CACHE=${{ steps.set-cache-location.outputs.cache-path }}/biomaRt >> $GITHUB_ENV 55 | shell: bash 56 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Github Actions for Bioconductor 2 | 3 | [![Workflow that tests the actions](https://github.com/grimbough/biocActionsExamples/actions/workflows/example-workflow.yml/badge.svg)](https://github.com/grimbough/biocActionsExamples/actions/workflows/example-workflow.yml) 4 | 5 | This repository holds some GitHub actions that may be useful for those developing or maintaining R packages that will be hosted by the [Bioconductor](https://www.bioconductor.org) project. Actions can be considered as tasks that form the building blocks of larger workflows. The development of an R package often benefits from the deployment of workflows for testing the code in a variety of conditions e.g. a variety of operating systems and specific versions of software. 6 | 7 | The acceptance of a package to Bioconductor project, as well as continued inclusion and deployment by passing tests on it's nightly build system, involves accommodating a number of specific requirements and features that make developing for it subtly different to a CRAN package. The actions provided here aim to simplify deploying a Github Workflow that closely matches the Bioconductor requirements. 8 | 9 | These actions are built upon the [GitHub Actions for the R language](https://github.com/r-lib/actions) and should be considered complementary to them. It's also recommended to take a look at the [biocthis](https://bioconductor.org/packages/biocthis/) package, which provides templates and functions for setting up GitHub Actions workflows for Bioconductor packages. 10 | 11 | ## Actions 12 | 13 | The actions currently hosted here are: 14 | 15 | - [bioc-actions/setup-bioc](https://github.com/grimbough/bioc-actions/tree/v1/setup-bioc) - Given a version of Bioconductor, this action installs the appropriate version of R and initialises the [BiocManager](https://cran.r-project.org/package=BiocManager) package. 16 | - [bioc-actions/build-install-check](https://github.com/grimbough/bioc-actions/tree/v1/build-install-check) - Build, install, and check a package emulating the process used by the Bioconductor Build System. 17 | - [bioc-actions/run-BiocCheck](https://github.com/grimbough/bioc-actions/tree/v1/run-BiocCheck) - Runs `BiocCheck::BiocCheck()` on a given package directory. 18 | - [bioc-actions/use-bioc-caches](https://github.com/grimbough/bioc-actions/tree/v1/use-bioc-caches) - Create and use a directory for caching files downloaded by Bioconductor packages between workflow runs. 19 | 20 | ## Examples 21 | 22 | Example workflows for using these actions on both a package repository and a repository where a package is stored in a subdirectory can be found in the [biocActionsExamples](https://github.com/grimbough/biocActionsExamples) repository. 23 | --------------------------------------------------------------------------------