Skip to content

Commit f9238f7

Browse files
committed
test miniforge_variant
1 parent d45c17d commit f9238f7

File tree

13 files changed

+616
-470
lines changed

13 files changed

+616
-470
lines changed

β€Ž.Rhistory

Lines changed: 454 additions & 454 deletions
Large diffs are not rendered by default.

β€Ž.github/workflows/rworkflows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ jobs:
5353
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
5454
runner_os: ${{ runner.os }}
5555
cache_version: cache-v1
56+
miniforge_variant: ""

β€ŽDESCRIPTION

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rworkflows
22
Type: Package
33
Title: Test, Document, Containerise, and Deploy R Packages
4-
Version: 0.99.13
4+
Version: 0.99.14
55
Authors@R:
66
c(person(given = "Brian",
77
family = "Schilder",
@@ -58,8 +58,6 @@ Suggests:
5858
BiocStyle,
5959
BiocPkgTools,
6060
biocViews
61-
Remotes:
62-
github::Bioconductor/BiocStyle
6361
VignetteBuilder: knitr
6462
License: GPL-3
6563
Config/testthat/edition: 3

β€ŽNEWS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# rworkflows 0.99.14
2+
3+
## New features
4+
5+
* Add step to enable conda envs: #78
6+
- Add subfunction: `gha_python_versions()` within `construct_runners`
7+
- Add new *action.yml*:
8+
- `miniforge_variant`
9+
- `miniforge_version`
10+
- `activate_environment`
11+
- `environment_file`
12+
- `channels`
13+
114
# rworkflows 0.99.13
215

316
## New features

β€ŽR/bioc_r_versions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ bioc_r_versions <- function(bioc_version = NULL,
5353
return(opts)
5454
} else if(is.null(bioc_version)){
5555
return(info)
56-
} else if (bioc_version=="devel") {
56+
} else if (bioc_version %in% c("devel","dev")) {
5757
return(info$devel)
58-
} else if (bioc_version=="release") {
58+
} else if (bioc_version %in% c("release","latest")) {
5959
return(info$release)
6060
} else if (bioc_version %in% names(info$r_ver_for_bioc_ver)){
6161
if(grepl("RELEASE_",bioc_version,ignore.case = TRUE)){

β€ŽR/construct_runners.R

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#' for a list of all official Bioconductor Docker container versions.
1414
#' @param rspm Which R repository manager to use on each OS
1515
#' (\code{NULL} means the default will be used for that OS).
16+
#' @param python_version Which python version to use on each OS.
17+
#' (\code{NULL} means python will not be installed on that OS).
18+
#' See
19+
#' \href{https://github.com/marketplace/actions/setup-miniconda}{here} for
20+
#' details.
1621
#' @param versions_explicit Specify R/Bioc versions explicitly
1722
#' (e.g. \code{r: 4.2.0, bioc: 3.16})
1823
#' as opposed to flexibly (e.g. \code{r: "latest", bioc: "release"}).
@@ -33,6 +38,9 @@ construct_runners <- function(os=c("ubuntu-latest",
3338
r = list("auto",
3439
"auto",
3540
"auto"),
41+
python_version = list(NULL,
42+
NULL,
43+
NULL),
3644
versions_explicit = FALSE,
3745
run_check_cont = FALSE,
3846
cont = construct_cont(
@@ -53,7 +61,8 @@ construct_runners <- function(os=c("ubuntu-latest",
5361
bioc = bioc,
5462
r = r,
5563
cont = cont,
56-
rspm = rspm)
64+
rspm = rspm,
65+
python_version = python_version)
5766
#### Set runners ####
5867
runners <- lapply(os, function(o){
5968
if(isTRUE(versions_explicit)){
@@ -65,16 +74,22 @@ construct_runners <- function(os=c("ubuntu-latest",
6574
}
6675
#### Check container settings ####
6776
if(isTRUE(run_check_cont)){
68-
cont <- check_cont(cont=cont,
69-
verbose=verbose)
70-
}
77+
args$cont[[o]] <- check_cont(cont=args$cont[[o]],
78+
verbose=verbose)
79+
}
7180
#### Construct new list ####
72-
list(os = o,
73-
bioc = info$bioc,
74-
r = info$r,
75-
cont = args$cont[[o]],
76-
rspm = args$rspm[[o]]
81+
l <- list(os = o,
82+
bioc = info$bioc,
83+
r = info$r,
84+
cont = args$cont[[o]],
85+
rspm = args$rspm[[o]]
7786
)
87+
#### Check python settings ####
88+
python_version <- if(!is.null(args$python_version)){
89+
l[["python-version"]] <- gha_python_versions(
90+
python_version=args$python_version[[o]])
91+
}
92+
return(l)
7893
})
7994
return(runners)
8095
}

β€ŽR/construct_runners_check_args.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ construct_runners_check_args <- function(os,
33
r,
44
cont,
55
rspm,
6+
python_version,
67
versions_explicit=FALSE,
78
verbose=TRUE){
89

910

1011
#### Fill names ####
11-
args <- list(os=os, bioc=bioc, r=r, cont=cont, rspm=rspm)
12+
args <- list(os=os, bioc=bioc, r=r, cont=cont, rspm=rspm,
13+
python_version=python_version)
1214
args2 <- lapply(stats::setNames(names(args),
1315
names(args)),
1416
function(nm){

β€ŽR/gha_python_versions.R

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
gha_python_versions <- function(python_version=NULL){
2+
yml <- yaml::read_yaml(paste0(
3+
"https://raw.githubusercontent.com/actions/python-versions/",
4+
"main/versions-manifest.json")
5+
)
6+
7+
if(!is.null(python_version)){
8+
python_version <- as.character(python_version[1])
9+
#### Get all versions (minor and major) ####
10+
versions <- sapply(yml, function(x){x$version})
11+
versions_major <- unique(sapply(strsplit(versions,'\\.'),
12+
function(x)paste(x[1],x[2],sep="."))
13+
)
14+
versions_x <- unique(sapply(strsplit(versions,'\\.'),
15+
function(x)paste(x[1],"x",sep="."))
16+
)
17+
versions_opts <- c(versions,versions_major,versions_x)
18+
#### Get devel version ####
19+
if(python_version %in% c("devel","dev")){
20+
python_version <- versions[sapply(yml, function(x){x$stable==FALSE})][1]
21+
#### Get release version ####
22+
} else if (python_version %in% c("latest","release")){
23+
python_version <- versions[sapply(yml, function(x){x$stable==TRUE})][1]
24+
#### Get specific version ####
25+
} else if(python_version=="3"){
26+
python_version <- "3.x"
27+
}else {
28+
if(!python_version %in% versions_opts){
29+
stopper(paste0("python_version=",shQuote(python_version),
30+
"is not available.",
31+
"Must be one of:",
32+
paste("\n - ",shQuote(versions_opts),collapse = "")))
33+
}
34+
}
35+
return(python_version)
36+
} else {
37+
return(yml)
38+
}
39+
}

β€Žaction.yml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,56 @@ inputs:
100100
The maximum time to wait for long R processes like
101101
dependency installations, downloads, and code checks.
102102
default: 2000
103+
miniforge_variant:
104+
description: >
105+
If provided, this variant of Miniforge will be downloaded and installed.
106+
If `miniforge_variant=false`, Miniforge will not be instaled at all.
107+
If `miniforge_variant=""`, the "Miniforge3" variant will be installed.
108+
If `miniforge_version` is not provided, the `latest` version will be used.
109+
Currently-known values: - Miniforge3 (default) - Miniforge-pypy3 -
110+
Mambaforge - Mambaforge-pypy3 Visit
111+
https://github.com/conda-forge/miniforge/releases/ for more information on
112+
available variants.
113+
default: false
114+
miniforge_version:
115+
description: >
116+
If provided, this version of the given Miniforge variant will be
117+
downloaded and installed. If `miniforge_variant` is not provided,
118+
`Miniforge3` will be used. Visit
119+
https://github.com/conda-forge/miniforge/releases/ for more information on
120+
available versions.
121+
default: ""
122+
activate_environment:
123+
description: >
124+
Environment name (or path) to activate on all shells. Default is `test`
125+
which will be created in `$CONDA/envs/test`. If an empty string is used,
126+
no environment is activated by default (For `base` activation see the
127+
`auto-activate-base` option). If the environment does not exist, it will
128+
be created and activated. If `environment-file` is used and you want that
129+
to be the environment used, you need to explicitely provide the name of
130+
that environment on `activate-environment`. If using sh/bash/cmd.exe
131+
shells please read the IMPORTANT! section on the README.md! to properly
132+
activate conda environments on these shells.
133+
default: "test"
134+
environment_file:
135+
description: >
136+
Path or URL to a .yml file to build the conda environment with.
137+
For more information see:
138+
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file
139+
default:
140+
""
141+
channels:
142+
description: >
143+
Conda configuration. Comma separated list of channels to use in order of
144+
priority. See
145+
https://docs.conda.io/projects/conda/en/latest/user-guide/configuration/
146+
for more information.
147+
default:
148+
""
103149
runs:
104150
using: 'composite'
105151
steps:
106-
- name: Set GitHub environment variables 🏞️
152+
- name: Set GitHub environment variables ️🌎
107153
run: |
108154
echo "GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}" >> $GITHUB_ENV
109155
echo "RGL_USE_NULL=TRUE" >> $GITHUB_ENV
@@ -113,6 +159,19 @@ runs:
113159
echo "NOT_CRAN=${{ !inputs.as_cran }}" >> $GITHUB_ENV
114160
shell: bash {0}
115161

162+
## Setup Miniconda 🐍
163+
- name: Setup Miniconda
164+
if: inputs.miniforge_variant != 'false'
165+
uses: conda-incubator/setup-miniconda@v2
166+
with:
167+
auto-update-conda: false
168+
python-version: ${{ matrix.python-version }}
169+
miniforge-variant: ${{ inputs.miniforge_variant }}
170+
miniforge-version: ${{ inputs.miniforge_version }}
171+
activate-environment: ${{ inputs.activate_environment }}
172+
environment-file: ${{ inputs.environment_file }}
173+
channels: ${{ inputs.channels }}
174+
116175
## Set the R library to the directory matching the
117176
## R packages cache step further below when running on Docker (Linux).
118177
- name: Set R library home on Linux πŸ“š
File renamed without changes.

0 commit comments

Comments
Β (0)