-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ns build action * add node modules Y_Y * update documentation --------- Co-authored-by: Dries Schaumont <[email protected]>
- Loading branch information
1 parent
86a511e
commit 8c078bb
Showing
445 changed files
with
98,431 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
ns-build | ||
================ | ||
|
||
Build a namespace from many viash config files. | ||
|
||
## Usage | ||
|
||
This action will run `viash ns build`. See the reference documentation | ||
on [ns build](https://viash.io/reference/viash/ns.html) for more info on | ||
each of the arguments. | ||
|
||
We recommend using a Linux or MacOS runner if possible. | ||
|
||
### Inputs available | ||
|
||
- `query`: - *optional*. Filter which components get selected by | ||
component and namespace name. Can be a regex. Example: | ||
“^mynamespace/component1\$”. | ||
- `query_namespace`: - *optional*. Filter which namespaces get selected | ||
by namespace name. Can be a regex. Example: “^mynamespace\$”. | ||
- `query_name`: - *optional*. Filter which components get selected by | ||
component name. Can be a regex. Example: “^component1”. | ||
- `src`: - *optional*. A source directory containing viash config files, | ||
possibly structured in a hierarchical folder structure. Default: src/. | ||
- `platform`: - *optional*. Acts as a regular expression to filter the | ||
platform ids specified in the found config files. If this is not | ||
provided, all platforms will be used. If no platforms are defined in a | ||
config, the native platform will be used. In addition, the path to a | ||
platform yaml file can also be specified. | ||
- `parallel`: - *optional*. Whether or not to run the process in | ||
parallel. | ||
- `config_mod`: - *optional*. Modify a viash config at runtime using | ||
dynamic config modding. | ||
- `target`: - *optional*. A target directory to build the executables | ||
into. Default: target/. | ||
- `setup`: - *optional*. Which setup strategy for creating the container | ||
to use \[Docker Platform only\]. | ||
|
||
## Examples | ||
|
||
``` yaml | ||
name: demo of viash ns build | ||
|
||
on: | ||
branch: main | ||
|
||
jobs: | ||
viash-linux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: viash-io/viash-actions/setup@v1 | ||
|
||
- uses: viash-io/viash-actions/ns-build@v1 | ||
viash-macos: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: viash-io/viash-actions/setup@v1 | ||
|
||
- uses: viash-io/viash-actions/ns-build@v1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
title: ns-build | ||
format: gfm | ||
--- | ||
|
||
```{r} | ||
#| include: false | ||
library(tidyverse) | ||
# action <- yaml::read_yaml("ns-build/action.yml") | ||
action <- yaml::read_yaml("action.yml") | ||
``` | ||
|
||
`r action$description` | ||
|
||
## Usage | ||
|
||
This action will run `viash ns build`. See the reference documentation on [ns build](https://viash.io/reference/viash/ns.html) for more info on each of the arguments. | ||
|
||
We recommend using a Linux or MacOS runner if possible. | ||
|
||
### Inputs available | ||
|
||
```{r} | ||
#| echo: false | ||
lines <- map_chr(names(action$inputs), function(name) { | ||
input <- action$inputs[[name]] | ||
required <- ifelse (input$required %||% FALSE, "required", "optional") | ||
glue::glue("* `{name}`: - _{required}_. {input$description}") | ||
}) | ||
knitr::asis_output(paste0(lines, collapse = "\n")) | ||
``` | ||
|
||
## Examples | ||
|
||
```yaml | ||
name: demo of viash ns build | ||
|
||
on: | ||
branch: main | ||
|
||
jobs: | ||
viash-linux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: viash-io/viash-actions/setup@v1 | ||
|
||
- uses: viash-io/viash-actions/ns-build@v1 | ||
viash-macos: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: viash-io/viash-actions/setup@v1 | ||
|
||
- uses: viash-io/viash-actions/ns-build@v1 | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: viash ns build | ||
description: Build a namespace from many viash config files. | ||
inputs: | ||
query: | ||
description: 'Filter which components get selected by component and namespace | ||
name. Can be a regex. Example: "^mynamespace/component1$".' | ||
required: false | ||
query_namespace: | ||
description: 'Filter which namespaces get selected by namespace name. Can be a | ||
regex. Example: "^mynamespace$".' | ||
required: false | ||
query_name: | ||
description: 'Filter which components get selected by component name. Can be a | ||
regex. Example: "^component1".' | ||
required: false | ||
src: | ||
description: ' A source directory containing viash config files, possibly structured | ||
in a hierarchical folder structure. Default: src/.' | ||
required: false | ||
platform: | ||
description: Acts as a regular expression to filter the platform ids specified | ||
in the found config files. If this is not provided, all platforms will be used. | ||
If no platforms are defined in a config, the native platform will be used. In | ||
addition, the path to a platform yaml file can also be specified. | ||
required: false | ||
parallel: | ||
description: Whether or not to run the process in parallel. | ||
required: false | ||
config_mod: | ||
description: Modify a viash config at runtime using dynamic config modding. | ||
required: false | ||
target: | ||
description: 'A target directory to build the executables into. Default: target/.' | ||
required: false | ||
setup: | ||
description: Which setup strategy for creating the container to use [Docker Platform | ||
only]. | ||
required: false | ||
runs: | ||
using: node16 | ||
main: index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This script generates a github action given a Viash schema | ||
|
||
library(tidyverse) | ||
|
||
# parameters | ||
skip_args <- c("push", "flatten") | ||
dest_file <- "ns-build/action.yml" | ||
subcommands <- c("ns", "build") | ||
|
||
#################### common code | ||
# fetch schema | ||
out <- system("viash export cli_schema", intern = TRUE) | ||
schema <- jsonlite::fromJSON(out, simplifyVector = FALSE) | ||
|
||
# go down schema to find the right command | ||
for (i in seq_along(subcommands)) { | ||
subcommand <- subcommands[[i]] | ||
schema <- schema[[which(sapply(schema, function(li) li$name == subcommand))]] | ||
|
||
if (i != length(subcommands)) { | ||
schema <- schema$subcommands | ||
} | ||
} | ||
|
||
# construct yaml | ||
selected_opts <- schema$opts[sapply(schema$opts, function(x) !x$name %in% skip_args)] | ||
input_values <- sapply(selected_opts, function(opt) { | ||
descr <- opt$descr %>% | ||
str_replace_all("@\\[[^]]*\\]\\(([^\\)]*)\\)", "\\1") %>% | ||
str_replace_all(". *$", ".") | ||
|
||
choices_str <- | ||
if (!is.null(opt$choices)) { | ||
paste0(" Possible values are: \"", paste(opt$choices, collapse = "\", \""), "\".") | ||
} else { | ||
"" | ||
} | ||
out <- list( | ||
description = paste0(descr, choices_str), | ||
required = opt$required | ||
) | ||
setNames(list(out), opt$name) | ||
}) | ||
out <- list( | ||
name = schema$bannerCommand, | ||
description = schema$bannerDescription, | ||
inputs = input_values, | ||
# outputs = list( | ||
# output = list( | ||
# description = "A list of all of the components found. By default this will be a yaml, unless the format argument was set to 'json'." | ||
# ) | ||
# ), | ||
runs = list( | ||
using = "node16", | ||
main = "index.js" | ||
) | ||
) | ||
|
||
# write github action | ||
handlers <- list( | ||
logical = function(x) { | ||
result <- ifelse(x, "true", "false") | ||
class(result) <- "verbatim" | ||
return(result) | ||
} | ||
) | ||
yaml::write_yaml( | ||
out, | ||
dest_file, | ||
handlers = handlers | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const core = require("@actions/core"); | ||
const exec = require("@actions/exec"); | ||
|
||
async function run() { | ||
try { | ||
// set up listeners | ||
let myOutput = ""; | ||
let myError = ""; | ||
|
||
const options = {}; | ||
options.listeners = { | ||
stdout: (data) => { | ||
myOutput += data.toString(); | ||
}, | ||
stderr: (data) => { | ||
myError += data.toString(); | ||
} | ||
}; | ||
|
||
// fetch arguments for command | ||
// skip "parallel" | ||
// todo: can I extract these inputNames from the action.yml? | ||
const inputNames = [ | ||
"query", "query_namespace", "query_name", "src", "platform", | ||
"parallel", "config_mod", "target", "setup" | ||
] | ||
const booleanInputs = ["parallel"] | ||
const inputArgs = inputNames.flatMap(function(argName) { | ||
const value = core.getInput(argName) | ||
if (value == "") { | ||
return []; | ||
} else if (booleanInputs.indexOf(argName) >= 0) { | ||
if (value.toLowerCase() == "true") { | ||
return ["--" + argName]; | ||
} else { | ||
return []; | ||
} | ||
} else { | ||
return ["--" + argName, value]; | ||
} | ||
}) | ||
let args = ["ns", "build"].concat(inputArgs); | ||
|
||
// run command | ||
await exec.exec("viash", args, options); | ||
|
||
// pass output | ||
core.setOutput("output", myOutput); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.