From 8d018135fb76c264cc4ab869e3c8f73030ea5bec Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Sat, 24 Feb 2024 21:14:34 +0100 Subject: [PATCH 01/50] Update action.yml --- project/detect-changed-components/action.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 6220206..9cd6448 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -95,7 +95,12 @@ runs: ( [.info.config] + [ - .functionality.resources[], .functionality.test_resources[] + ( + try .functionality.resources[] catch [] + + try .functionality.test_resources[] catch [] + + try .resources[] catch [] + + try .test_resources[] catch [] + ) | select(.path and .parent) | (.parent | sub("^file:(//)?"; "") | sub("/[^/]*$"; "")) + "/" + .path ] @@ -116,4 +121,4 @@ runs: # reformat as json and write to file jq -cs '.' <<< "${output_array[*]}" > "$output_file" - echo "output_file=$output_file" >> $GITHUB_OUTPUT \ No newline at end of file + echo "output_file=$output_file" >> $GITHUB_OUTPUT From 1c6dab7b05f4586d90974725e75e4ab190e4097c Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Sat, 24 Feb 2024 21:34:26 +0100 Subject: [PATCH 02/50] Update jq query --- project/detect-changed-components/action.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 9cd6448..bc99300 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -93,17 +93,18 @@ runs: readarray -t resources < <( jq -cr ' ( - [.info.config] + + .info.config // [] + + .build_info.config // [] + [ ( - try .functionality.resources[] catch [] + - try .functionality.test_resources[] catch [] + - try .resources[] catch [] + - try .test_resources[] catch [] + .functionality.resources // [] + + .functionality.test_resources // [] + + .resources // [] + + .test_resources // [] ) | select(.path and .parent) | (.parent | sub("^file:(//)?"; "") | sub("/[^/]*$"; "")) + "/" + .path - ] + ][] )[] ' <<< "$component" ) From 2220abfa1d47970acc52ea96652e10a506b257ec Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Mon, 17 Jun 2024 17:15:11 +0200 Subject: [PATCH 03/50] update for viash 0.9 --- ns-build/README.md | 34 +++++++++++++++++++--------- ns-build/action.yml | 38 ++++++++++++++++++++++++-------- ns-build/generate_yml.R | 17 ++++++++++---- ns-build/index.js | 2 +- ns-list/README.md | 46 ++++++++++++++++++++------------------ ns-list/action.yml | 49 ++++++++++++++++++++++++----------------- ns-list/generate_yml.R | 18 +++++++++++---- ns-list/index.js | 4 ++-- 8 files changed, 137 insertions(+), 71 deletions(-) diff --git a/ns-build/README.md b/ns-build/README.md index 323d8b1..c5f1658 100644 --- a/ns-build/README.md +++ b/ns-build/README.md @@ -1,5 +1,5 @@ -ns-build -================ +# ns-build + Build a namespace from many viash config files. @@ -22,19 +22,33 @@ We recommend using a Linux or MacOS runner if possible. 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. +- `runner`: - *optional*. Acts as a regular expression to filter the + runner ids specified in the found config files. If this is not + provided, all runners will be used. If no runners are defined in a + config, the executable runner will be used. +- `engine`: - *optional*. Acts as a regular expression to filter the + engine ids specified in the found config files. If this is not + provided, all engines will be used. If no engines are defined in a + config, the native engine will be used. - `parallel`: - *optional*. Whether or not to run the process in parallel. - `config_mod`: - *optional*. Modify a viash config at runtime using - dynamic config modding. + config_mod. - `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\]. +- `colorize`: - *optional*. Specify whether the console output should be + colorized. If not specified, we attempt to detect this automatically. + Possible values are: “true”, “false”, “auto”. +- `loglevel`: - *optional*. Specify the log level in us. Possible values + are: “error”, “warn”, “info”, “debug”, “trace”. +- `setup`: - *optional*. Which docker_setup_strategy for creating the + container to use \[Docker Engine only\]. +- `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. Deprecated in Viash 0.9.0, + will be removed in Viash 1.0.0. ## Examples diff --git a/ns-build/action.yml b/ns-build/action.yml index 8efd0ef..6337fc9 100644 --- a/ns-build/action.yml +++ b/ns-build/action.yml @@ -15,27 +15,47 @@ inputs: regex. Example: "^component1".' required: false src: - description: ' A source directory containing viash config files, possibly structured + 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. + runner: + description: Acts as a regular expression to filter the runner ids specified in + the found config files. If this is not provided, all runners will be used. If + no runners are defined in a config, the executable runner will be used. + required: false + engine: + description: Acts as a regular expression to filter the engine ids specified in + the found config files. If this is not provided, all engines will be used. If + no engines are defined in a config, the native engine will be used. 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. + description: Modify a viash config at runtime using config_mod. required: false target: description: 'A target directory to build the executables into. Default: target/.' required: false + colorize: + description: 'Specify whether the console output should be colorized. If not specified, + we attempt to detect this automatically. Possible values are: "true", "false", + "auto".' + required: false + loglevel: + description: 'Specify the log level in us. Possible values are: "error", "warn", + "info", "debug", "trace".' + required: false setup: - description: Which setup strategy for creating the container to use [Docker Platform - only]. + description: Which docker_setup_strategy for creating the container to use [Docker + Engine only]. + 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. Deprecated + in Viash 0.9.0, will be removed in Viash 1.0.0. required: false runs: using: node20 diff --git a/ns-build/generate_yml.R b/ns-build/generate_yml.R index 4393bab..fc44128 100644 --- a/ns-build/generate_yml.R +++ b/ns-build/generate_yml.R @@ -9,15 +9,15 @@ subcommands <- c("ns", "build") #################### common code # fetch schema -out <- system("viash export cli_schema", intern = TRUE) +out <- system("VIASH_VERSION=0.9.0-RC6 viash export cli_schema --format json", 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))]] + subcommand_names <- sapply(schema, function(li) li$name) + schema <- schema[[which(subcommand_names == subcommands[[i]])]] - if (i != length(subcommands)) { + if ("subcommands" %in% names(schema) && i < length(subcommands)) { schema <- schema$subcommands } } @@ -41,8 +41,17 @@ input_values <- sapply(selected_opts, function(opt) { ) setNames(list(out), opt$name) }) +# workaround for viash 0.9.0-RC6, should be fixed in 0.9.0 +if (!"platform" %in% names(input_values)) { + input_values$platform <- list( + 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. Deprecated in Viash 0.9.0, will be removed in Viash 1.0.0.", + required = FALSE + ) +} + out <- list( name = schema$bannerCommand, + author = "Data Intuitive", description = schema$bannerDescription, inputs = input_values, # outputs = list( diff --git a/ns-build/index.js b/ns-build/index.js index bb67009..6bc34e5 100644 --- a/ns-build/index.js +++ b/ns-build/index.js @@ -22,7 +22,7 @@ async function run() { // todo: can I extract these inputNames from the action.yml? const inputNames = [ "query", "query_namespace", "query_name", "src", "platform", - "parallel", "config_mod", "target", "setup" + "runner", "engine", "parallel", "config_mod", "target", "setup" ] const booleanInputs = ["parallel"] const multilineInputs = ["config_mod"] diff --git a/ns-list/README.md b/ns-list/README.md index d7fa2d1..4479a3e 100644 --- a/ns-list/README.md +++ b/ns-list/README.md @@ -1,5 +1,5 @@ -ns-list -================ +# ns-list + List a namespace containing many viash config files. @@ -21,34 +21,38 @@ We recommend using a Linux or MacOS runner if possible. - `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/”. + possibly structured in a hierarchical folder structure. Default: src/. +- `runner`: - *optional*. Acts as a regular expression to filter the + runner ids specified in the found config files. If this is not + provided, all runners will be used. If no runners are defined in a + config, the executable runner will be used. +- `engine`: - *optional*. Acts as a regular expression to filter the + engine ids specified in the found config files. If this is not + provided, all engines will be used. If no engines are defined in a + config, the native engine will be used. +- `config_mod`: - *optional*. Modify a viash config at runtime using + config_mod. +- `colorize`: - *optional*. Specify whether the console output should be + colorized. If not specified, we attempt to detect this automatically. + Possible values are: “true”, “false”, “auto”. +- `loglevel`: - *optional*. Specify the log level in us. Possible values + are: “error”, “warn”, “info”, “debug”, “trace”. +- `format`: - *optional*. Which output format to use. Possible values + are: “yaml”, “json”. +- `parse_argument_groups`: - *optional*. DEPRECATED. This is now always + enabled. Whether or not to postprocess each component’s + argument_groups. - `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. -- `config_mod`: - *optional*. Modify a viash config at runtime using - dynamic config modding. -- `format`: - *optional*. Which output format to use. Possible values - are: “yaml”, “json”. Default is “yaml”. -- `parse_argument_groups`: - *optional*. Whether or not to postprocess - each component’s argument groups. -- `output_file`: - *optional*. Path of a file to which the output will - be written. If not set, this action will create a file with a random - name in `RUNNER_TEMP`. + platform yaml file can also be specified. Deprecated in Viash 0.9.0, + will be removed in Viash 1.0.0. ### Outputs - `output`: A list of all of the components found. By default this will be a yaml, unless the format argument was set to ‘json’. -- `output_file`: Path of a file to which the output was written (same as - inputs.output_file). We recommend using this property for capturing - the action’s output because there is a limit in the object size that - github actions can manage. Additionally, if you use this property - instead of a static file path, changing the location of the output - file will not require you to adjust settings for downstream actions as - well. ## Examples diff --git a/ns-list/action.yml b/ns-list/action.yml index b1ad7e5..5627d0b 100644 --- a/ns-list/action.yml +++ b/ns-list/action.yml @@ -16,39 +16,48 @@ inputs: required: false src: description: 'A source directory containing viash config files, possibly structured - in a hierarchical folder structure. Default: "src/".' + 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. + runner: + description: Acts as a regular expression to filter the runner ids specified in + the found config files. If this is not provided, all runners will be used. If + no runners are defined in a config, the executable runner will be used. + required: false + engine: + description: Acts as a regular expression to filter the engine ids specified in + the found config files. If this is not provided, all engines will be used. If + no engines are defined in a config, the native engine will be used. required: false config_mod: - description: Modify a viash config at runtime using dynamic config modding. + description: Modify a viash config at runtime using config_mod. + required: false + colorize: + description: 'Specify whether the console output should be colorized. If not specified, + we attempt to detect this automatically. Possible values are: "true", "false", + "auto".' + required: false + loglevel: + description: 'Specify the log level in us. Possible values are: "error", "warn", + "info", "debug", "trace".' required: false format: - description: 'Which output format to use. Possible values are: "yaml", "json". Default is "yaml".' + description: 'Which output format to use. Possible values are: "yaml", "json".' required: false parse_argument_groups: - description: Whether or not to postprocess each component's argument groups. + description: DEPRECATED. This is now always enabled. Whether or not to postprocess + each component's argument_groups. required: false - output_file: + 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. Deprecated + in Viash 0.9.0, will be removed in Viash 1.0.0. required: false - description: > - Path of a file to which the output will be written. If not set, - this action will create a file with a random name in `RUNNER_TEMP`. outputs: output: description: A list of all of the components found. By default this will be a yaml, unless the format argument was set to 'json'. - output_file: - description: > - Path of a file to which the output was written (same as inputs.output_file). - We recommend using this property for capturing the action's output because - there is a limit in the object size that github actions can manage. Additionally, - if you use this property instead of a static file path, changing the location of - the output file will not require you to adjust settings for downstream actions as well. runs: using: node20 main: index.js diff --git a/ns-list/generate_yml.R b/ns-list/generate_yml.R index 10f6da8..6a5e861 100644 --- a/ns-list/generate_yml.R +++ b/ns-list/generate_yml.R @@ -9,15 +9,15 @@ subcommands <- c("ns", "list") #################### common code # fetch schema -out <- system("viash export cli_schema", intern = TRUE) +out <- system("VIASH_VERSION=0.9.0-RC6 viash export cli_schema --format json", 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))]] + subcommand_names <- sapply(schema, function(li) li$name) + schema <- schema[[which(subcommand_names == subcommands[[i]])]] - if (i != length(subcommands)) { + if ("subcommands" %in% names(schema) && i < length(subcommands)) { schema <- schema$subcommands } } @@ -41,8 +41,18 @@ input_values <- sapply(selected_opts, function(opt) { ) setNames(list(out), opt$name) }) + +# workaround for viash 0.9.0-RC6, should be fixed in 0.9.0 +if (!"platform" %in% names(input_values)) { + input_values$platform <- list( + 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. Deprecated in Viash 0.9.0, will be removed in Viash 1.0.0.", + required = FALSE + ) +} + out <- list( name = schema$bannerCommand, + author = "Data Intuitive", description = schema$bannerDescription, inputs = input_values, outputs = list( diff --git a/ns-list/index.js b/ns-list/index.js index 6960b2d..4ae4fc4 100644 --- a/ns-list/index.js +++ b/ns-list/index.js @@ -24,8 +24,8 @@ async function run() { // skip "parallel" // todo: can I extract these inputNames from the action.yml? const inputNames = [ - "query", "query_namespace", "query_name", "src", "platform", - "config_mod", "format", "parse_argument_groups" + "query", "query_namespace", "query_name", "src", "runner", "engine", + "platform", "config_mod", "format", "parse_argument_groups" ] const booleanInputs = ["parse_argument_groups"] const multilineInputs = ["config_mod"] From e67a9ed15701ac6f118e2ee65ed57cfa4ffc202e Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 19 Jun 2024 09:59:27 +0200 Subject: [PATCH 04/50] add matrix to output of ns list --- ns-list/index.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ns-list/index.js b/ns-list/index.js index 4ae4fc4..8776230 100644 --- a/ns-list/index.js +++ b/ns-list/index.js @@ -64,6 +64,41 @@ async function run() { // pass output core.setOutput("output", myOutput); + + // parse json in myOutput + let components = [] + if (core.getInput("format") == "json") { + components = JSON.parse(myOutput); + } else if (core.getInput("format") == "yaml") { + const yaml = require('js-yaml'); + components = yaml.load(myOutput); + } + + // turn into matrix + const matrix = components.map(function(component) { + const comp_name = component?.name ?? component?.functionality?.name + const comp_namespace = component?.namespace ?? component?.functionality?.namespace + const comp_fullname = comp_namespace ? comp_namespace + "/" + comp_name : comp_name + const comp_config = component?.build_info?.config ?? component?.info?.config + const comp_dir = comp_config ? path.dirname(comp_config) : undefined + // todo: if component has a test_resource with a nextflow_script, get the entrypoint? + return { + name: comp_name, + namespace: comp_namespace, + fullname: comp_fullname, + config: comp_config, + dir: comp_dir + } + }) + // return matrix as json + let matrix_str; + if (core.getInput("format") == "json") { + matrix_str = JSON.stringify(matrix); + } else if (core.getInput("format") == "yaml") { + const yaml = require('js-yaml'); + matrix_str = yaml.dump(matrix); + } + core.setOutput("output_matrix", matrix_str); } catch (error) { core.setFailed(error.message); } From e3af58d4a7651b1048d350ec7187781c90ed8a33 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 19 Jun 2024 10:36:27 +0200 Subject: [PATCH 05/50] update docs --- ns-build/README.md | 25 +++++++++++++++++------- ns-build/README.qmd | 20 ++++++++++++++++++- ns-build/action.yml | 22 ++++++++++++++------- ns-build/generate_yml.R | 23 ++++++++++++++-------- ns-list/README.md | 43 ++++++++++++++++++++++++++++++----------- ns-list/README.qmd | 13 ++++++++++--- ns-list/action.yml | 36 ++++++++++++++++++++++++++-------- ns-list/generate_yml.R | 26 +++++++++++++++++++++---- ns-list/index.js | 2 +- 9 files changed, 160 insertions(+), 50 deletions(-) diff --git a/ns-build/README.md b/ns-build/README.md index c5f1658..fd9d140 100644 --- a/ns-build/README.md +++ b/ns-build/README.md @@ -1,6 +1,13 @@ # ns-build + + Build a namespace from many viash config files. ## Usage @@ -11,7 +18,7 @@ each of the arguments. We recommend using a Linux or MacOS runner if possible. -### Inputs available +### Inputs - `query`: - *optional*. Filter which components get selected by component and namespace name. Can be a regex. Example: @@ -22,6 +29,12 @@ We recommend using a Linux or MacOS runner if possible. 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*. Deprecated. Use –runner and –engine instead. + 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. - `runner`: - *optional*. Acts as a regular expression to filter the runner ids specified in the found config files. If this is not provided, all runners will be used. If no runners are defined in a @@ -43,12 +56,10 @@ We recommend using a Linux or MacOS runner if possible. are: “error”, “warn”, “info”, “debug”, “trace”. - `setup`: - *optional*. Which docker_setup_strategy for creating the container to use \[Docker Engine only\]. -- `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. Deprecated in Viash 0.9.0, - will be removed in Viash 1.0.0. + +### Outputs + +- `output`: The output of ‘viash ns build’. ## Examples diff --git a/ns-build/README.qmd b/ns-build/README.qmd index bbcb14d..29db383 100644 --- a/ns-build/README.qmd +++ b/ns-build/README.qmd @@ -3,6 +3,13 @@ title: ns-build format: gfm --- + + ```{r} #| include: false library(tidyverse) @@ -18,7 +25,7 @@ This action will run `viash ns build`. See the reference documentation on [ns bu We recommend using a Linux or MacOS runner if possible. -### Inputs available +### Inputs ```{r} #| echo: false @@ -30,6 +37,17 @@ lines <- map_chr(names(action$inputs), function(name) { knitr::asis_output(paste0(lines, collapse = "\n")) ``` +### Outputs + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + ## Examples ```yaml diff --git a/ns-build/action.yml b/ns-build/action.yml index 6337fc9..4760a32 100644 --- a/ns-build/action.yml +++ b/ns-build/action.yml @@ -1,3 +1,7 @@ +######################################################## +# DO NOT EDIT THIS FILE MANUALLY # +# Please run 'Rscript ns-build/generate_yml.R' instead # +######################################################## name: viash ns build author: Data Intuitive description: Build a namespace from many viash config files. @@ -18,6 +22,13 @@ inputs: description: 'A source directory containing viash config files, possibly structured in a hierarchical folder structure. Default: src/.' required: false + platform: + description: Deprecated. Use --runner and --engine instead. 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 runner: description: Acts as a regular expression to filter the runner ids specified in the found config files. If this is not provided, all runners will be used. If @@ -50,13 +61,10 @@ inputs: description: Which docker_setup_strategy for creating the container to use [Docker Engine only]. 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. Deprecated - in Viash 0.9.0, will be removed in Viash 1.0.0. - required: false +outputs: + output: + description: The output of 'viash ns build'. runs: using: node20 main: index.js + diff --git a/ns-build/generate_yml.R b/ns-build/generate_yml.R index fc44128..41842ae 100644 --- a/ns-build/generate_yml.R +++ b/ns-build/generate_yml.R @@ -9,7 +9,7 @@ subcommands <- c("ns", "build") #################### common code # fetch schema -out <- system("VIASH_VERSION=0.9.0-RC6 viash export cli_schema --format json", intern = TRUE) +out <- system("viash export cli_schema --format json", intern = TRUE) schema <- jsonlite::fromJSON(out, simplifyVector = FALSE) # go down schema to find the right command @@ -54,11 +54,11 @@ out <- list( author = "Data Intuitive", 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'." - # ) - # ), + outputs = list( + output = list( + description = "The output of 'viash ns build'." + ) + ), runs = list( using = "node20", main = "index.js" @@ -73,8 +73,15 @@ handlers <- list( return(result) } ) -yaml::write_yaml( +yaml_str <- yaml::as.yaml( out, - dest_file, handlers = handlers ) +out_str <- c( + "########################################################", + "# DO NOT EDIT THIS FILE MANUALLY #", + "# Please run 'Rscript ns-build/generate_yml.R' instead #", + "########################################################", + yaml_str +) +writeLines(out_str, dest_file) diff --git a/ns-list/README.md b/ns-list/README.md index 4479a3e..0a622f7 100644 --- a/ns-list/README.md +++ b/ns-list/README.md @@ -1,6 +1,13 @@ # ns-list + + List a namespace containing many viash config files. ## Usage @@ -11,7 +18,7 @@ each of the arguments. We recommend using a Linux or MacOS runner if possible. -### Inputs available +### Inputs - `query`: - *optional*. Filter which components get selected by component and namespace name. Can be a regex. Example: @@ -22,6 +29,12 @@ We recommend using a Linux or MacOS runner if possible. 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*. Deprecated. Use –runner and –engine instead. + 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. - `runner`: - *optional*. Acts as a regular expression to filter the runner ids specified in the found config files. If this is not provided, all runners will be used. If no runners are defined in a @@ -42,17 +55,25 @@ We recommend using a Linux or MacOS runner if possible. - `parse_argument_groups`: - *optional*. DEPRECATED. This is now always enabled. Whether or not to postprocess each component’s argument_groups. -- `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. Deprecated in Viash 0.9.0, - will be removed in Viash 1.0.0. +- `output_file`: - *optional*. Path of a file to which the output will + be written. If not set, this action will create a file with a random + name in `RUNNER_TEMP`. ### Outputs -- `output`: A list of all of the components found. By default this will - be a yaml, unless the format argument was set to ‘json’. +- `output`: The output of the ‘viash ns list’ command, which is a list + of all of the components found. By default this will be a yaml, unless + the format argument was set to ‘json’. +- `output_file`: Path of a file to which the output was written (same as + \`inputs.output_file\`\`). We recommend using this property for + capturing the action’s output because there is a limit in the object + size that github actions can manage. Additionally, if you use this + property instead of a static file path, changing the location of the + output file will not require you to adjust settings for downstream + actions as well. +- `output_matrix`: A simplified version of the output, which is a list + of components with fields ‘name’, ‘namespace’, ‘full_name’, ‘config’, + and ‘dir’. ## Examples @@ -73,7 +94,7 @@ jobs: - run: | # do something with the output yaml - echo "${{steps.ns_list.outputs.output}}" + echo "${{steps.ns_list.outputs.output_file}}" viash-macos: runs-on: macos-latest steps: @@ -86,5 +107,5 @@ jobs: - run: | # do something with the output json - echo "${{steps.ns_list.outputs.output}}" + echo "${{steps.ns_list.outputs.output_file}}" ``` diff --git a/ns-list/README.qmd b/ns-list/README.qmd index e4b6d2a..3b48f47 100644 --- a/ns-list/README.qmd +++ b/ns-list/README.qmd @@ -3,6 +3,13 @@ title: ns-list format: gfm --- + + ```{r} #| include: false library(tidyverse) @@ -18,7 +25,7 @@ This action will run `viash ns list`. See the reference documentation on [ns lis We recommend using a Linux or MacOS runner if possible. -### Inputs available +### Inputs ```{r} #| echo: false @@ -60,7 +67,7 @@ jobs: - run: | # do something with the output yaml - echo "${{steps.ns_list.outputs.output}}" + echo "${{steps.ns_list.outputs.output_file}}" viash-macos: runs-on: macos-latest steps: @@ -73,6 +80,6 @@ jobs: - run: | # do something with the output json - echo "${{steps.ns_list.outputs.output}}" + echo "${{steps.ns_list.outputs.output_file}}" ``` diff --git a/ns-list/action.yml b/ns-list/action.yml index 5627d0b..f1658ea 100644 --- a/ns-list/action.yml +++ b/ns-list/action.yml @@ -1,3 +1,7 @@ +######################################################## +# DO NOT EDIT THIS FILE MANUALLY # +# Please run 'Rscript ns-list/generate_yml.R' instead # +######################################################## name: viash ns list author: Data Intuitive description: List a namespace containing many viash config files. @@ -18,6 +22,13 @@ inputs: description: 'A source directory containing viash config files, possibly structured in a hierarchical folder structure. Default: src/.' required: false + platform: + description: Deprecated. Use --runner and --engine instead. 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 runner: description: Acts as a regular expression to filter the runner ids specified in the found config files. If this is not provided, all runners will be used. If @@ -47,17 +58,26 @@ inputs: description: DEPRECATED. This is now always enabled. Whether or not to postprocess each component's argument_groups. 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. Deprecated - in Viash 0.9.0, will be removed in Viash 1.0.0. + output_file: + description: Path of a file to which the output will be written. If not set, this + action will create a file with a random name in `RUNNER_TEMP`. required: false outputs: output: - description: A list of all of the components found. By default this will be a - yaml, unless the format argument was set to 'json'. + description: The output of the 'viash ns list' command, which is a list of all + of the components found. By default this will be a yaml, unless the format argument + was set to 'json'. + output_file: + description: Path of a file to which the output was written (same as `inputs.output_file``). + We recommend using this property for capturing the action’s output because there + is a limit in the object size that github actions can manage. Additionally, + if you use this property instead of a static file path, changing the location + of the output file will not require you to adjust settings for downstream actions + as well. + output_matrix: + description: A simplified version of the output, which is a list of components + with fields 'name', 'namespace', 'full_name', 'config', and 'dir'. runs: using: node20 main: index.js + diff --git a/ns-list/generate_yml.R b/ns-list/generate_yml.R index 6a5e861..446d339 100644 --- a/ns-list/generate_yml.R +++ b/ns-list/generate_yml.R @@ -9,7 +9,7 @@ subcommands <- c("ns", "list") #################### common code # fetch schema -out <- system("VIASH_VERSION=0.9.0-RC6 viash export cli_schema --format json", intern = TRUE) +out <- system("viash export cli_schema --format json", intern = TRUE) schema <- jsonlite::fromJSON(out, simplifyVector = FALSE) # go down schema to find the right command @@ -50,6 +50,11 @@ if (!"platform" %in% names(input_values)) { ) } +input_values$output_file <- list( + description = "Path of a file to which the output will be written. If not set, this action will create a file with a random name in `RUNNER_TEMP`.", + required = FALSE +) + out <- list( name = schema$bannerCommand, author = "Data Intuitive", @@ -57,7 +62,13 @@ out <- list( 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'." + description = "The output of the 'viash ns list' command, which is a list of all of the components found. By default this will be a yaml, unless the format argument was set to 'json'." + ), + output_file = list( + description = "Path of a file to which the output was written (same as `inputs.output_file``). We recommend using this property for capturing the action’s output because there is a limit in the object size that github actions can manage. Additionally, if you use this property instead of a static file path, changing the location of the output file will not require you to adjust settings for downstream actions as well." + ), + output_matrix = list( + description = "A simplified version of the output, which is a list of components with fields 'name', 'namespace', 'full_name', 'config', and 'dir'." ) ), runs = list( @@ -74,8 +85,15 @@ handlers <- list( return(result) } ) -yaml::write_yaml( +yaml_str <- yaml::as.yaml( out, - dest_file, handlers = handlers ) +out_str <- c( + "########################################################", + "# DO NOT EDIT THIS FILE MANUALLY #", + "# Please run 'Rscript ns-list/generate_yml.R' instead #", + "########################################################", + yaml_str +) +writeLines(out_str, dest_file) diff --git a/ns-list/index.js b/ns-list/index.js index 8776230..88f4517 100644 --- a/ns-list/index.js +++ b/ns-list/index.js @@ -85,7 +85,7 @@ async function run() { return { name: comp_name, namespace: comp_namespace, - fullname: comp_fullname, + full_name: comp_fullname, config: comp_config, dir: comp_dir } From b5652afda0e9337a85c70c0abf9d817d3b233815 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 08:22:55 +0200 Subject: [PATCH 06/50] fix description --- ns-list/action.yml | 2 +- ns-list/generate_yml.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ns-list/action.yml b/ns-list/action.yml index f1658ea..49d1259 100644 --- a/ns-list/action.yml +++ b/ns-list/action.yml @@ -69,7 +69,7 @@ outputs: was set to 'json'. output_file: description: Path of a file to which the output was written (same as `inputs.output_file``). - We recommend using this property for capturing the action’s output because there + We recommend using this property for capturing the action's output because there is a limit in the object size that github actions can manage. Additionally, if you use this property instead of a static file path, changing the location of the output file will not require you to adjust settings for downstream actions diff --git a/ns-list/generate_yml.R b/ns-list/generate_yml.R index 446d339..bcb3c95 100644 --- a/ns-list/generate_yml.R +++ b/ns-list/generate_yml.R @@ -65,7 +65,7 @@ out <- list( description = "The output of the 'viash ns list' command, which is a list of all of the components found. By default this will be a yaml, unless the format argument was set to 'json'." ), output_file = list( - description = "Path of a file to which the output was written (same as `inputs.output_file``). We recommend using this property for capturing the action’s output because there is a limit in the object size that github actions can manage. Additionally, if you use this property instead of a static file path, changing the location of the output file will not require you to adjust settings for downstream actions as well." + description = "Path of a file to which the output was written (same as `inputs.output_file``). We recommend using this property for capturing the action's output because there is a limit in the object size that github actions can manage. Additionally, if you use this property instead of a static file path, changing the location of the output file will not require you to adjust settings for downstream actions as well." ), output_matrix = list( description = "A simplified version of the output, which is a list of components with fields 'name', 'namespace', 'full_name', 'config', and 'dir'." From 181261ec17e3dc5c2537ffc6afae3cd4303fab28 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 08:23:03 +0200 Subject: [PATCH 07/50] add more actions --- project/build-target/README.md | 43 ++++++++++++++++++++++ project/build-target/action.yml | 65 +++++++++++++++++++++++++++++++++ project/is-pr/README.md | 31 ++++++++++++++++ project/is-pr/action.yml | 26 +++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 project/build-target/README.md create mode 100644 project/build-target/action.yml create mode 100644 project/is-pr/README.md create mode 100644 project/is-pr/action.yml diff --git a/project/build-target/README.md b/project/build-target/README.md new file mode 100644 index 0000000..e6df963 --- /dev/null +++ b/project/build-target/README.md @@ -0,0 +1,43 @@ +# Build the target directory + +This action will build a target directory using the `viash ns build` command. + +## Usage + +This action will build a target directory using the `viash ns build` command. + +### Inputs + +- `target_branch`: - *optional*. Branch to deploy to. If not specified, `build-${BRANCH_NAME}` will be used. +- `version`: - *optional*. Version name to use for the build. If not specified, `build-${BRANCH_NAME}` will be used. + +### Outputs + +- `docker_component_matrix`: Matrix of Docker components +- `component_matrix`: Matrix of components + +### Examples + +```yaml +name: demo of build-target + +on: + branch: main + +jobs: + build-target: + runs-on: ubuntu-latest + steps: + - uses: viash-io/viash-actions/setup@v3 + + - id: build_target + uses: viash-io/viash-actions/build-target@v5 + + - run: | + # view target directory + ls -l target/ + + # do something with the output + echo "${{steps.build_target.outputs.docker_component_matrix}}" + echo "${{steps.build_target.outputs.component_matrix}}" +``` diff --git a/project/build-target/action.yml b/project/build-target/action.yml new file mode 100644 index 0000000..fac1bfb --- /dev/null +++ b/project/build-target/action.yml @@ -0,0 +1,65 @@ +name: Build target directory +author: Data Intuitive +description: > + Builds a target directory using the viash ns build command. +inputs: + target_branch: + description: 'Branch to deploy to. If not specified, `build-${BRANCH_NAME}` will be used.' + required: false + version: + description: 'Version name to use for the build. If not specified, `build-${BRANCH_NAME}` will be used.' + required: false +outputs: + docker_component_matrix: + description: Matrix of Docker components + value: ${{ steps.ns_list_docker.outputs.output_matrix }} + component_matrix: + description: Matrix of components + value: ${{ steps.ns_list.outputs.output_matrix }} + +runs: + using: 'composite' + steps: + - name: Determine version tag from branch name + shell: bash + id: defaults + run: | + BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///') + VERSION=${{ inputs.version }} + if [ -z "$VERSION" ]; then + VERSION="build-$BRANCH_NAME" + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + + TARGET_BRANCH=${{ inputs.target_branch }} + if [ -z "$TARGET_BRANCH" ]; then + TARGET_BRANCH="build-$BRANCH_NAME" + fi + echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT + + - name: Remove target folder from .gitignore + shell: bash + run: | + # allow publishing the target folder + sed -i '/^\/?target.*/d' .gitignore + + - name: Set version in _viash.yaml + shell: bash + run: | + jq '.version = "${{ steps.defaults.outputs.version }}"' _viash.yaml > _viash.yaml.tmp && \ + mv _viash.yaml.tmp _viash.yaml + + - uses: viash-io/viash-actions/ns-build@v5 + with: + parallel: true + + - id: ns_list_docker + uses: viash-io/viash-actions/ns-list@v5 + with: + engine: docker + format: json + + - id: ns_list + uses: viash-io/viash-actions/ns-list@v5 + with: + format: json \ No newline at end of file diff --git a/project/is-pr/README.md b/project/is-pr/README.md new file mode 100644 index 0000000..96fe0f5 --- /dev/null +++ b/project/is-pr/README.md @@ -0,0 +1,31 @@ +# Is PR + +Check whether the branch has a PR and if this run was triggered by a push event. + +## Usage + +This action will check whether the branch has a PR and if this run was triggered by a push event. + +### Outputs + +- `check`: Returns "true" if the branch has a PR and this run was not triggered by a push event, else "false". + +### Examples + +```yaml +name: Is PR + +on: + push: + pull_request: + +jobs: + is-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: viash-io/viash-actions/is-pr@v1 + id: is_pr + - run: | + echo "Is PR: ${{ steps.is_pr.outputs.check }}" +``` diff --git a/project/is-pr/action.yml b/project/is-pr/action.yml new file mode 100644 index 0000000..c135a6b --- /dev/null +++ b/project/is-pr/action.yml @@ -0,0 +1,26 @@ +name: Is PR +author: Data Intuitive +description: > + Check whether the branch has a PR and if this run was triggered by a push event. +outputs: + check: + description: 'Returns "true" if the branch has a PR and this run was not triggered by a push event, else "false".' + value: ${{ steps.github_cli.outputs.check }} + +runs: + using: 'composite' + steps: + - name: 'Check whether the branch has a PR and if this run was triggered by a push event' + shell: bash + id: github_cli + run: | + pull_request=$(gh pr list -R ${{ github.repository }} -H ${{ github.ref_name }} --json url --state open --limit 1 | jq '.[0].url') + + # If the branch has a PR and this run was triggered by a push event, do not run + if [[ "$pull_request" != "null" && "$GITHUB_REF_NAME" != "main" && "${{ github.event_name == 'push' }}" == "true" && "${{ !contains(github.event.head_commit.message, 'ci force') }}" == "true" ]]; then + echo "check=false" >> $GITHUB_OUTPUT + else + echo "check=true" >> $GITHUB_OUTPUT + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From fa0303de4958409151d579c60bf1ccc0a6754fb2 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 08:30:48 +0200 Subject: [PATCH 08/50] update action --- project/build-target/action.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index fac1bfb..f059f9d 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -3,6 +3,9 @@ author: Data Intuitive description: > Builds a target directory using the viash ns build command. inputs: + github_token: + description: 'GitHub token. If not specified, the default GITHUB_TOKEN will be used.' + required: true target_branch: description: 'Branch to deploy to. If not specified, `build-${BRANCH_NAME}` will be used.' required: false @@ -10,6 +13,12 @@ inputs: description: 'Version name to use for the build. If not specified, `build-${BRANCH_NAME}` will be used.' required: false outputs: + target_branch: + description: 'The branch that the build was deployed to.' + value: ${{ steps.defaults.outputs.target_branch }} + version: + description: 'The version that was used for the build.' + value: ${{ steps.defaults.outputs.version }} docker_component_matrix: description: Matrix of Docker components value: ${{ steps.ns_list_docker.outputs.output_matrix }} @@ -37,6 +46,12 @@ runs: fi echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT + GTHB_TOKEN=${{ inputs.github_token }} + if [ -z "$GTHB_TOKEN" ]; then + GTHB_TOKEN=$GITHUB_TOKEN + fi + echo "github_token=$GTHB_TOKEN" >> $GITHUB_OUTPUT + - name: Remove target folder from .gitignore shell: bash run: | @@ -53,13 +68,22 @@ runs: with: parallel: true - - id: ns_list_docker + - name: Deploy to target branch + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ steps.defaults.outputs.github_token }} + publish_branch: ${{ steps.defaults.outputs.target_branch }} + publish_dir: . + + - name: List Docker components + id: ns_list_docker uses: viash-io/viash-actions/ns-list@v5 with: engine: docker format: json - - id: ns_list + - name: List components + id: ns_list uses: viash-io/viash-actions/ns-list@v5 with: format: json \ No newline at end of file From d1628e9bfe1b29b92dbc542ba24093758c6809ba Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 08:34:29 +0200 Subject: [PATCH 09/50] update readme --- project/build-target/README.md | 25 ++++++++---- project/build-target/README.qmd | 68 +++++++++++++++++++++++++++++++++ project/is-pr/README.md | 21 ++++++---- project/is-pr/README.qmd | 62 ++++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 15 deletions(-) create mode 100644 project/build-target/README.qmd create mode 100644 project/is-pr/README.qmd diff --git a/project/build-target/README.md b/project/build-target/README.md index e6df963..319c5a8 100644 --- a/project/build-target/README.md +++ b/project/build-target/README.md @@ -1,24 +1,33 @@ -# Build the target directory +# build-target -This action will build a target directory using the `viash ns build` command. -## Usage + -This action will build a target directory using the `viash ns build` command. +Builds a target directory using the viash ns build command. ### Inputs -- `target_branch`: - *optional*. Branch to deploy to. If not specified, `build-${BRANCH_NAME}` will be used. -- `version`: - *optional*. Version name to use for the build. If not specified, `build-${BRANCH_NAME}` will be used. +- `github_token`: - *required*. GitHub token. If not specified, the + default GITHUB_TOKEN will be used. +- `target_branch`: - *optional*. Branch to deploy to. If not specified, + `build-${BRANCH_NAME}` will be used. +- `version`: - *optional*. Version name to use for the build. If not + specified, `build-${BRANCH_NAME}` will be used. ### Outputs +- `target_branch`: The branch that the build was deployed to. +- `version`: The version that was used for the build. - `docker_component_matrix`: Matrix of Docker components - `component_matrix`: Matrix of components -### Examples +## Examples -```yaml +``` yaml name: demo of build-target on: diff --git a/project/build-target/README.qmd b/project/build-target/README.qmd new file mode 100644 index 0000000..657df47 --- /dev/null +++ b/project/build-target/README.qmd @@ -0,0 +1,68 @@ +--- +title: build-target +format: gfm +--- + + + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +``` + +`r action$description` + +### Inputs + +```{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")) +``` + +### Outputs + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +## Examples + +```yaml +name: demo of build-target + +on: + branch: main + +jobs: + build-target: + runs-on: ubuntu-latest + steps: + - uses: viash-io/viash-actions/setup@v3 + + - id: build_target + uses: viash-io/viash-actions/build-target@v5 + + - run: | + # view target directory + ls -l target/ + + # do something with the output + echo "${{steps.build_target.outputs.docker_component_matrix}}" + echo "${{steps.build_target.outputs.component_matrix}}" +``` + diff --git a/project/is-pr/README.md b/project/is-pr/README.md index 96fe0f5..1a988bd 100644 --- a/project/is-pr/README.md +++ b/project/is-pr/README.md @@ -1,18 +1,25 @@ -# Is PR +# build-target -Check whether the branch has a PR and if this run was triggered by a push event. -## Usage + -This action will check whether the branch has a PR and if this run was triggered by a push event. +Check whether the branch has a PR and if this run was triggered by a +push event. + +### Inputs ### Outputs -- `check`: Returns "true" if the branch has a PR and this run was not triggered by a push event, else "false". +- `check`: Returns “true” if the branch has a PR and this run was not + triggered by a push event, else “false”. -### Examples +## Examples -```yaml +``` yaml name: Is PR on: diff --git a/project/is-pr/README.qmd b/project/is-pr/README.qmd new file mode 100644 index 0000000..4031b56 --- /dev/null +++ b/project/is-pr/README.qmd @@ -0,0 +1,62 @@ +--- +title: build-target +format: gfm +--- + + + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +``` + +`r action$description` + +### Inputs + +```{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")) +``` + +### Outputs + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +## Examples + +```yaml +name: Is PR + +on: + push: + pull_request: + +jobs: + is-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: viash-io/viash-actions/is-pr@v1 + id: is_pr + - run: | + echo "Is PR: ${{ steps.is_pr.outputs.check }}" +``` + From dd782425d510e74f0751b2776d0cc3afc3e6f64e Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 09:58:52 +0200 Subject: [PATCH 10/50] remove functionality --- project/build-target/action.yml | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index f059f9d..b643e3b 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -2,16 +2,15 @@ name: Build target directory author: Data Intuitive description: > Builds a target directory using the viash ns build command. + inputs: - github_token: - description: 'GitHub token. If not specified, the default GITHUB_TOKEN will be used.' - required: true target_branch: - description: 'Branch to deploy to. If not specified, `build-${BRANCH_NAME}` will be used.' + description: 'Branch to deploy to. If not specified, `${BRANCH_NAME}_build` will be used.' required: false version: - description: 'Version name to use for the build. If not specified, `build-${BRANCH_NAME}` will be used.' + description: 'Version name to use for the build. If not specified, `${BRANCH_NAME}_build` will be used.' required: false + outputs: target_branch: description: 'The branch that the build was deployed to.' @@ -33,16 +32,16 @@ runs: shell: bash id: defaults run: | - BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///') + BRANCH_NAME=$(echo $GITHUB_REF | sed 's/refs\/heads\///' | sed 's/[^a-zA-Z0-9_]/_/g') VERSION=${{ inputs.version }} if [ -z "$VERSION" ]; then - VERSION="build-$BRANCH_NAME" + VERSION="${BRANCH_NAME}_build" fi echo "version=$VERSION" >> $GITHUB_OUTPUT TARGET_BRANCH=${{ inputs.target_branch }} if [ -z "$TARGET_BRANCH" ]; then - TARGET_BRANCH="build-$BRANCH_NAME" + TARGET_BRANCH="${BRANCH_NAME}_build" fi echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT @@ -64,26 +63,19 @@ runs: jq '.version = "${{ steps.defaults.outputs.version }}"' _viash.yaml > _viash.yaml.tmp && \ mv _viash.yaml.tmp _viash.yaml - - uses: viash-io/viash-actions/ns-build@v5 + - uses: ../../ns-build with: parallel: true - - name: Deploy to target branch - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ steps.defaults.outputs.github_token }} - publish_branch: ${{ steps.defaults.outputs.target_branch }} - publish_dir: . - - name: List Docker components id: ns_list_docker - uses: viash-io/viash-actions/ns-list@v5 + uses: ../../ns-list with: engine: docker format: json - name: List components id: ns_list - uses: viash-io/viash-actions/ns-list@v5 + uses: ../../ns-list with: format: json \ No newline at end of file From 53e954951d2993d9992526eba1733c57756cd5b0 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 10:00:07 +0200 Subject: [PATCH 11/50] remove variable --- project/build-target/action.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index b643e3b..20717f6 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -45,12 +45,6 @@ runs: fi echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT - GTHB_TOKEN=${{ inputs.github_token }} - if [ -z "$GTHB_TOKEN" ]; then - GTHB_TOKEN=$GITHUB_TOKEN - fi - echo "github_token=$GTHB_TOKEN" >> $GITHUB_OUTPUT - - name: Remove target folder from .gitignore shell: bash run: | From 99cabaaac46fa867b8bc2bd28d02d444b6102861 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 10:24:21 +0200 Subject: [PATCH 12/50] update action --- project/build-target/README.md | 10 +++--- project/build-target/action.yml | 56 +++++++++++++++++++++++---------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/project/build-target/README.md b/project/build-target/README.md index 319c5a8..d5adf34 100644 --- a/project/build-target/README.md +++ b/project/build-target/README.md @@ -11,19 +11,17 @@ Builds a target directory using the viash ns build command. ### Inputs -- `github_token`: - *required*. GitHub token. If not specified, the - default GITHUB_TOKEN will be used. - `target_branch`: - *optional*. Branch to deploy to. If not specified, - `build-${BRANCH_NAME}` will be used. + `${BRANCH_NAME}_build` will be used. - `version`: - *optional*. Version name to use for the build. If not - specified, `build-${BRANCH_NAME}` will be used. + specified, `${BRANCH_NAME}_build` will be used. ### Outputs - `target_branch`: The branch that the build was deployed to. - `version`: The version that was used for the build. -- `docker_component_matrix`: Matrix of Docker components -- `component_matrix`: Matrix of components +- `docker_matrix`: Matrix of executables for which Docker containers + need to be built. ## Examples diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 20717f6..099159f 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -18,12 +18,9 @@ outputs: version: description: 'The version that was used for the build.' value: ${{ steps.defaults.outputs.version }} - docker_component_matrix: - description: Matrix of Docker components + docker_matrix: + description: Matrix of executables for which Docker containers need to be built. value: ${{ steps.ns_list_docker.outputs.output_matrix }} - component_matrix: - description: Matrix of components - value: ${{ steps.ns_list.outputs.output_matrix }} runs: using: 'composite' @@ -45,11 +42,16 @@ runs: fi echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT + TARGET_DIR=$(yq -r '.target' _viash.yaml) + if [ -z "$TARGET_DIR" ]; then + TARGET_DIR="target" + fi + echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT + - name: Remove target folder from .gitignore shell: bash run: | - # allow publishing the target folder - sed -i '/^\/?target.*/d' .gitignore + sed -i '/^\/?${{ steps.defaults.outputs.target_dir }}.*/d' .gitignore - name: Set version in _viash.yaml shell: bash @@ -61,15 +63,35 @@ runs: with: parallel: true - - name: List Docker components + - name: Find Docker Executables that need to be built id: ns_list_docker - uses: ../../ns-list - with: - engine: docker - format: json + shell: bash + run: | + TARGET_DIR=`${{ steps.defaults.outputs.target_dir }}` - - name: List components - id: ns_list - uses: ../../ns-list - with: - format: json \ No newline at end of file + BUILT_CONFIGS=`find "$TARGET_DIR" -name .config.vsh.yaml` + + OUTPUT="[" + + for yaml in $BUILT_CONFIGS; do + RUNNER=`yq -r ".build_info.runner" $yaml` + ENGINE=`yq -r ".build_info.engine // .info.platform" $yaml` + NAME=`yq -r ".name // .functionality.name" $yaml` + NAMESPACE=`yq -r ".namespace // .functionality.namespace" $yaml` + if [ "$NAMESPACE" != "null" ]; then + FULL_NAME="$NAMESPACE/$NAME" + else + FULL_NAME="$NAME" + fi + CONFIG=`yq -r ".build_info.config // .info.config" $yaml` + SRC_DIR=`dirname $CONFIG` + TARGET_DIR=`dirname $yaml` + EXECUTABLE=`yq -r ".build_info.executable // .info.executable" $yaml` + + JSON="{\"runner\":\"$RUNNER\",\"engine\":\"$ENGINE\",\"name\":\"$FULL_NAME\",\"config\":\"$CONFIG\",\"src_dir\":\"$SRC_DIR\",\"target_dir\":\"$TARGET_DIR\",\"executable\":\"$EXECUTABLE\"}" + OUTPUT="$OUTPUT$JSON," + done + + OUTPUT="${OUTPUT%,}]" + + echo "output_matrix=$OUTPUT" >> $GITHUB_OUTPUT \ No newline at end of file From ee043a8543b8dd50641e9593bcf2be06cc3acd8e Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 11:34:20 +0200 Subject: [PATCH 13/50] update --- project/build-target/README.md | 9 ++++--- project/build-target/action.yml | 48 ++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/project/build-target/README.md b/project/build-target/README.md index d5adf34..cfff8c3 100644 --- a/project/build-target/README.md +++ b/project/build-target/README.md @@ -11,15 +11,18 @@ Builds a target directory using the viash ns build command. ### Inputs -- `target_branch`: - *optional*. Branch to deploy to. If not specified, - `${BRANCH_NAME}_build` will be used. - `version`: - *optional*. Version name to use for the build. If not specified, `${BRANCH_NAME}_build` will be used. +- `target_branch`: - *optional*. Branch to deploy to. If not specified, + `${BRANCH_NAME}_build` will be used. +- `image_tag`: - *optional*. Force the built components to use a + specific Docker image tag. +- `viash_pro_token`: - *optional*. Viash pro token ### Outputs -- `target_branch`: The branch that the build was deployed to. - `version`: The version that was used for the build. +- `target_branch`: The branch that the build was deployed to. - `docker_matrix`: Matrix of executables for which Docker containers need to be built. diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 099159f..4886162 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -4,20 +4,26 @@ description: > Builds a target directory using the viash ns build command. inputs: + version: + description: 'Version name to use for the build. If not specified, `${BRANCH_NAME}_build` will be used.' + required: false target_branch: description: 'Branch to deploy to. If not specified, `${BRANCH_NAME}_build` will be used.' required: false - version: - description: 'Version name to use for the build. If not specified, `${BRANCH_NAME}_build` will be used.' + image_tag: + description: 'Force the built components to use a specific Docker image tag.' + required: false + viash_pro_token: + description: 'Viash pro token' required: false outputs: - target_branch: - description: 'The branch that the build was deployed to.' - value: ${{ steps.defaults.outputs.target_branch }} version: description: 'The version that was used for the build.' value: ${{ steps.defaults.outputs.version }} + target_branch: + description: 'The branch that the build was deployed to.' + value: ${{ steps.defaults.outputs.target_branch }} docker_matrix: description: Matrix of executables for which Docker containers need to be built. value: ${{ steps.ns_list_docker.outputs.output_matrix }} @@ -48,6 +54,16 @@ runs: fi echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT + VIASH_VERSION=`viash -v | grep -oP 'viash \K[0-9.]+'` + if [[ -z "${{inputs.image_tag }}" ]]; then + CONFIG_MOD="" + elif [ "$(printf '%s\n' "0.9.0" "$VIASH_VERSION" | sort -V | head -n1)" == "0.9.0" ]; then + CONFIG_MOD='.platforms[.type == "docker"].target_tag := "${{ inputs.image_tag }}"' + else + CONFIG_MOD='.engines[.type == "docker"].target_tag := "${{ inputs.image_tag }}"' + fi + echo "config_mod=$CONFIG_MOD" >> $GITHUB_OUTPUT + - name: Remove target folder from .gitignore shell: bash run: | @@ -62,6 +78,26 @@ runs: - uses: ../../ns-build with: parallel: true + config_mod: ${{ steps.defaults.outputs.config_mod }} + + - name: Build nextflow schemas + if: ${{ inputs.viash_pro_token != '' }} + uses: viash-io/viash-actions/pro/build-nextflow-schemas@v5 + with: + components: src + workflows: src + viash_pro_token: ${{ secrets.GTHB_PAT }} + tools_version: 'main_build' + enable_dataset_input: true + + - name: Build parameter files + if: ${{ inputs.viash_pro_token != '' }} + uses: viash-io/viash-actions/pro/build-nextflow-params@v5 + with: + workflows: src + components: src + viash_pro_token: ${{ secrets.GTHB_PAT }} + tools_version: 'main_build' - name: Find Docker Executables that need to be built id: ns_list_docker @@ -94,4 +130,4 @@ runs: OUTPUT="${OUTPUT%,}]" - echo "output_matrix=$OUTPUT" >> $GITHUB_OUTPUT \ No newline at end of file + echo "output_matrix=$OUTPUT" >> $GITHUB_OUTPUT From 40cf5e4a2b9eaf9b11396ade6a584c540adef250 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 11:44:01 +0200 Subject: [PATCH 14/50] fix action --- project/build-target/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 4886162..ab9a08c 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -86,7 +86,7 @@ runs: with: components: src workflows: src - viash_pro_token: ${{ secrets.GTHB_PAT }} + viash_pro_token: ${{ inputs.viash_pro_token }} tools_version: 'main_build' enable_dataset_input: true @@ -96,7 +96,7 @@ runs: with: workflows: src components: src - viash_pro_token: ${{ secrets.GTHB_PAT }} + viash_pro_token: ${{ inputs.viash_pro_token }} tools_version: 'main_build' - name: Find Docker Executables that need to be built From db639cf08d02a9474afbde87aab59a33f2689e1d Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 11:48:25 +0200 Subject: [PATCH 15/50] fix action --- project/build-target/action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index ab9a08c..1eda705 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -26,7 +26,7 @@ outputs: value: ${{ steps.defaults.outputs.target_branch }} docker_matrix: description: Matrix of executables for which Docker containers need to be built. - value: ${{ steps.ns_list_docker.outputs.output_matrix }} + value: ${{ steps.find_docker_executables.outputs.output_matrix }} runs: using: 'composite' @@ -75,14 +75,14 @@ runs: jq '.version = "${{ steps.defaults.outputs.version }}"' _viash.yaml > _viash.yaml.tmp && \ mv _viash.yaml.tmp _viash.yaml - - uses: ../../ns-build + - uses: ./ns-build with: parallel: true config_mod: ${{ steps.defaults.outputs.config_mod }} - name: Build nextflow schemas if: ${{ inputs.viash_pro_token != '' }} - uses: viash-io/viash-actions/pro/build-nextflow-schemas@v5 + uses: ./pro/build-nextflow-schemas with: components: src workflows: src @@ -92,7 +92,7 @@ runs: - name: Build parameter files if: ${{ inputs.viash_pro_token != '' }} - uses: viash-io/viash-actions/pro/build-nextflow-params@v5 + uses: ./pro/build-nextflow-params with: workflows: src components: src @@ -100,7 +100,7 @@ runs: tools_version: 'main_build' - name: Find Docker Executables that need to be built - id: ns_list_docker + id: find_docker_executables shell: bash run: | TARGET_DIR=`${{ steps.defaults.outputs.target_dir }}` From 2eb4933b91d35b9333b73aad2207dc8956e54403 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 12:02:48 +0200 Subject: [PATCH 16/50] fix ci --- project/build-target/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 1eda705..fceef3c 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -72,8 +72,7 @@ runs: - name: Set version in _viash.yaml shell: bash run: | - jq '.version = "${{ steps.defaults.outputs.version }}"' _viash.yaml > _viash.yaml.tmp && \ - mv _viash.yaml.tmp _viash.yaml + yq eval '.version = "${{ steps.defaults.outputs.version }}"' -i _viash.yaml - uses: ./ns-build with: From 6481bacdb288fe93c2845101bfa7b5075dd2eb2e Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:15:55 +0200 Subject: [PATCH 17/50] pin versions --- project/build-target/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index fceef3c..07cbec0 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -74,14 +74,14 @@ runs: run: | yq eval '.version = "${{ steps.defaults.outputs.version }}"' -i _viash.yaml - - uses: ./ns-build + - uses: viash-io/viash-actions/ns-build@viash-0.9 with: parallel: true config_mod: ${{ steps.defaults.outputs.config_mod }} - name: Build nextflow schemas if: ${{ inputs.viash_pro_token != '' }} - uses: ./pro/build-nextflow-schemas + uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 with: components: src workflows: src @@ -91,7 +91,7 @@ runs: - name: Build parameter files if: ${{ inputs.viash_pro_token != '' }} - uses: ./pro/build-nextflow-params + uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 with: workflows: src components: src From 1526efa491b7090c9527cf50d577ff5d464f4b8b Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:20:02 +0200 Subject: [PATCH 18/50] fix action --- project/build-target/action.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 07cbec0..6698a1f 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -48,10 +48,7 @@ runs: fi echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT - TARGET_DIR=$(yq -r '.target' _viash.yaml) - if [ -z "$TARGET_DIR" ]; then - TARGET_DIR="target" - fi + TARGET_DIR=$(yq -r '.target // "target"' _viash.yaml) echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT VIASH_VERSION=`viash -v | grep -oP 'viash \K[0-9.]+'` From e8a2ed287287ce95ca4b7d47d89a1f208d92bfa4 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:21:35 +0200 Subject: [PATCH 19/50] fix ci --- project/build-target/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 6698a1f..87af81c 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -99,7 +99,7 @@ runs: id: find_docker_executables shell: bash run: | - TARGET_DIR=`${{ steps.defaults.outputs.target_dir }}` + TARGET_DIR="${{ steps.defaults.outputs.target_dir }}" BUILT_CONFIGS=`find "$TARGET_DIR" -name .config.vsh.yaml` From 4f53681cae66987fb2230fa712d66dca9a25b339 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:26:51 +0200 Subject: [PATCH 20/50] fix ci --- project/build-target/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 87af81c..1b36db4 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -108,6 +108,11 @@ runs: for yaml in $BUILT_CONFIGS; do RUNNER=`yq -r ".build_info.runner" $yaml` ENGINE=`yq -r ".build_info.engine // .info.platform" $yaml` + + # skip if not an executable or does not use a docker engine + if [ "$RUNNER" != "executable" ] || [[ "$ENGINE" != *"docker"* ]]; then + continue + fi NAME=`yq -r ".name // .functionality.name" $yaml` NAMESPACE=`yq -r ".namespace // .functionality.namespace" $yaml` if [ "$NAMESPACE" != "null" ]; then @@ -120,6 +125,8 @@ runs: TARGET_DIR=`dirname $yaml` EXECUTABLE=`yq -r ".build_info.executable // .info.executable" $yaml` + echo "Found Docker executable: $FULL_NAME" + JSON="{\"runner\":\"$RUNNER\",\"engine\":\"$ENGINE\",\"name\":\"$FULL_NAME\",\"config\":\"$CONFIG\",\"src_dir\":\"$SRC_DIR\",\"target_dir\":\"$TARGET_DIR\",\"executable\":\"$EXECUTABLE\"}" OUTPUT="$OUTPUT$JSON," done From 5682e297ec4cb864fcacc8b1538e27acc8ec9424 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:29:21 +0200 Subject: [PATCH 21/50] fix ci --- project/build-target/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 1b36db4..d315129 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -127,7 +127,7 @@ runs: echo "Found Docker executable: $FULL_NAME" - JSON="{\"runner\":\"$RUNNER\",\"engine\":\"$ENGINE\",\"name\":\"$FULL_NAME\",\"config\":\"$CONFIG\",\"src_dir\":\"$SRC_DIR\",\"target_dir\":\"$TARGET_DIR\",\"executable\":\"$EXECUTABLE\"}" + JSON="{\"name\":\"$NAME\",\"namespace\":\"$NAMESPACE\",\"full_name\":\"$FULL_NAME\",\"config\":\"$CONFIG\",\"dir\":\"$SRC_DIR\",\"target\":\"$TARGET_DIR\",\"executable\":\"$EXECUTABLE\",\"runner\":\"$RUNNER\",\"engine\":\"$ENGINE\"}" OUTPUT="$OUTPUT$JSON," done From 805d899b49eb3a9186cc179db8c4af994f5dd1ce Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:35:15 +0200 Subject: [PATCH 22/50] fix ci --- project/build-target/action.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index d315129..8b36957 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -114,11 +114,11 @@ runs: continue fi NAME=`yq -r ".name // .functionality.name" $yaml` - NAMESPACE=`yq -r ".namespace // .functionality.namespace" $yaml` - if [ "$NAMESPACE" != "null" ]; then - FULL_NAME="$NAMESPACE/$NAME" - else + NAMESPACE=`yq -r '.namespace // .functionality.namespace // ""' $yaml` + if [ -z "$NAMESPACE" ]; then FULL_NAME="$NAME" + else + FULL_NAME="$NAMESPACE/$NAME" fi CONFIG=`yq -r ".build_info.config // .info.config" $yaml` SRC_DIR=`dirname $CONFIG` @@ -127,8 +127,13 @@ runs: echo "Found Docker executable: $FULL_NAME" - JSON="{\"name\":\"$NAME\",\"namespace\":\"$NAMESPACE\",\"full_name\":\"$FULL_NAME\",\"config\":\"$CONFIG\",\"dir\":\"$SRC_DIR\",\"target\":\"$TARGET_DIR\",\"executable\":\"$EXECUTABLE\",\"runner\":\"$RUNNER\",\"engine\":\"$ENGINE\"}" - OUTPUT="$OUTPUT$JSON," + JSON_FIELDS="" + for key in NAME NAMESPACE RUNNER ENGINE CONFIG EXECUTABLE SRC_DIR TARGET_DIR FULL_NAME; do + key_lower=`echo $key | tr '[:upper:]' '[:lower:]'` + JSON_FIELDS="$JSON_FIELDS\"${key_lower}\":\"${key}\"," + done + + OUTPUT="$OUTPUT{${JSON_FIELDS%,}}," done OUTPUT="${OUTPUT%,}]" From 7e5c61e8ea8938c4161d0aba71e6080c23f0e220 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:36:28 +0200 Subject: [PATCH 23/50] fix ci --- project/build-target/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 8b36957..942f3d9 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -130,7 +130,7 @@ runs: JSON_FIELDS="" for key in NAME NAMESPACE RUNNER ENGINE CONFIG EXECUTABLE SRC_DIR TARGET_DIR FULL_NAME; do key_lower=`echo $key | tr '[:upper:]' '[:lower:]'` - JSON_FIELDS="$JSON_FIELDS\"${key_lower}\":\"${key}\"," + JSON_FIELDS="$JSON_FIELDS\"${key_lower}\":\"${!key}\"," done OUTPUT="$OUTPUT{${JSON_FIELDS%,}}," From bc1938cd85bb06fbec060aa252757147714f15af Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:41:04 +0200 Subject: [PATCH 24/50] fix ci --- project/build-target/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 942f3d9..4e073b7 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -64,7 +64,8 @@ runs: - name: Remove target folder from .gitignore shell: bash run: | - sed -i '/^\/?${{ steps.defaults.outputs.target_dir }}.*/d' .gitignore + TARGET_DIR="${{ steps.defaults.outputs.target_dir }}" + sed -i "/^\\/?${TARGET_DIR}.*/d" .gitignore - name: Set version in _viash.yaml shell: bash From 7a257278a62a78439ec0a46dc2d8adbe4b46635b Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 13:44:27 +0200 Subject: [PATCH 25/50] fix ci --- project/build-target/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 4e073b7..8a6ea9c 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -65,7 +65,7 @@ runs: shell: bash run: | TARGET_DIR="${{ steps.defaults.outputs.target_dir }}" - sed -i "/^\\/?${TARGET_DIR}.*/d" .gitignore + sed -i "/^\\/*${TARGET_DIR}.*/d" .gitignore - name: Set version in _viash.yaml shell: bash From 4b864eba54c62c2546ebf09b36a2f5bd560e5ed0 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 15:13:43 +0200 Subject: [PATCH 26/50] add matrix to output --- project/detect-changed-components/README.md | 30 +++++---- project/detect-changed-components/README.qmd | 67 ++++++++++++++++++++ project/detect-changed-components/action.yml | 21 ++++++ 3 files changed, 107 insertions(+), 11 deletions(-) create mode 100644 project/detect-changed-components/README.qmd diff --git a/project/detect-changed-components/README.md b/project/detect-changed-components/README.md index 0ff2b45..6044ae7 100644 --- a/project/detect-changed-components/README.md +++ b/project/detect-changed-components/README.md @@ -1,22 +1,30 @@ -# Detect components with changed files +# detect-changed-components -Filter a json file produced by viash ns list on whether -the component has been changed with respect to the -default branch. -## Inputs + - * `input_file`: (Required) Path to a viash ns list json file. +Filter a json file produced by viash ns list on whether the component +has been changed with respect to the default branch. -## Outputs +### Inputs - * `output_file`: Path to the filtered viash ns list json file, - filtered on whether one of the resources of the component has - been changed or not. +- `input_file`: - *required*. Path to a viash ns list json file + +### Outputs + +- `output_file`: Path to the filtered viash ns list json file, filtered + on whether one of the resources of the component has been changed or + not. + +- `output_matrix`: Matrix of components that have changed resources. ## Examples -```yaml +``` yaml name: demo of detect-changed on: diff --git a/project/detect-changed-components/README.qmd b/project/detect-changed-components/README.qmd new file mode 100644 index 0000000..318c3b4 --- /dev/null +++ b/project/detect-changed-components/README.qmd @@ -0,0 +1,67 @@ +--- +title: detect-changed-components +format: gfm +--- + + + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +``` + +`r action$description` + +### Inputs + +```{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")) +``` + +### Outputs + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +## Examples + +```yaml +name: demo of detect-changed + +on: + push: + +jobs: + demo: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - id: ns_list + uses: viash-io/viash-actions/ns-list@v3 + with: + format: json + + - id: ns_list_changed + uses: viash-io/viash-actions/detect-changed-components@v3 + with: + input_file: ${{ steps.ns_list.outputs.output_file }} +``` diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index bc99300..318c294 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -14,9 +14,18 @@ outputs: Path to the filtered viash ns list json file, filtered on whether one of the resources of the component has been changed or not. value: ${{ steps.filter.outputs.output_file }} + output_matrix: + description: | + Matrix of components that have changed resources. + value: ${{ steps.set_matrix.outputs.matrix }} runs: using: 'composite' steps: + - name: Get head git commit message + shell: bash + id: get_head_commit_message + run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s ${{ github.event.pull_request.head.sha || github.sha }})" >> "$GITHUB_OUTPUT" + - name: Get changed files id: changed-files uses: tj-actions/changed-files@v42.0.2 @@ -123,3 +132,15 @@ runs: # reformat as json and write to file jq -cs '.' <<< "${output_array[*]}" > "$output_file" echo "output_file=$output_file" >> $GITHUB_OUTPUT + + - id: set_matrix + shell: bash + run: | + echo "matrix=$(jq -c '[ .[] | + { + "name": .name // .functionality.name, + "namespace": .namespace // .functionality.namespace // "", + "config": .build_info.config, + "dir": .build_info.config | capture("^(?.*\/)").dir + } + ]' ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && steps.ns_list.outputs.output_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT From 51c0f630d492175e56019bc5607a4afad1888336 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 15:24:58 +0200 Subject: [PATCH 27/50] fix ci --- project/detect-changed-components/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 318c294..4c66cde 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -138,9 +138,9 @@ runs: run: | echo "matrix=$(jq -c '[ .[] | { - "name": .name // .functionality.name, - "namespace": .namespace // .functionality.namespace // "", + "name": (.name // .functionality.name), + "namespace": (.namespace // .functionality.namespace // ""), "config": .build_info.config, "dir": .build_info.config | capture("^(?.*\/)").dir } - ]' ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && steps.ns_list.outputs.output_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT + ]' ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && inputs.input_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT From 1b56dd539b4176bfeb152e60e975b4218d282b0b Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 16:48:04 +0200 Subject: [PATCH 28/50] fix action --- project/detect-changed-components/action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 4c66cde..ac0acfb 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -95,15 +95,14 @@ runs: # iterate over the components for component in "${components[@]}"; do - config_path=$(jq -cr '.info.config' <<< "$component" ) + config_path=$(jq -cr '.build_info.config // .info.config' <<< "$component" ) echo "Checking '$config_path'" # get the components resources readarray -t resources < <( jq -cr ' ( - .info.config // [] + - .build_info.config // [] + + [.build_info.config // .info.config] + [ ( .functionality.resources // [] + From f2c7a0de68b6c280cb22e44e83b1c895b4ab9d07 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 17:29:33 +0200 Subject: [PATCH 29/50] fix action --- project/detect-changed-components/action.yml | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index ac0acfb..c4fd249 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -96,25 +96,32 @@ runs: # iterate over the components for component in "${components[@]}"; do config_path=$(jq -cr '.build_info.config // .info.config' <<< "$component" ) + config_dir=`dirname "$config_path"` echo "Checking '$config_path'" # get the components resources readarray -t resources < <( jq -cr ' ( - [.build_info.config // .info.config] + + # viash config + [.build_info.config // (.info.config)] + + # viash >= 0.9 resources [ - ( - .functionality.resources // [] + - .functionality.test_resources // [] + - .resources // [] + - .test_resources // [] - ) + ((.resources // []) + (.test_resources // []))[] + | .path + | sub("^(?[^/])"; "'$config_dir'/" + .match) + | sub("^/"; "") + ] + + # viash < 0.9 resources + [ + (.functionality.resources // [])[], (.functionality.test_resources // [])[] | select(.path and .parent) | (.parent | sub("^file:(//)?"; "") | sub("/[^/]*$"; "")) + "/" + .path - ][] + ] )[] - ' <<< "$component" + # resolve paths wrt current dir (only needed for viash < 0.9) + | sub("'"`pwd`"'/"; "") + ' <<< "$component" ) # check if resource is in the list of changed resources From 1e23fe1be5335946d800fef1f857e0932ddebee6 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 17:34:06 +0200 Subject: [PATCH 30/50] fix action --- project/detect-changed-components/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index c4fd249..9fe111a 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -149,4 +149,4 @@ runs: "config": .build_info.config, "dir": .build_info.config | capture("^(?.*\/)").dir } - ]' ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && inputs.input_file || steps.ns_list_filtered.outputs.output_file }} )" >> $GITHUB_OUTPUT + ]' ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && inputs.input_file || steps.filter.outputs.output_file }} )" >> $GITHUB_OUTPUT From c1e986e6ebe5661d3fd022e6297eb8b9cfa29a7e Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 17:37:34 +0200 Subject: [PATCH 31/50] improve readability --- project/detect-changed-components/action.yml | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 9fe111a..c67ffb9 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -24,7 +24,9 @@ runs: - name: Get head git commit message shell: bash id: get_head_commit_message - run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s ${{ github.event.pull_request.head.sha || github.sha }})" >> "$GITHUB_OUTPUT" + run: | + head_commit_message=$(git show -s --format=%s ${{ github.event.pull_request.head.sha || github.sha }}) + echo "HEAD_COMMIT_MESSAGE=$head_commit_message" >> "$GITHUB_OUTPUT" - name: Get changed files id: changed-files @@ -142,11 +144,15 @@ runs: - id: set_matrix shell: bash run: | - echo "matrix=$(jq -c '[ .[] | - { - "name": (.name // .functionality.name), - "namespace": (.namespace // .functionality.namespace // ""), - "config": .build_info.config, - "dir": .build_info.config | capture("^(?.*\/)").dir - } - ]' ${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && inputs.input_file || steps.filter.outputs.output_file }} )" >> $GITHUB_OUTPUT + comp_file=${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && inputs.input_file || steps.filter.outputs.output_file }} ) + matrix=$( + jq -c '[ .[] | + { + "name": (.name // .functionality.name), + "namespace": (.namespace // .functionality.namespace // ""), + "config": .build_info.config, + "dir": .build_info.config | capture("^(?.*\/)").dir + } + ]' $comp_file + ) + echo "matrix=$matrix" >> $GITHUB_OUTPUT From 067c3231bbf7bd23ece7e0826b9b948b7ccd758c Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 17:38:55 +0200 Subject: [PATCH 32/50] fix action --- project/detect-changed-components/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index c67ffb9..6651ff4 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -144,7 +144,7 @@ runs: - id: set_matrix shell: bash run: | - comp_file=${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && inputs.input_file || steps.filter.outputs.output_file }} ) + comp_file="${{ contains(steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE, 'ci force') && inputs.input_file || steps.filter.outputs.output_file }}" matrix=$( jq -c '[ .[] | { From 746c4fcf2807e63d7965123d8b9bafc841cf2efb Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 21 Jun 2024 17:41:19 +0200 Subject: [PATCH 33/50] clean up action --- project/detect-changed-components/action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 6651ff4..8294a21 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -121,13 +121,12 @@ runs: | (.parent | sub("^file:(//)?"; "") | sub("/[^/]*$"; "")) + "/" + .path ] )[] - # resolve paths wrt current dir (only needed for viash < 0.9) - | sub("'"`pwd`"'/"; "") - ' <<< "$component" + ' <<< "$component" ) # check if resource is in the list of changed resources for resource_rel_path in "${resources[@]}"; do + # resolve paths wrt current dir (only needed for viash < 0.9) resource_project_path=$(realpath --relative-to="$GITHUB_WORKSPACE" "$resource_rel_path") if [[ " ${changed_files[*]} " =~ " ${resource_project_path} " ]]; then echo " Detected changed resources!" From 070141d4c91eaa90e314cae5eae821c78ccb66eb Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:13:46 +0200 Subject: [PATCH 34/50] move update docker engine --- project/update-docker-engine/README.md | 36 +++++++++++ project/update-docker-engine/README.qmd | 63 +++++++++++++++++++ .../update-docker-engine}/action.yml | 2 +- update-docker-engine/README.md | 23 ------- 4 files changed, 100 insertions(+), 24 deletions(-) create mode 100644 project/update-docker-engine/README.md create mode 100644 project/update-docker-engine/README.qmd rename {update-docker-engine => project/update-docker-engine}/action.yml (96%) delete mode 100644 update-docker-engine/README.md diff --git a/project/update-docker-engine/README.md b/project/update-docker-engine/README.md new file mode 100644 index 0000000..c40c6cd --- /dev/null +++ b/project/update-docker-engine/README.md @@ -0,0 +1,36 @@ + + +# update-docker-engine + + + +Install the latest Docker Engine or update an existing one to the latest +available version. Note that this action only works on Ubuntu based +images. + +### Inputs + +### Outputs + +## Examples + +``` yaml +name: Demo of update-docker-engine + +on: + push: + pull_request: + +jobs: + demo: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Update Docker Engine + uses: viash-io/viash-actions/update-docker-engine@v3 +``` diff --git a/project/update-docker-engine/README.qmd b/project/update-docker-engine/README.qmd new file mode 100644 index 0000000..6411815 --- /dev/null +++ b/project/update-docker-engine/README.qmd @@ -0,0 +1,63 @@ +--- +format: gfm +--- + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) +``` + +# `r action_name` + + + +`r action$description` + +### Inputs + +```{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")) +``` + +### Outputs + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +## Examples + +```yaml +name: Demo of `r action_name` + +on: + push: + pull_request: + +jobs: + demo: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: `r action$name` + uses: viash-io/viash-actions/project/update-docker-engine@v3 +``` + diff --git a/update-docker-engine/action.yml b/project/update-docker-engine/action.yml similarity index 96% rename from update-docker-engine/action.yml rename to project/update-docker-engine/action.yml index 33cd328..9eed2f2 100644 --- a/update-docker-engine/action.yml +++ b/project/update-docker-engine/action.yml @@ -19,4 +19,4 @@ runs: "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update - sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \ No newline at end of file + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin diff --git a/update-docker-engine/README.md b/update-docker-engine/README.md deleted file mode 100644 index 0be0b35..0000000 --- a/update-docker-engine/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Install or Update Latest Available Docker - -Install the latest Docker Engine or update an existing one to the latest available version. -Note that this action only works on Ubuntu based images. - - -## Examples - -```yaml -name: demo of update-docker-engine - -on: - push: - -jobs: - demo: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - uses: viash-io/viash-actions/update-docker-engine@v3 -``` From c1223538ee1f23148a1011aa2588e2d3d7e51e62 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:13:54 +0200 Subject: [PATCH 35/50] remove viash hub deploy --- viash-hub/deploy/README.md | 53 ----------------------------- viash-hub/deploy/action.yml | 67 ------------------------------------- 2 files changed, 120 deletions(-) delete mode 100644 viash-hub/deploy/README.md delete mode 100644 viash-hub/deploy/action.yml diff --git a/viash-hub/deploy/README.md b/viash-hub/deploy/README.md deleted file mode 100644 index ebc4afc..0000000 --- a/viash-hub/deploy/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Deploy - -This action will deploy/push build artifacts to Viash-Hub. -The functionality is greatly inspired by `peaceiris/actions-gh-pages@v3` but tweaked and minimized for our use case. - -## Usage - -This action will deploy/pull a branch from a repository and replace all content with the available build artifacts from the pipeline. - -If the `github_repo` is specified, the action will first pull the branch from the GitHub repository and then push it to the Viash-Hub repository. -If the `github_repo` is not specified, the action will first pull the branch from the Viash-Hub repository and then push it back to the Viash-Hub repository. - -### Inputs available - - `github_token`: GitHub token. - `viash_hub_token`: Viash-Hub token. - `viash_hub_repo`: user/repo_name on Viash-Hub. - `github_repo`: user/repo_name on GitHub from where to get the base branch information. - `src_branch`: Source Git branch name. - `dest_branch`: Destination Git branch name. - `commit_message`: Override the commit message for the deployment. - -## Examples - -```yaml -name: demo of viash-hub/push -on: - pull_request: -jobs: - demo: - runs-on: ubuntu-latest - - steps: - - uses: viash-io/viash-actions/setup@v4 - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: viash-io/viash-actions/ns-build@v4 - with: - parallel: true - - - name: Deploy to Viash-Hub - uses: viash-io/viash-actions/viash-hub/push@v4 - with: - github_token: ${{ github.token }} - viash_hub_token: ${{ secrets.VIASHHUB_PAT }} - viash_hub_repo: openpipelines-bio/openpipeline - github_repo: openpipelines-bio/openpipeline - src_branch: main_build - dest_branch: main_build -``` \ No newline at end of file diff --git a/viash-hub/deploy/action.yml b/viash-hub/deploy/action.yml deleted file mode 100644 index afbb16e..0000000 --- a/viash-hub/deploy/action.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: 'Deploy to viash-hub' -author: Data Intuitive -description: > - This action will push build artifacts to Viash-Hub. -inputs: - github_token: - required: false - description: GitHub token. - viash_hub_token: - description: Viash-Hub token. - required: true - viash_hub_repo: - description: user/repo_name on Viash-Hub. - required: true - github_repo: - description: user/repo_name on GitHub from where to get the base branch information. - required: false - src_branch: - description: Source Git branch name. - required: true - dest_branch: - description: Destination Git branch name. - required: true - commit_message: - description: User defined custom commit message. - required: false -runs: - using: 'composite' - steps: - - name: 'Determine temporary working directory' - shell: bash - id: workdir - run: | - repo_dir=/home/runner/viash-hub-push-`date +%s` - echo "working directory: $repo_dir" - echo "REPO_DIR=$repo_dir" >> $GITHUB_ENV - - name: 'Pull existing branch from GitHub' - if: ${{ inputs.github_repo != '' }} - shell: bash - id: pullfromgithub - run: | - # removed --depth=1 given that we rewrite the remote history. - git clone --single-branch --branch ${{ inputs.src_branch }} --no-checkout https://x-access-token:${{ inputs.github_token }}@github.com/${{ inputs.github_repo }}.git ${{ env.REPO_DIR }} - - name: 'Pull existing branch from ViashHub' - if: ${{ inputs.github_repo == '' }} - shell: bash - id: pullfromviashhub - run: | - git clone --single-branch --branch ${{ inputs.src_branch }} --depth=1 --no-checkout https://x-access-token:${{ inputs.viash_hub_token }}@viash-hub.com/${{ inputs.viash_hub_repo }}.git ${{ env.REPO_DIR }} - - name: 'Push to Viash-Hub' - shell: bash - id: pushviashhub - run: | - cd ${{ env.REPO_DIR }} - rsync -a --exclude='.git' ${{ github.workspace }}/ . - git add --all - git remote add viash-hub https://x-access-token:${{ inputs.viash_hub_token }}@viash-hub.com/${{ inputs.viash_hub_repo }}.git - git config user.name ${{ github.actor }} - git config user.email ${{ github.actor }}@users.noreply.github.com - if [ -z "${{ inputs.commit_message }}" ] - then - git commit -m "deploy: ${{ github.sha }}" - else - git commit -m "${{ inputs.commit_message }}" - fi - git push -f viash-hub ${{ inputs.dest_branch }} - \ No newline at end of file From e0714c916ac3a7b5d267ee315840a18a665f5f4d Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:18:08 +0200 Subject: [PATCH 36/50] arguments `components` and `workflows` were removed in favour for the `target_dir` argument. --- pro/build-nextflow-params/README.md | 64 +++++++++-------- pro/build-nextflow-params/README.qmd | 72 +++++++++++++++++++ pro/build-nextflow-params/action.yml | 84 ++++++++--------------- pro/build-nextflow-schemas/README.md | 63 +++++++++-------- pro/build-nextflow-schemas/README.qmd | 72 +++++++++++++++++++ pro/build-nextflow-schemas/action.yml | 99 +++++++-------------------- 6 files changed, 266 insertions(+), 188 deletions(-) create mode 100644 pro/build-nextflow-params/README.qmd create mode 100644 pro/build-nextflow-schemas/README.qmd diff --git a/pro/build-nextflow-params/README.md b/pro/build-nextflow-params/README.md index 4ffdc26..25e7d75 100644 --- a/pro/build-nextflow-params/README.md +++ b/pro/build-nextflow-params/README.md @@ -1,47 +1,51 @@ -# build-nextflow-params - -This action will build nextflow parameter file templates for Viash workflows and components in a folder. - -## Usage -This action will look for viash configs for workflows and components in a directory, -and will generate (nextflow parameter file templates)[https://www.nextflow.io/docs/latest/cli.html#run]. -For workflows, the parameter files will saved next to the Viash config, for components will output to the target directory (see viash ns build). -This component required Viash to be installed and available in `$PATH`. -We recommend to use [viash-actions/setup](https://github.com/viash-io/viash-actions/tree/main/setup) before you run `build-nextflow-params`. -### Inputs available +# build-nextflow-params -It is _required_ to set at least one argument for `components` or for `worklows`: + -* `components` - _optional_. Location of the viash configurations for components. Will most often be a folder from a repository that has been cloned in a previous step of your workflow using [checkout](https://github.com/marketplace/actions/checkout). Ex: `example_repository/src`. +This action will build nextflow parameter file templates (see nextflow’s +-params-file option) for Viash workflows and components in a repository. +For workflows, will save the build parameter files next to the Viash +config. For components, will output to the target directory (see viash +ns build). -* `workflows` - _optional_. Location of the viash configurations for workflows. Will most often be a folder from a repository that has been cloned in a previous step of your workflow using [checkout](https://github.com/marketplace/actions/checkout). Ex: `example_repository/workfows`. +### Inputs available -* `viash_pro_token` - Viash Pro token. +- `target_dir`: *(Optional)* The target directory. If not specified, the + `target` path specified in the Viash project config (`_viash.yaml`) + will be used. If that is not specified, the default `target/nextflow` + will be used. +- `viash_pro_token`: Viash Pro token. +- `tools_version`: *(Optional)* Release of Viash tools to use. Default: + `latest`. -* `tools_version` - _optional_. Release of Viash tools to use. Will use the latest release by default. Ex: `main_build` +## Usage -## Examples +``` yaml +name: Demo of build-nextflow-params -```yaml -name: demo of build-nextflow-params on: - pull_request: + push: + jobs: demo: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 + + - name: Check out repository + uses: actions/checkout@v3 - - name: Build nextflow parameter files - uses: viash-io/viash-actions/build-nextflow-params@v3 + - name: Build parameter yaml + uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 with: - workflows: workflows - token: ${{ secrets.GTHB_PAT }} - tools_version: 'main_build' -``` \ No newline at end of file + target: target/ + token: ${{ secrets.VIASH_PRO_TOKEN }} + tools_version: main_build +``` diff --git a/pro/build-nextflow-params/README.qmd b/pro/build-nextflow-params/README.qmd new file mode 100644 index 0000000..3638237 --- /dev/null +++ b/pro/build-nextflow-params/README.qmd @@ -0,0 +1,72 @@ +--- +format: gfm +--- + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) +``` + +# `r action_name` + + + +`r action$description` + +### Inputs available + +```{r} +#| echo: false +lines <- map_chr(names(action$inputs), function(name) { + input <- action$inputs[[name]] + required <- ifelse(input$required %||% FALSE, "", "_(Optional)_ ") + description <- gsub(".[ \n\r]*$", ".", input$description) + default <- ifelse(!is.null(input$default), paste0(" Default: `", input$default, "`."), "") + glue::glue("* `{name}`: {required}{description}{default}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +if (length(lines) > 0) { + knitr::asis_output(paste0("### Outputs", "", lines, collapse = "\n")) +} +``` + + +## Usage + +```yaml +name: Demo of `r action_name` + +on: + push: + +jobs: + demo: + runs-on: ubuntu-latest + + steps: + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 + + - name: Check out repository + uses: actions/checkout@v3 + + - name: `r action$name` + uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 + with: + target: target/ + token: ${{ secrets.VIASH_PRO_TOKEN }} + tools_version: main_build +``` diff --git a/pro/build-nextflow-params/action.yml b/pro/build-nextflow-params/action.yml index ca43517..1ed2cf7 100644 --- a/pro/build-nextflow-params/action.yml +++ b/pro/build-nextflow-params/action.yml @@ -6,12 +6,9 @@ description: > For workflows, will save the build parameter files next to the Viash config. For components, will output to the target directory (see viash ns build). inputs: - components: + target_dir: required: false - description: 'Location of the viash configuration for components.' - workflows: - required: false - description: 'Location of the viash configurations for workflows.' + description: 'The target directory. If not specified, the `target` path specified in the Viash project config (`_viash.yaml`) will be used. If that is not specified, the default `target/nextflow` will be used.' viash_pro_token: description: Viash Pro token. required: true @@ -41,61 +38,36 @@ runs: path: viash_tools ref: ${{ steps.latestrelease.outputs.releasetag }} - - uses: viash-io/viash-actions/ns-list@v5 - id: nslistcomponents - if: inputs.components - with: - src: ${{ inputs.components }} - format: "json" - platform: "nextflow" + - name: Determine target directory + shell: bash + id: defaults + run: | + TARGET_DIR=${{ inputs.target_dir }} - - uses: viash-io/viash-actions/ns-list@v5 - id: nslistworkflows - if: inputs.workflows - with: - src: ${{ inputs.workflows }} - format: "json" + if [ -z "$TARGET_DIR" ]; then + TARGET_DIR=$(yq -r '.target // "target/nextflow"' _viash.yaml) + fi + + echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT - name: 'Generate param files' shell: bash id: generate-params run: | command -v viash >/dev/null 2>&1 || { echo >&2 "Viash could not be found."; exit 127; } - # Check if at least some input is defined. - if [ ! -f "${{ steps.nslistcomponents.outputs.output_file }}" ] && [ ! -f "${{ steps.nslistworkflows.outputs.output_file }}" ]; then - echo "One of the workflows or components properties must be set." - exit 1; - fi - # Process components - if [ -f "${{ steps.nslistcomponents.outputs.output_file }}" ]; then - # Get config paths - component_inputs=$(jq -r '[.[] | .info.config] | join(";")' "${{ steps.nslistcomponents.outputs.output_file }}") - # Get output paths - jq_query='[.[] | "target/nextflow/" + .functionality.namespace + "/" + .functionality.name + "/nextflow_params.yaml"] | join(";")' - component_outputs_params=$(jq -r "$jq_query" "${{ steps.nslistcomponents.outputs.output_file }}") - fi - # Process workflows - if [ -f "${{ steps.nslistworkflows.outputs.output_file }}" ]; then - # Get config paths - workflow_inputs=$(jq -r '[.[] | select((.functionality.resources[].type // []) | contains("nextflow_script")) | .info.config] | join(";")' "${{ steps.nslistworkflows.outputs.output_file }}") - # Get output paths - jq_query='[.[] | select((.functionality.resources[].type // []) | contains("nextflow_script")) | .info.config | capture("^(?.*\/)").dir + "/nextflow_params.yaml"] | join(";")' - workflow_outputs_params=$(jq -r "$jq_query" "${{ steps.nslistworkflows.outputs.output_file }}") - fi - inputs=() - outputs=() - echo "Workflow inputs: $workflow_inputs" - echo "Component inputs: $component_inputs" - if [ -n "$workflow_inputs" ]; then - echo "Adding workflow inputs" - inputs+=(--input "$workflow_inputs") - outputs+=(--output "$workflow_outputs_params") - fi - if [ -n "$component_inputs" ]; then - echo "Adding component inputs" - inputs+=(--input "$component_inputs") - outputs+=(--output "$component_outputs_params") - fi - echo "Running viash_tools/target/docker/nextflow/generate_params/generate_params ${inputs[@]} ${outputs[@]}" - viash_tools/target/docker/nextflow/generate_params/generate_params "${inputs[@]}" "${outputs[@]}" - echo "Created $outputs" \ No newline at end of file + + TARGET_DIR="${{ steps.defaults.outputs.target_dir }}" + + BUILT_CONFIGS=$(find "$TARGET_DIR" -name .config.vsh.yaml) + echo "Detected configs:" + echo "$BUILT_CONFIGS" + echo + + NEXTFLOW_PARAMS=$(echo "$BUILT_CONFIGS" | sed 's/.config.vsh.yaml/nextflow_params.yaml/g') + echo "Building Nextflow param files:" + echo "$NEXTFLOW_PARAMS" + echo + + viash_tools/target/docker/nextflow/generate_params/generate_params \ + --input $(echo "$BUILT_CONFIGS" | paste -sd ";") \ + --output $(echo "$NEXTFLOW_PARAMS" | paste -sd ";") diff --git a/pro/build-nextflow-schemas/README.md b/pro/build-nextflow-schemas/README.md index c4835cc..db2c5e6 100644 --- a/pro/build-nextflow-schemas/README.md +++ b/pro/build-nextflow-schemas/README.md @@ -1,47 +1,52 @@ -# build-nextflow-schemas -This action will build nextflow schemas for Viash workflows and components in a folder. -## Usage +# build-nextflow-schemas -This action will look for viash configs for workflows and components in a directory, -and will generate [nextflow pipeline JSON schemas](https://help.tower.nf/latest/pipeline-schema/overview/). -For workflows, the schemas will saved next to the Viash config, for components will output to the target directory (see viash ns build). This component required Viash to be installed and available in `$PATH`. We recommend to use [viash-actions/setup](https://github.com/viash-io/viash-actions/tree/main/setup) before you run `build-nextflow-schemas`. + -We recommend using a Linux or MacOS runner if possible. +This action will build nextflow schemas for Viash workflows and +components in a repository. For workflows, will save the build schemas +next to the Viash config. For components, will output to the target +directory (see viash ns build). ### Inputs available -It is _required_ to set at least one argument for `components` or for `worklows`: - -* `components` - _optional_. Location of the viash configurations for components. Will most often be a folder from a repository that has been cloned in a previous step of your workflow using [checkout](https://github.com/marketplace/actions/checkout). Ex: `example_repository/src`. - -* `workflows` - _optional_. Location of the viash configurations for workflows. Will most often be a folder from a repository that has been cloned in a previous step of your workflow using [checkout](https://github.com/marketplace/actions/checkout). Ex: `example_repository/workfows`. +- `target_dir`: *(Optional)* The target directory. If not specified, the + `target` path specified in the Viash project config (`_viash.yaml`) + will be used. If that is not specified, the default `target/nextflow` + will be used. +- `viash_pro_token`: Viash Pro token. +- `tools_version`: *(Optional)* Release of Viash tools to use. Default: + `latest`. +- `enable_dataset_input`: *(Optional)* enable nf-tower dataset inpu. + Default: `false`. -* `viash_pro_token` - Viash Pro token. - -* `tools_version` - _optional_. Release of Viash tools to use. Will use the latest release by default. Ex: `main_build` +## Usage -## Examples +``` yaml +name: Demo of build-nextflow-schemas -```yaml -name: demo of generate_documentation_qmd on: - pull_request: + push: + jobs: demo: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 + + - name: Check out repository + uses: actions/checkout@v3 - - name: Build nextflow schemas - uses: viash-io/viash-actions/build-nextflow-schemas@v3 + - name: Build nf-tower schemas + uses: viash-io/viash-actions/pro/build-nextflow-schemas@viash-0.9 with: - workflows: workflows - token: ${{ secrets.GTHB_PAT }} - tools_version: 'main_build' -``` \ No newline at end of file + target: target/ + token: ${{ secrets.VIASH_PRO_TOKEN }} + tools_version: main_build +``` diff --git a/pro/build-nextflow-schemas/README.qmd b/pro/build-nextflow-schemas/README.qmd new file mode 100644 index 0000000..f420ec6 --- /dev/null +++ b/pro/build-nextflow-schemas/README.qmd @@ -0,0 +1,72 @@ +--- +format: gfm +--- + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) +``` + +# `r action_name` + + + +`r action$description` + +### Inputs available + +```{r} +#| echo: false +lines <- map_chr(names(action$inputs), function(name) { + input <- action$inputs[[name]] + required <- ifelse(input$required %||% FALSE, "", "_(Optional)_ ") + description <- gsub(".[ \n\r]*$", ".", input$description) + default <- ifelse(!is.null(input$default), paste0(" Default: `", input$default, "`."), "") + glue::glue("* `{name}`: {required}{description}{default}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +if (length(lines) > 0) { + knitr::asis_output(paste0("### Outputs", "", lines, collapse = "\n")) +} +``` + + +## Usage + +```yaml +name: Demo of `r action_name` + +on: + push: + +jobs: + demo: + runs-on: ubuntu-latest + + steps: + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 + + - name: Check out repository + uses: actions/checkout@v3 + + - name: `r action$name` + uses: viash-io/viash-actions/pro/build-nextflow-schemas@viash-0.9 + with: + target: target/ + token: ${{ secrets.VIASH_PRO_TOKEN }} + tools_version: main_build +``` diff --git a/pro/build-nextflow-schemas/action.yml b/pro/build-nextflow-schemas/action.yml index c43d3d0..306c2ab 100644 --- a/pro/build-nextflow-schemas/action.yml +++ b/pro/build-nextflow-schemas/action.yml @@ -5,28 +5,21 @@ description: > For workflows, will save the build schemas next to the Viash config. For components, will output to the target directory (see viash ns build). inputs: - components: + target_dir: required: false - description: 'Location of the viash configuration for components.' - type: string - workflows: - required: false - description: 'Location of the viash configurations for workflows.' + description: 'The target directory. If not specified, the `target` path specified in the Viash project config (`_viash.yaml`) will be used. If that is not specified, the default `target/nextflow` will be used.' viash_pro_token: description: Viash Pro token. required: true - type: string tools_version: description: > Release of Viash tools to use. required: false default: 'latest' - type: string enable_dataset_input: description: 'enable nf-tower dataset input' required: false - default: false - type: boolean + default: "false" runs: using: 'composite' steps: @@ -49,20 +42,17 @@ runs: path: viash_tools ref: ${{ steps.latestrelease.outputs.releasetag }} - - uses: viash-io/viash-actions/ns-list@v5 - id: nslistcomponents - if: inputs.components - with: - src: ${{ inputs.components }} - format: "json" - platform: "nextflow" + - name: Determine target directory + shell: bash + id: defaults + run: | + TARGET_DIR=${{ inputs.target_dir }} + + if [ -z "$TARGET_DIR" ]; then + TARGET_DIR=$(yq -r '.target // "target/nextflow"' _viash.yaml) + fi - - uses: viash-io/viash-actions/ns-list@v5 - id: nslistworkflows - if: inputs.workflows - with: - src: ${{ inputs.workflows }} - format: "json" + echo "target_dir=$TARGET_DIR" >> $GITHUB_OUTPUT - name: 'Generate schemas' shell: bash @@ -70,56 +60,19 @@ runs: run: | command -v viash >/dev/null 2>&1 || { echo >&2 "Viash could not be found."; exit 127; } - # Check if at least some input is defined. - if [ ! -f "${{ steps.nslistcomponents.outputs.output_file }}" ] && [ ! -f "${{ steps.nslistworkflows.outputs.output_file }}" ]; then - echo "One of the workflows or components properties must be set." - exit 1; - fi - - # Process components - if [ -f "${{ steps.nslistcomponents.outputs.output_file }}" ]; then - # Get config paths - component_inputs=$(jq -r '[.[] | .info.config] | join(";")' "${{ steps.nslistcomponents.outputs.output_file }}") - - # Get output paths - jq_query='[.[] | "target/nextflow/" + .functionality.namespace + "/" + .functionality.name + "/nextflow_schema.json"] | join(";")' - component_outputs_schema=$(jq -r "$jq_query" "${{ steps.nslistcomponents.outputs.output_file }}") - fi - - # Process workflows - if [ -f "${{ steps.nslistworkflows.outputs.output_file }}" ]; then - # Get config paths - workflow_inputs=$(jq -r '[.[] | select((.functionality.resources[].type // []) | contains("nextflow_script")) | .info.config] | join(";")' "${{ steps.nslistworkflows.outputs.output_file }}") - - # Get output paths - jq_query='[.[] | select((.functionality.resources[].type // []) | contains("nextflow_script")) | .info.config | capture("^(?.*\/)").dir + "/nextflow_schema.json"] | join(";")' - workflow_outputs_schema=$(jq -r "$jq_query" "${{ steps.nslistworkflows.outputs.output_file }}") - fi + TARGET_DIR="${{ steps.defaults.outputs.target_dir }}" - inputs=() - outputs=() + BUILT_CONFIGS=$(find "$TARGET_DIR" -name .config.vsh.yaml) + echo "Detected configs:" + echo "$BUILT_CONFIGS" + echo - echo "Workflow inputs: $workflow_inputs" - echo "Component inputs: $component_inputs" - - if [ -n "$workflow_inputs" ]; then - echo "Adding workflow inputs" - inputs+=(--input "$workflow_inputs") - outputs+=(--output "$workflow_outputs_schema") - fi - - if [ -n "$component_inputs" ]; then - echo "Adding component inputs" - inputs+=(--input "$component_inputs") - outputs+=(--output "$component_outputs_schema") - fi - - extra_params=() - if [ "${{ inputs.enable_dataset_input }}" == "true" ]; then - extra_params+=("--enable_dataset_input") - fi + NEXTFLOW_SCHEMAS=$(echo "$BUILT_CONFIGS" | sed 's/.config.vsh.yaml/nextflow_schema.json/g') + echo "Building Nextflow schema files:" + echo "$NEXTFLOW_SCHEMAS" + echo - echo "Running viash_tools/target/docker/nextflow/generate_schema/generate_schema ${inputs[@]} ${outputs[@]} ${extra_params[@]}" - viash_tools/target/docker/nextflow/generate_schema/generate_schema "${inputs[@]}" "${outputs[@]}" "${extra_params[@]}" - - echo "Created $outputs_schema" \ No newline at end of file + viash_tools/target/docker/nextflow/generate_schema/generate_schema \ + --input "$BUILT_CONFIGS" \ + --output "$NEXTFLOW_SCHEMAS" \ + ${{ inputs.enable_dataset_input }} From d3ee4f2b136df7a4002906c62f42d1b1c506c907 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:18:33 +0200 Subject: [PATCH 37/50] uniformize documentation pages --- Makefile | 13 ++++ README.md | 49 ++++++++---- README.qmd | 54 +++++++++++++ ns-build/README.md | 24 +++--- ns-build/README.qmd | 34 ++++----- ns-list/README.md | 68 ++++++++++------- ns-list/README.qmd | 79 ++++++++++++-------- pro/generate-documentation-qmd/README.md | 30 ++++++-- pro/generate-documentation-qmd/README.qmd | 26 +++++-- project/build-target/README.md | 24 +++--- project/build-target/README.qmd | 34 +++++---- project/detect-changed-components/README.md | 31 ++++---- project/detect-changed-components/README.qmd | 36 ++++----- project/is-pr/README.md | 18 +++-- project/is-pr/README.qmd | 27 ++++--- project/is-pr/action.yml | 2 +- project/sync-and-cache-s3/README.md | 44 ++++++----- project/sync-and-cache-s3/README.qmd | 66 ++++++++++++++++ project/sync-and-cache-s3/action.yml | 2 +- setup/README.md | 41 +++++----- setup/README.qmd | 73 ++++++++++++++++++ setup/action.yml | 2 +- 22 files changed, 541 insertions(+), 236 deletions(-) create mode 100644 Makefile create mode 100644 README.qmd create mode 100644 project/sync-and-cache-s3/README.qmd create mode 100644 setup/README.qmd diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2456e54 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +# Find all .qmd files +QMD_FILES := $(shell find . -name "*.qmd") + +# Render all .qmd files to md +all: $(QMD_FILES:.qmd=.md) + +# Recipe to render an individual .qmd file +%.md: %.qmd + quarto render $< + +# Remove the generated md files +clean: + rm -f $(QMD_FILES:.qmd=.md) diff --git a/README.md b/README.md index a421b22..1e259d4 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,44 @@ # Github Actions for Viash -This repository stores [Github Actions](https://github.com/features/actions) useful for building and publishing [Viash](https://viash.io) components: -1. [viash-io/viash-actions/setup](setup) - Install Viash -2. [viash-io/viash-actions/ns-list](ns-list) - List Viash components in a repository -3. [viash-io/viash-actions/ns-build](ns-build) - Build a namespace from many viash config files +This repository stores [Github +Actions](https://github.com/features/actions) useful for building and +publishing [Viash](https://viash.io) components: -There are also a few actions that are commonly used in Viash projects: + 1. [viash-io/viash-actions/ns-build@v6](ns-build) - viash ns build + 1. [viash-io/viash-actions/ns-list@v6](ns-list) - viash ns list + 1. [viash-io/viash-actions/setup@v6](setup) - Setup Viash -1. [viash-io/viash-actions/project/cache-and-sync-s3](project/cache-and-sync-s3) - Sync and cache an S3 bucket -2. [viash-io/viash_actions/project/detect-changed-components](project/detect-changed-components) - Detect changed Viash components +There are also some actions that are commonly used in Viash projects: -We recommend using `v3` for your actions. + 1. [viash-io/viash-actions/project/build-target@v6](project/build-target) - Build target directory + 1. [viash-io/viash-actions/project/detect-changed-components@v6](project/detect-changed-components) - Detect components with changed files + 1. [viash-io/viash-actions/project/is-pr@v6](project/is-pr) - Is PR + 1. [viash-io/viash-actions/project/sync-and-cache-s3@v6](project/sync-and-cache-s3) - Sync and cache an S3 bucket + 1. [viash-io/viash-actions/project/update-docker-engine@v6](project/update-docker-engine) - Update Docker Engine -## Release Management +Finally, there are some [Viash +Pro](https://www.data-intuitive.com/services/viashpro.html) actions: + + 1. [viash-io/viash-actions/pro/build-nextflow-params@v6](pro/build-nextflow-params) - Build parameter yaml + 1. [viash-io/viash-actions/pro/build-nextflow-schemas@v6](pro/build-nextflow-schemas) - Build nf-tower schemas + 1. [viash-io/viash-actions/pro/generate-documentation-qmd@v6](pro/generate-documentation-qmd) - Build and publish qmd -This repository uses [GitHub's recommended release management for actions](https://docs.github.com/en/actions/creating-actions/about-custom-actions#using-release-management-for-actions): +We recommend using `v6` for your actions. + +## Release Management -* GitHub releases with tags are used for updates on the actions. -* Semantic versioning is used, with major, minor and possibly patch release. -* Major versions (such as `v1`) will always point to the last minor or patch release for this major version. (when `v1.0.2` is out, `v1` will point to this update to). This means using `viash-io/viash-actions/setup@v1` in your workflow file will automatically get the updated versions. Using `viash-io/viash-actions/setup@v1.0.2` will pin a specific release. -* Major version changes (`v1` to `v2`) will often come with breaking changes, and workflows might require manual updates. \ No newline at end of file +This repository uses [GitHub’s recommended release management for +actions](https://docs.github.com/en/actions/creating-actions/about-custom-actions#using-release-management-for-actions): + +- GitHub releases with tags are used for updates on the actions. +- Semantic versioning is used, with major, minor and possibly patch + release. +- Major versions (such as `v1`) will always point to the last minor or + patch release for this major version. (when `v1.0.2` is out, `v1` will + point to this update to). This means using + `viash-io/viash-actions/setup@v1` in your workflow file will + automatically get the updated versions. Using + `viash-io/viash-actions/setup@v1.0.2` will pin a specific release. +- Major version changes (`v1` to `v2`) will often come with breaking + changes, and workflows might require manual updates. diff --git a/README.qmd b/README.qmd new file mode 100644 index 0000000..559866c --- /dev/null +++ b/README.qmd @@ -0,0 +1,54 @@ +--- +title: Github Actions for Viash +format: gfm +--- + +```{r} +#| include: false +library(tidyverse) + +repo_name <- "viash-io/viash-actions" +latest_stable_version <- "v6" + +actions <- tibble( + file = list.files(".", full.names = TRUE, recursive = TRUE, pattern = "action.yml"), + path = gsub("^\\./(.*)/action.yml$", "\\1", file), + action = map(file, yaml::read_yaml), + action_name = map_chr(action, "name"), + namespace = ifelse(grepl("/", path), gsub("/.*", "", path), ""), + str = paste0("1. [", repo_name, "/", path, "@", latest_stable_version, "](", path, ") - ", action_name, "\n") +) +``` + + +This repository stores [Github Actions](https://github.com/features/actions) useful for building and publishing [Viash](https://viash.io) components: + +```{r} +#| echo: false +cat(actions %>% filter(namespace == "") %>% pull(str) %>% paste(collapse = "")) +``` + +There are also some actions that are commonly used in Viash projects: + +```{r} +#| echo: false +cat(actions %>% filter(namespace == "project") %>% pull(str) %>% paste(collapse = "")) +``` + +Finally, there are some [Viash Pro](https://www.data-intuitive.com/services/viashpro.html) actions: + +```{r} +#| echo: false +cat(actions %>% filter(namespace == "pro") %>% pull(str) %>% paste(collapse = "")) +``` + +We recommend using ``r latest_stable_version`` for your actions. + +## Release Management + +This repository uses [GitHub's recommended release management for actions](https://docs.github.com/en/actions/creating-actions/about-custom-actions#using-release-management-for-actions): + +* GitHub releases with tags are used for updates on the actions. +* Semantic versioning is used, with major, minor and possibly patch release. +* Major versions (such as `v1`) will always point to the last minor or patch release for this major version. (when `v1.0.2` is out, `v1` will point to this update to). This means using `viash-io/viash-actions/setup@v1` in your workflow file will automatically get the updated versions. Using `viash-io/viash-actions/setup@v1.0.2` will pin a specific release. +* Major version changes (`v1` to `v2`) will often come with breaking changes, and workflows might require manual updates. \ No newline at end of file diff --git a/ns-build/README.md b/ns-build/README.md index fd9d140..e0372fd 100644 --- a/ns-build/README.md +++ b/ns-build/README.md @@ -1,11 +1,10 @@ -# ns-build +# ns-build + Build a namespace from many viash config files. @@ -64,22 +63,21 @@ We recommend using a Linux or MacOS runner if possible. ## Examples ``` yaml -name: demo of viash ns build +name: Demo of ns-build on: - branch: main + push: jobs: viash-linux: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Check out repository + uses: actions/checkout@v3 - - uses: viash-io/viash-actions/ns-build@v3 - viash-macos: - runs-on: macos-latest - steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 - - uses: viash-io/viash-actions/ns-build@v3 + - name: viash ns build + uses: viash-io/viash-actions/ns-build@v3 ``` diff --git a/ns-build/README.qmd b/ns-build/README.qmd index 29db383..c12c470 100644 --- a/ns-build/README.qmd +++ b/ns-build/README.qmd @@ -1,22 +1,21 @@ --- -title: ns-build format: gfm --- - - ```{r} #| include: false library(tidyverse) -# action <- yaml::read_yaml("ns-build/action.yml") action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) ``` +# `r action_name` + + + `r action$description` ## Usage @@ -51,23 +50,22 @@ knitr::asis_output(paste0(lines, collapse = "\n")) ## Examples ```yaml -name: demo of viash ns build +name: Demo of `r action_name` on: - branch: main + push: jobs: viash-linux: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Check out repository + uses: actions/checkout@v3 - - uses: viash-io/viash-actions/ns-build@v3 - viash-macos: - runs-on: macos-latest - steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 - - uses: viash-io/viash-actions/ns-build@v3 + - name: `r action$name` + uses: viash-io/viash-actions/ns-build@v3 ``` diff --git a/ns-list/README.md b/ns-list/README.md index 0a622f7..dee2e93 100644 --- a/ns-list/README.md +++ b/ns-list/README.md @@ -1,11 +1,10 @@ -# ns-list +# ns-list + List a namespace containing many viash config files. @@ -75,37 +74,54 @@ We recommend using a Linux or MacOS runner if possible. of components with fields ‘name’, ‘namespace’, ‘full_name’, ‘config’, and ‘dir’. -## Examples +## Usage ``` yaml -name: demo of viash ns list +name: Demo of ns-list -on: - branch: main +on: + push: jobs: - viash-linux: + nslist: runs-on: ubuntu-latest - steps: - - uses: viash-io/viash-actions/setup@v3 - - id: ns_list - uses: viash-io/viash-actions/ns-list@v3 - - - run: | - # do something with the output yaml - echo "${{steps.ns_list.outputs.output_file}}" - viash-macos: - runs-on: macos-latest + outputs: + output_file: ${{ steps.ns_list.outputs.output_file }} + output_matrix: ${{ steps.ns_list.outputs.output_matrix }} + steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 + + - name: Check out repository + uses: actions/checkout@v3 - - id: ns_list + - name: viash ns list uses: viash-io/viash-actions/ns-list@v3 - with: - format: json - - run: | - # do something with the output json - echo "${{steps.ns_list.outputs.output_file}}" + - name: View output + run: | + cat "${{steps.ns_list.outputs.output_file}}" + + use_matrix: + runs-on: ubuntu-latest + needs: nslist + + strategy: + matrix: + component: ${{fromJson(needs.nslist.outputs.output_matrix)}} + + steps: + - name: Do something for every component + run: | + echo "Name: ${{ matrix.component.name }}" + echo "Namespace: ${{ matrix.component.namespace }}" + echo "Runner: ${{ matrix.component.runner }}" + echo "Engine: ${{ matrix.component.engine }}" + echo "Config: ${{ matrix.component.config }}" + echo "Executable: ${{ matrix.component.executable }}" + echo "Src dir: ${{ matrix.component.src_dir }}" + echo "Target dir: ${{ matrix.component.target_dir }}" + echo "Full name: ${{ matrix.component.full_name }}" ``` diff --git a/ns-list/README.qmd b/ns-list/README.qmd index 3b48f47..563a420 100644 --- a/ns-list/README.qmd +++ b/ns-list/README.qmd @@ -1,22 +1,21 @@ --- -title: ns-list format: gfm --- - - ```{r} #| include: false library(tidyverse) -# action <- yaml::read_yaml("ns-list/action.yml") action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) ``` +# `r action_name` + + + `r action$description` ## Usage @@ -48,38 +47,54 @@ lines <- map_chr(names(action$outputs), function(name) { knitr::asis_output(paste0(lines, collapse = "\n")) ``` -## Examples +## Usage ```yaml -name: demo of viash ns list +name: Demo of `r action_name` -on: - branch: main +on: + push: jobs: - viash-linux: + nslist: runs-on: ubuntu-latest - steps: - - uses: viash-io/viash-actions/setup@v3 - - id: ns_list - uses: viash-io/viash-actions/ns-list@v3 - - - run: | - # do something with the output yaml - echo "${{steps.ns_list.outputs.output_file}}" - viash-macos: - runs-on: macos-latest + outputs: + output_file: ${{ steps.ns_list.outputs.output_file }} + output_matrix: ${{ steps.ns_list.outputs.output_matrix }} + steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 + + - name: Check out repository + uses: actions/checkout@v3 - - id: ns_list + - name: `r action$name` uses: viash-io/viash-actions/ns-list@v3 - with: - format: json - - run: | - # do something with the output json - echo "${{steps.ns_list.outputs.output_file}}" -``` + - name: View output + run: | + cat "${{steps.ns_list.outputs.output_file}}" + + use_matrix: + runs-on: ubuntu-latest + needs: nslist + + strategy: + matrix: + component: ${{fromJson(needs.nslist.outputs.output_matrix)}} + steps: + - name: Do something for every component + run: | + echo "Name: ${{ matrix.component.name }}" + echo "Namespace: ${{ matrix.component.namespace }}" + echo "Runner: ${{ matrix.component.runner }}" + echo "Engine: ${{ matrix.component.engine }}" + echo "Config: ${{ matrix.component.config }}" + echo "Executable: ${{ matrix.component.executable }}" + echo "Src dir: ${{ matrix.component.src_dir }}" + echo "Target dir: ${{ matrix.component.target_dir }}" + echo "Full name: ${{ matrix.component.full_name }}" +``` diff --git a/pro/generate-documentation-qmd/README.md b/pro/generate-documentation-qmd/README.md index f032df0..e8a9611 100644 --- a/pro/generate-documentation-qmd/README.md +++ b/pro/generate-documentation-qmd/README.md @@ -1,5 +1,12 @@ + + # generate-documentation-qmd + + Create quarto markdown files for viash components or workflows, based on a jinja template. @@ -43,26 +50,33 @@ before you run `generate_documentation_qmd`. - `src`: *(Optional)* An override for the `--src` parameter in `viash ns list`. Example: `src/`. -## Examples +## Usage ``` yaml -name: demo of generate-documentation-qmd +name: Demo of generate-documentation-qmd on: - pull_request: + push: jobs: demo: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 - - uses: actions/checkout@v3 - - uses: viash-io/viash-actions/generate-documentation-qmd@v3 + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 + + - name: Check out repository + uses: actions/checkout@v3 + with: + path: project + + - name: Build and publish qmd + uses: viash-io/viash-actions/generate-documentation-qmd@v3 with: - project_dir: ./ + project_dir: project src: src - output_dir: /website/components + output_dir: website dest_path: "{type}s/{namespace}/{name}.qmd" git_repo: openpipelines-bio/openpipelines token: ${{ secrets.GTHB_PAT }} diff --git a/pro/generate-documentation-qmd/README.qmd b/pro/generate-documentation-qmd/README.qmd index bd7813f..ea44b7a 100644 --- a/pro/generate-documentation-qmd/README.qmd +++ b/pro/generate-documentation-qmd/README.qmd @@ -1,5 +1,4 @@ --- -title: generate-documentation-qmd format: gfm --- @@ -7,8 +6,16 @@ format: gfm #| include: false library(tidyverse) action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) ``` +# `r action_name` + + + `r action$description` ### Inputs available @@ -40,23 +47,26 @@ if (length(lines) > 0) { ## Usage ```yaml -name: demo of generate-documentation-qmd +name: Demo of `r action_name` on: - pull_request: + push: jobs: demo: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - path: project + - name: Install Viash + uses: viash-io/viash-actions/setup@v3 - - uses: viash-io/viash-actions/setup@v3 + - name: Check out repository + uses: actions/checkout@v3 + with: + path: project - - uses: viash-io/viash-actions/generate-documentation-qmd@v3 + - name: `r action$name` + uses: viash-io/viash-actions/generate-documentation-qmd@v3 with: project_dir: project src: src diff --git a/project/build-target/README.md b/project/build-target/README.md index cfff8c3..015b56c 100644 --- a/project/build-target/README.md +++ b/project/build-target/README.md @@ -1,10 +1,10 @@ -# build-target +# build-target + Builds a target directory using the viash ns build command. @@ -29,21 +29,25 @@ Builds a target directory using the viash ns build command. ## Examples ``` yaml -name: demo of build-target +name: Demo of build-target -on: - branch: main +on: + push: + pull_request: jobs: - build-target: + demo: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Check out repository + uses: viash-io/viash-actions/setup@v3 - - id: build_target + - name: Build target directory + id: build_target uses: viash-io/viash-actions/build-target@v5 - - run: | + - name: Check output + run: | # view target directory ls -l target/ diff --git a/project/build-target/README.qmd b/project/build-target/README.qmd index 657df47..4292b56 100644 --- a/project/build-target/README.qmd +++ b/project/build-target/README.qmd @@ -1,20 +1,21 @@ --- -title: build-target format: gfm --- - - ```{r} #| include: false library(tidyverse) action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) ``` +# `r action_name` + + + `r action$description` ### Inputs @@ -43,21 +44,25 @@ knitr::asis_output(paste0(lines, collapse = "\n")) ## Examples ```yaml -name: demo of build-target +name: Demo of `r action_name` -on: - branch: main +on: + push: + pull_request: jobs: - build-target: + demo: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - name: Check out repository + uses: viash-io/viash-actions/setup@v3 - - id: build_target + - name: `r action$name` + id: build_target uses: viash-io/viash-actions/build-target@v5 - - run: | + - name: Check output + run: | # view target directory ls -l target/ @@ -65,4 +70,3 @@ jobs: echo "${{steps.build_target.outputs.docker_component_matrix}}" echo "${{steps.build_target.outputs.component_matrix}}" ``` - diff --git a/project/detect-changed-components/README.md b/project/detect-changed-components/README.md index 6044ae7..a08e333 100644 --- a/project/detect-changed-components/README.md +++ b/project/detect-changed-components/README.md @@ -1,10 +1,10 @@ -# detect-changed-components +# detect-changed-components + Filter a json file produced by viash ns list on whether the component @@ -25,7 +25,7 @@ has been changed with respect to the default branch. ## Examples ``` yaml -name: demo of detect-changed +name: Demo of detect-changed-components on: push: @@ -35,15 +35,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - id: ns_list - uses: viash-io/viash-actions/ns-list@v3 - with: - format: json - - - id: ns_list_changed - uses: viash-io/viash-actions/detect-changed-components@v3 - with: - input_file: ${{ steps.ns_list.outputs.output_file }} + - uses: actions/checkout@v3 + + - id: ns_list + uses: viash-io/viash-actions/ns-list@v3 + with: + format: json + + - name: Detect components with changed files + id: ns_list_changed + uses: viash-io/viash-actions/detect-changed-components@v3 + with: + input_file: ${{ steps.ns_list.outputs.output_file }} ``` diff --git a/project/detect-changed-components/README.qmd b/project/detect-changed-components/README.qmd index 318c3b4..4df8074 100644 --- a/project/detect-changed-components/README.qmd +++ b/project/detect-changed-components/README.qmd @@ -1,20 +1,21 @@ --- -title: detect-changed-components format: gfm --- - - ```{r} #| include: false library(tidyverse) action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) ``` +# `r action_name` + + + `r action$description` ### Inputs @@ -43,7 +44,7 @@ knitr::asis_output(paste0(lines, collapse = "\n")) ## Examples ```yaml -name: demo of detect-changed +name: Demo of `r action_name` on: push: @@ -53,15 +54,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - id: ns_list - uses: viash-io/viash-actions/ns-list@v3 - with: - format: json + - id: ns_list + uses: viash-io/viash-actions/ns-list@v3 + with: + format: json - - id: ns_list_changed - uses: viash-io/viash-actions/detect-changed-components@v3 - with: - input_file: ${{ steps.ns_list.outputs.output_file }} + - name: `r action$name` + id: ns_list_changed + uses: viash-io/viash-actions/detect-changed-components@v3 + with: + input_file: ${{ steps.ns_list.outputs.output_file }} ``` diff --git a/project/is-pr/README.md b/project/is-pr/README.md index 1a988bd..7887c72 100644 --- a/project/is-pr/README.md +++ b/project/is-pr/README.md @@ -1,10 +1,10 @@ -# build-target +# is-pr + Check whether the branch has a PR and if this run was triggered by a @@ -20,19 +20,23 @@ push event. ## Examples ``` yaml -name: Is PR +name: Demo of is-pr on: push: pull_request: jobs: - is-pr: + demo: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: viash-io/viash-actions/is-pr@v1 + - name: Check out repository + uses: actions/checkout@v3 + + - name: Is PR + uses: viash-io/viash-actions/is-pr@v1 id: is_pr + - run: | echo "Is PR: ${{ steps.is_pr.outputs.check }}" ``` diff --git a/project/is-pr/README.qmd b/project/is-pr/README.qmd index 4031b56..79b8e26 100644 --- a/project/is-pr/README.qmd +++ b/project/is-pr/README.qmd @@ -1,20 +1,21 @@ --- -title: build-target format: gfm --- - - ```{r} #| include: false library(tidyverse) action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) ``` +# `r action_name` + + + `r action$description` ### Inputs @@ -43,19 +44,23 @@ knitr::asis_output(paste0(lines, collapse = "\n")) ## Examples ```yaml -name: Is PR +name: Demo of `r action_name` on: push: pull_request: jobs: - is-pr: + demo: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: viash-io/viash-actions/is-pr@v1 + - name: Check out repository + uses: actions/checkout@v3 + + - name: `r action$name` + uses: viash-io/viash-actions/is-pr@v1 id: is_pr + - run: | echo "Is PR: ${{ steps.is_pr.outputs.check }}" ``` diff --git a/project/is-pr/action.yml b/project/is-pr/action.yml index c135a6b..db3261d 100644 --- a/project/is-pr/action.yml +++ b/project/is-pr/action.yml @@ -23,4 +23,4 @@ runs: echo "check=true" >> $GITHUB_OUTPUT fi env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/project/sync-and-cache-s3/README.md b/project/sync-and-cache-s3/README.md index 30c830a..29ab670 100644 --- a/project/sync-and-cache-s3/README.md +++ b/project/sync-and-cache-s3/README.md @@ -1,35 +1,45 @@ -# Sync and Cache S3 Bucket -A GitHub Action to sync an S3 bucket to a local folder and create a cache. -For now, this will only be able to sync public S3 buckets. +# sync-and-cache-s3 -## Inputs + - * `s3_bucket`: (Required) Path to an S3 bucket. - * `dest_path`: (Required) Where to store the data. - * `cache_key_prefix`: (Optional) A prefix for the cache hash key. Prefix is also used for restoring stale cache if no cache hit occurred for key. Default value is `cachekey__`. +Sync an S3 bucket to a folder and create a cache. -## Outputs +### Inputs - * `cache_key`: The caching key, which is the hash of the contents of the S3 bucket. +- `s3_bucket`: - *required*. Path to an S3 bucket. +- `dest_path`: - *required*. Where to store the data. +- `cache_key_prefix`: - *optional*. A prefix for the cache hash key. + Prefix is also used for restoring stale cache if no cache hit occurred + for key. + +### Outputs + +- `cache_key`: Caching key. ## Examples -```yaml -name: demo of sync-and-cache-s3 +``` yaml +name: Demo of sync-and-cache-s3 on: push: + pull_request: jobs: demo: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: viash-io/viash-actions/sync-and-cache-s3 - with: - s3_bucket: s3:/mybucket/resources - dest_path: resources + - name: Check out repository + uses: actions/checkout@v3 + + - name: Sync and cache an S3 bucket + uses: viash-io/viash-actions/sync-and-cache-s3 + with: + s3_bucket: s3:/mybucket/resources + dest_path: resources ``` diff --git a/project/sync-and-cache-s3/README.qmd b/project/sync-and-cache-s3/README.qmd new file mode 100644 index 0000000..c1bfc68 --- /dev/null +++ b/project/sync-and-cache-s3/README.qmd @@ -0,0 +1,66 @@ +--- +format: gfm +--- + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) +``` + +# `r action_name` + + + +`r action$description` + +### Inputs + +```{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")) +``` + +### Outputs + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +## Examples + +```yaml +name: Demo of `r action_name` + +on: + push: + pull_request: + +jobs: + demo: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: `r action$name` + uses: viash-io/viash-actions/sync-and-cache-s3 + with: + s3_bucket: s3:/mybucket/resources + dest_path: resources +``` + diff --git a/project/sync-and-cache-s3/action.yml b/project/sync-and-cache-s3/action.yml index fcd725f..c09496e 100644 --- a/project/sync-and-cache-s3/action.yml +++ b/project/sync-and-cache-s3/action.yml @@ -56,4 +56,4 @@ runs: - name: List resources shell: bash run: | - tree ${{ inputs.dest_path }} -L 3 \ No newline at end of file + tree ${{ inputs.dest_path }} -L 3 diff --git a/setup/README.md b/setup/README.md index 767ed40..e963f51 100644 --- a/setup/README.md +++ b/setup/README.md @@ -1,35 +1,33 @@ -# setup -Setup a Viash release (https://github.com/viash-io/viash/releases) using GitHub Actions. -## Usage +# setup -This action will use `wget get.viash.io` to install Viash in the `$HOME/.local/bin` directory and add that folder to the PATH. + -We recommend using a Linux or MacOS runner if possible. +This action will setup Viash from the git repository +https://github.com/viash-io/viash/ -### Inputs available +### Inputs -* `version` - _optional_. If provided, the specific Viash version will be installed. Ex: `version: 0.6.0`. +- `version`: - *optional*. The version of Viash to use. Either a release + tag (eg. 0.6.0) or “@develop” for latest development version. If + missing, uses latest stable version. - ```yaml - steps: - - uses: viash-io/viash-actions/setup@v3 - with: - version: 0.6.0 - ``` - - If not provided, `setup` will use the latest _released_ version of Viash. - - If the latest development build is desired, use `version: develop`. +### Outputs + +- `version`: The installed version of viash. ## Examples -```yaml -name: demo of setup +``` yaml +name: Demo of setup -on: - branch: main +on: + push: + pull_request: jobs: viash-linux: @@ -51,4 +49,3 @@ jobs: - run: | viash --version ``` - diff --git a/setup/README.qmd b/setup/README.qmd new file mode 100644 index 0000000..2c2095d --- /dev/null +++ b/setup/README.qmd @@ -0,0 +1,73 @@ +--- +format: gfm +--- + +```{r} +#| include: false +library(tidyverse) +action <- yaml::read_yaml("action.yml") +action_name <- basename(getwd()) +``` + +# `r action_name` + + + +`r action$description` + +### Inputs + +```{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")) +``` + +### Outputs + +```{r} +#| echo: false +lines <- map_chr(names(action$outputs), function(name) { + output <- action$outputs[[name]] + glue::glue("* `{name}`: {output$description}") +}) +knitr::asis_output(paste0(lines, collapse = "\n")) +``` + +## Examples + +```yaml +name: Demo of `r action_name` + +on: + push: + pull_request: + +jobs: + viash-linux: + runs-on: ubuntu-latest + steps: + - uses: viash-io/viash-actions/setup@v3 + - run: | + viash --version + viash-windows: + runs-on: windows-latest + steps: + - uses: viash-io/viash-actions/setup@v3 + - run: | + viash --version + viash-macos: + runs-on: macos-latest + steps: + - uses: viash-io/viash-actions/setup@v3 + - run: | + viash --version +``` + diff --git a/setup/action.yml b/setup/action.yml index fa1bd32..1164622 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -3,7 +3,7 @@ author: Data Intuitive description: 'This action will setup Viash from the git repository https://github.com/viash-io/viash/' inputs: version: - description: 'The version of Viash to use. Either a release tag (eg. 0.6.0) or "develop" for latest built dev version. If missing, uses latest stable version.' + description: 'The version of Viash to use. Either a release tag (eg. 0.6.0) or "@develop" for latest development version. If missing, uses latest stable version.' required: false outputs: version: From e4ad37a3f10b467661ae6c653b398c978d26d6e2 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:19:50 +0200 Subject: [PATCH 38/50] add changelog --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab6d860..24ee8e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +# viash-actions v6.0.0 + +## Breaking changes + +* `update-docker-engine` was moved to `project/update-docker-engine` (PR #27). + +* `pro/build-nextflow-params` arguments `components` and `workflows` were removed in favour for the `target_dir` argument (PR #27). + +* `pro/build-nextflow-schemas` arguments `components` and `workflows` were removed in favour for the `target_dir` argument (PR #27). + +## Major changes + +* All actions were updated to work with Viash 0.9 and later (PR #27). + +## Documentation + +* Updated all READMEs to be more consistent (PR #27). + # viash-actions v5.2.1 ## Bug Fixes From d259c57781c1e88080f851663b59d2941613a434 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:38:45 +0200 Subject: [PATCH 39/50] update docs --- CHANGELOG.md | 8 ++++++-- Makefile | 18 ++++++++++-------- project/build-target/README.md | 4 +++- project/build-target/action.yml | 10 +++++----- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ee8e7..a0b24c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ * `pro/build-nextflow-schemas` arguments `components` and `workflows` were removed in favour for the `target_dir` argument (PR #27). +## New functionality + +* `project/build-target`: Created an action for building a target directory using `viash ns build` and generating a matrix of the components for which Docker images need to be built and pushed (PR #27). + ## Major changes * All actions were updated to work with Viash 0.9 and later (PR #27). @@ -26,13 +30,13 @@ ## Minor changes -* `project/detect-changed-components`: bump `tj-actions/changed-files` to `42.0.2` (PR #24) +* `project/detect-changed-components`: bump `tj-actions/changed-files` to `42.0.2` (PR #24). # viash-actions v5.1.0 ## New functionality -* `pro/build-nextflow-schemas`: Add optional flag to allow dataset input for nf-tower (PR #23) +* `pro/build-nextflow-schemas`: Add optional flag to allow dataset input for nf-tower (PR #23). # viash-actions v5.0.0 diff --git a/Makefile b/Makefile index 2456e54..1421f8d 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ -# Find all .qmd files -QMD_FILES := $(shell find . -name "*.qmd") +# Set up some variables for consistency +QMD_FILES := $(shell find . -name "README.qmd") # Find all README.qmd files +MD_FILES := $(patsubst %.qmd,%.md,$(QMD_FILES)) # Corresponding MD filenames -# Render all .qmd files to md -all: $(QMD_FILES:.qmd=.md) +# Default target: build all MD files +all: $(MD_FILES) -# Recipe to render an individual .qmd file -%.md: %.qmd +README.md: README.qmd + quarto render $< +%/README.md: %/README.qmd %/action.yml quarto render $< -# Remove the generated md files +# Clean up generated MD files clean: - rm -f $(QMD_FILES:.qmd=.md) + rm -f $(MD_FILES) diff --git a/project/build-target/README.md b/project/build-target/README.md index 015b56c..f1c0486 100644 --- a/project/build-target/README.md +++ b/project/build-target/README.md @@ -7,7 +7,9 @@ DO NOT EDIT THIS FILE MANUALLY! This README was generated by running `make` --> -Builds a target directory using the viash ns build command. +Build a target directory using the viash ns build command and create a +matrix of the executables which have Docker containers that need to be +built. ### Inputs diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 8a6ea9c..99d8e76 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -1,7 +1,9 @@ name: Build target directory author: Data Intuitive description: > - Builds a target directory using the viash ns build command. + Build a target directory using the viash ns build command + and create a matrix of the executables which have Docker + containers that need to be built. inputs: version: @@ -81,8 +83,7 @@ runs: if: ${{ inputs.viash_pro_token != '' }} uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 with: - components: src - workflows: src + target_dir: ${{ steps.defaults.outputs.target_dir }} viash_pro_token: ${{ inputs.viash_pro_token }} tools_version: 'main_build' enable_dataset_input: true @@ -91,8 +92,7 @@ runs: if: ${{ inputs.viash_pro_token != '' }} uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 with: - workflows: src - components: src + target_dir: ${{ steps.defaults.outputs.target_dir }} viash_pro_token: ${{ inputs.viash_pro_token }} tools_version: 'main_build' From 4e150634674df90af2935b13518f6c7376b5dfc2 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:39:19 +0200 Subject: [PATCH 40/50] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0b24c9..0f35f54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ * Updated all READMEs to be more consistent (PR #27). +* Added a Makefile for generating READMEs more efficiently (PR #27). + # viash-actions v5.2.1 ## Bug Fixes From 3be470f10fdb2d974bc2cf8164b23c5da1f13702 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 12:41:12 +0200 Subject: [PATCH 41/50] update mentioned viash versions to v6 --- ns-build/README.md | 4 ++-- ns-build/README.qmd | 4 ++-- ns-list/README.md | 4 ++-- ns-list/README.qmd | 4 ++-- pro/build-nextflow-params/README.md | 4 ++-- pro/build-nextflow-params/README.qmd | 4 ++-- pro/build-nextflow-schemas/README.md | 4 ++-- pro/build-nextflow-schemas/README.qmd | 4 ++-- pro/generate-documentation-qmd/README.md | 4 ++-- pro/generate-documentation-qmd/README.qmd | 4 ++-- project/build-target/README.md | 4 ++-- project/build-target/README.qmd | 4 ++-- project/build-target/action.yml | 6 +++--- project/detect-changed-components/README.md | 4 ++-- project/detect-changed-components/README.qmd | 4 ++-- project/is-pr/README.md | 2 +- project/is-pr/README.qmd | 2 +- project/update-docker-engine/README.md | 2 +- project/update-docker-engine/README.qmd | 2 +- setup/README.md | 6 +++--- setup/README.qmd | 6 +++--- 21 files changed, 41 insertions(+), 41 deletions(-) diff --git a/ns-build/README.md b/ns-build/README.md index e0372fd..8228022 100644 --- a/ns-build/README.md +++ b/ns-build/README.md @@ -76,8 +76,8 @@ jobs: uses: actions/checkout@v3 - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: viash ns build - uses: viash-io/viash-actions/ns-build@v3 + uses: viash-io/viash-actions/ns-build@v6 ``` diff --git a/ns-build/README.qmd b/ns-build/README.qmd index c12c470..9626936 100644 --- a/ns-build/README.qmd +++ b/ns-build/README.qmd @@ -63,9 +63,9 @@ jobs: uses: actions/checkout@v3 - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: `r action$name` - uses: viash-io/viash-actions/ns-build@v3 + uses: viash-io/viash-actions/ns-build@v6 ``` diff --git a/ns-list/README.md b/ns-list/README.md index dee2e93..e372db1 100644 --- a/ns-list/README.md +++ b/ns-list/README.md @@ -92,13 +92,13 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 - name: viash ns list - uses: viash-io/viash-actions/ns-list@v3 + uses: viash-io/viash-actions/ns-list@v6 - name: View output run: | diff --git a/ns-list/README.qmd b/ns-list/README.qmd index 563a420..9f60ac6 100644 --- a/ns-list/README.qmd +++ b/ns-list/README.qmd @@ -65,13 +65,13 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 - name: `r action$name` - uses: viash-io/viash-actions/ns-list@v3 + uses: viash-io/viash-actions/ns-list@v6 - name: View output run: | diff --git a/pro/build-nextflow-params/README.md b/pro/build-nextflow-params/README.md index 25e7d75..fd56de2 100644 --- a/pro/build-nextflow-params/README.md +++ b/pro/build-nextflow-params/README.md @@ -37,13 +37,13 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 - name: Build parameter yaml - uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 + uses: viash-io/viash-actions/pro/build-nextflow-params@v6 with: target: target/ token: ${{ secrets.VIASH_PRO_TOKEN }} diff --git a/pro/build-nextflow-params/README.qmd b/pro/build-nextflow-params/README.qmd index 3638237..e2f1f0a 100644 --- a/pro/build-nextflow-params/README.qmd +++ b/pro/build-nextflow-params/README.qmd @@ -58,13 +58,13 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 - name: `r action$name` - uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 + uses: viash-io/viash-actions/pro/build-nextflow-params@v6 with: target: target/ token: ${{ secrets.VIASH_PRO_TOKEN }} diff --git a/pro/build-nextflow-schemas/README.md b/pro/build-nextflow-schemas/README.md index db2c5e6..3be36f3 100644 --- a/pro/build-nextflow-schemas/README.md +++ b/pro/build-nextflow-schemas/README.md @@ -38,13 +38,13 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 - name: Build nf-tower schemas - uses: viash-io/viash-actions/pro/build-nextflow-schemas@viash-0.9 + uses: viash-io/viash-actions/pro/build-nextflow-schemas@v6 with: target: target/ token: ${{ secrets.VIASH_PRO_TOKEN }} diff --git a/pro/build-nextflow-schemas/README.qmd b/pro/build-nextflow-schemas/README.qmd index f420ec6..e89b88e 100644 --- a/pro/build-nextflow-schemas/README.qmd +++ b/pro/build-nextflow-schemas/README.qmd @@ -58,13 +58,13 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 - name: `r action$name` - uses: viash-io/viash-actions/pro/build-nextflow-schemas@viash-0.9 + uses: viash-io/viash-actions/pro/build-nextflow-schemas@v6 with: target: target/ token: ${{ secrets.VIASH_PRO_TOKEN }} diff --git a/pro/generate-documentation-qmd/README.md b/pro/generate-documentation-qmd/README.md index e8a9611..0a16432 100644 --- a/pro/generate-documentation-qmd/README.md +++ b/pro/generate-documentation-qmd/README.md @@ -64,7 +64,7 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 @@ -72,7 +72,7 @@ jobs: path: project - name: Build and publish qmd - uses: viash-io/viash-actions/generate-documentation-qmd@v3 + uses: viash-io/viash-actions/generate-documentation-qmd@v6 with: project_dir: project src: src diff --git a/pro/generate-documentation-qmd/README.qmd b/pro/generate-documentation-qmd/README.qmd index ea44b7a..aa09f92 100644 --- a/pro/generate-documentation-qmd/README.qmd +++ b/pro/generate-documentation-qmd/README.qmd @@ -58,7 +58,7 @@ jobs: steps: - name: Install Viash - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Check out repository uses: actions/checkout@v3 @@ -66,7 +66,7 @@ jobs: path: project - name: `r action$name` - uses: viash-io/viash-actions/generate-documentation-qmd@v3 + uses: viash-io/viash-actions/generate-documentation-qmd@v6 with: project_dir: project src: src diff --git a/project/build-target/README.md b/project/build-target/README.md index f1c0486..8762f82 100644 --- a/project/build-target/README.md +++ b/project/build-target/README.md @@ -42,11 +42,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: Build target directory id: build_target - uses: viash-io/viash-actions/build-target@v5 + uses: viash-io/viash-actions/build-target@v6 - name: Check output run: | diff --git a/project/build-target/README.qmd b/project/build-target/README.qmd index 4292b56..0e118b0 100644 --- a/project/build-target/README.qmd +++ b/project/build-target/README.qmd @@ -55,11 +55,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: viash-io/viash-actions/setup@v3 + uses: viash-io/viash-actions/setup@v6 - name: `r action$name` id: build_target - uses: viash-io/viash-actions/build-target@v5 + uses: viash-io/viash-actions/build-target@v6 - name: Check output run: | diff --git a/project/build-target/action.yml b/project/build-target/action.yml index 99d8e76..8078bf9 100644 --- a/project/build-target/action.yml +++ b/project/build-target/action.yml @@ -74,14 +74,14 @@ runs: run: | yq eval '.version = "${{ steps.defaults.outputs.version }}"' -i _viash.yaml - - uses: viash-io/viash-actions/ns-build@viash-0.9 + - uses: viash-io/viash-actions/ns-build@v6 with: parallel: true config_mod: ${{ steps.defaults.outputs.config_mod }} - name: Build nextflow schemas if: ${{ inputs.viash_pro_token != '' }} - uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 + uses: viash-io/viash-actions/pro/build-nextflow-params@v6 with: target_dir: ${{ steps.defaults.outputs.target_dir }} viash_pro_token: ${{ inputs.viash_pro_token }} @@ -90,7 +90,7 @@ runs: - name: Build parameter files if: ${{ inputs.viash_pro_token != '' }} - uses: viash-io/viash-actions/pro/build-nextflow-params@viash-0.9 + uses: viash-io/viash-actions/pro/build-nextflow-params@v6 with: target_dir: ${{ steps.defaults.outputs.target_dir }} viash_pro_token: ${{ inputs.viash_pro_token }} diff --git a/project/detect-changed-components/README.md b/project/detect-changed-components/README.md index a08e333..ee95fd8 100644 --- a/project/detect-changed-components/README.md +++ b/project/detect-changed-components/README.md @@ -38,13 +38,13 @@ jobs: - uses: actions/checkout@v3 - id: ns_list - uses: viash-io/viash-actions/ns-list@v3 + uses: viash-io/viash-actions/ns-list@v6 with: format: json - name: Detect components with changed files id: ns_list_changed - uses: viash-io/viash-actions/detect-changed-components@v3 + uses: viash-io/viash-actions/detect-changed-components@v6 with: input_file: ${{ steps.ns_list.outputs.output_file }} ``` diff --git a/project/detect-changed-components/README.qmd b/project/detect-changed-components/README.qmd index 4df8074..cf75b2a 100644 --- a/project/detect-changed-components/README.qmd +++ b/project/detect-changed-components/README.qmd @@ -57,13 +57,13 @@ jobs: - uses: actions/checkout@v3 - id: ns_list - uses: viash-io/viash-actions/ns-list@v3 + uses: viash-io/viash-actions/ns-list@v6 with: format: json - name: `r action$name` id: ns_list_changed - uses: viash-io/viash-actions/detect-changed-components@v3 + uses: viash-io/viash-actions/detect-changed-components@v6 with: input_file: ${{ steps.ns_list.outputs.output_file }} ``` diff --git a/project/is-pr/README.md b/project/is-pr/README.md index 7887c72..8faf9ec 100644 --- a/project/is-pr/README.md +++ b/project/is-pr/README.md @@ -34,7 +34,7 @@ jobs: uses: actions/checkout@v3 - name: Is PR - uses: viash-io/viash-actions/is-pr@v1 + uses: viash-io/viash-actions/is-pr@v6 id: is_pr - run: | diff --git a/project/is-pr/README.qmd b/project/is-pr/README.qmd index 79b8e26..f86e30e 100644 --- a/project/is-pr/README.qmd +++ b/project/is-pr/README.qmd @@ -58,7 +58,7 @@ jobs: uses: actions/checkout@v3 - name: `r action$name` - uses: viash-io/viash-actions/is-pr@v1 + uses: viash-io/viash-actions/is-pr@v6 id: is_pr - run: | diff --git a/project/update-docker-engine/README.md b/project/update-docker-engine/README.md index c40c6cd..5999562 100644 --- a/project/update-docker-engine/README.md +++ b/project/update-docker-engine/README.md @@ -32,5 +32,5 @@ jobs: uses: actions/checkout@v3 - name: Update Docker Engine - uses: viash-io/viash-actions/update-docker-engine@v3 + uses: viash-io/viash-actions/update-docker-engine@v6 ``` diff --git a/project/update-docker-engine/README.qmd b/project/update-docker-engine/README.qmd index 6411815..6dc9829 100644 --- a/project/update-docker-engine/README.qmd +++ b/project/update-docker-engine/README.qmd @@ -58,6 +58,6 @@ jobs: uses: actions/checkout@v3 - name: `r action$name` - uses: viash-io/viash-actions/project/update-docker-engine@v3 + uses: viash-io/viash-actions/project/update-docker-engine@v6 ``` diff --git a/setup/README.md b/setup/README.md index e963f51..4536ebf 100644 --- a/setup/README.md +++ b/setup/README.md @@ -33,19 +33,19 @@ jobs: viash-linux: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - uses: viash-io/viash-actions/setup@v6 - run: | viash --version viash-windows: runs-on: windows-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - uses: viash-io/viash-actions/setup@v6 - run: | viash --version viash-macos: runs-on: macos-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - uses: viash-io/viash-actions/setup@v6 - run: | viash --version ``` diff --git a/setup/README.qmd b/setup/README.qmd index 2c2095d..a29c416 100644 --- a/setup/README.qmd +++ b/setup/README.qmd @@ -54,19 +54,19 @@ jobs: viash-linux: runs-on: ubuntu-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - uses: viash-io/viash-actions/setup@v6 - run: | viash --version viash-windows: runs-on: windows-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - uses: viash-io/viash-actions/setup@v6 - run: | viash --version viash-macos: runs-on: macos-latest steps: - - uses: viash-io/viash-actions/setup@v3 + - uses: viash-io/viash-actions/setup@v6 - run: | viash --version ``` From cf832fed68ab73ab9ccbd273033a634b6f685f71 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 13:23:18 +0200 Subject: [PATCH 42/50] fix platform description --- ns-build/README.md | 27 +++++++++++++-------------- ns-build/action.yml | 6 +++--- ns-list/README.md | 28 ++++++++++++++-------------- ns-list/action.yml | 6 +++--- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/ns-build/README.md b/ns-build/README.md index 8228022..b2fcde9 100644 --- a/ns-build/README.md +++ b/ns-build/README.md @@ -28,20 +28,19 @@ We recommend using a Linux or MacOS runner if possible. 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*. Deprecated. Use –runner and –engine instead. - 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. -- `runner`: - *optional*. Acts as a regular expression to filter the - runner ids specified in the found config files. If this is not - provided, all runners will be used. If no runners are defined in a - config, the executable runner will be used. -- `engine`: - *optional*. Acts as a regular expression to filter the - engine ids specified in the found config files. If this is not - provided, all engines will be used. If no engines are defined in a - config, the native engine will be used. +- `platform`: - *optional*. (viash \< 0.9.0) 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. +- `runner`: - *optional*. (viash \>= 0.9.0) Acts as a regular expression + to filter the runner ids specified in the found config files. If this + is not provided, all runners will be used. If no runners are defined + in a config, the executable runner will be used. +- `engine`: - *optional*. (viash \>= 0.9.0) Acts as a regular expression + to filter the engine ids specified in the found config files. If this + is not provided, all engines will be used. If no engines are defined + in a config, the native engine will be used. - `parallel`: - *optional*. Whether or not to run the process in parallel. - `config_mod`: - *optional*. Modify a viash config at runtime using diff --git a/ns-build/action.yml b/ns-build/action.yml index 4760a32..7189f55 100644 --- a/ns-build/action.yml +++ b/ns-build/action.yml @@ -23,19 +23,19 @@ inputs: in a hierarchical folder structure. Default: src/.' required: false platform: - description: Deprecated. Use --runner and --engine instead. Acts as a regular + description: (viash < 0.9.0) 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 runner: - description: Acts as a regular expression to filter the runner ids specified in + description: (viash >= 0.9.0) Acts as a regular expression to filter the runner ids specified in the found config files. If this is not provided, all runners will be used. If no runners are defined in a config, the executable runner will be used. required: false engine: - description: Acts as a regular expression to filter the engine ids specified in + description: (viash >= 0.9.0) Acts as a regular expression to filter the engine ids specified in the found config files. If this is not provided, all engines will be used. If no engines are defined in a config, the native engine will be used. required: false diff --git a/ns-list/README.md b/ns-list/README.md index e372db1..5f17867 100644 --- a/ns-list/README.md +++ b/ns-list/README.md @@ -28,20 +28,20 @@ We recommend using a Linux or MacOS runner if possible. 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*. Deprecated. Use –runner and –engine instead. - 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. -- `runner`: - *optional*. Acts as a regular expression to filter the - runner ids specified in the found config files. If this is not - provided, all runners will be used. If no runners are defined in a - config, the executable runner will be used. -- `engine`: - *optional*. Acts as a regular expression to filter the - engine ids specified in the found config files. If this is not - provided, all engines will be used. If no engines are defined in a - config, the native engine will be used. +- `platform`: - *optional*. (viash \< 0.9.0) Use –runner and –engine + instead. 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. +- `runner`: - *optional*. (viash \>= 0.9.0) Acts as a regular expression + to filter the runner ids specified in the found config files. If this + is not provided, all runners will be used. If no runners are defined + in a config, the executable runner will be used. +- `engine`: - *optional*. (viash \>= 0.9.0) Acts as a regular expression + to filter the engine ids specified in the found config files. If this + is not provided, all engines will be used. If no engines are defined + in a config, the native engine will be used. - `config_mod`: - *optional*. Modify a viash config at runtime using config_mod. - `colorize`: - *optional*. Specify whether the console output should be diff --git a/ns-list/action.yml b/ns-list/action.yml index 49d1259..244306c 100644 --- a/ns-list/action.yml +++ b/ns-list/action.yml @@ -23,19 +23,19 @@ inputs: in a hierarchical folder structure. Default: src/.' required: false platform: - description: Deprecated. Use --runner and --engine instead. Acts as a regular + description: (viash < 0.9.0) Use --runner and --engine instead. 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 runner: - description: Acts as a regular expression to filter the runner ids specified in + description: (viash >= 0.9.0) Acts as a regular expression to filter the runner ids specified in the found config files. If this is not provided, all runners will be used. If no runners are defined in a config, the executable runner will be used. required: false engine: - description: Acts as a regular expression to filter the engine ids specified in + description: (viash >= 0.9.0) Acts as a regular expression to filter the engine ids specified in the found config files. If this is not provided, all engines will be used. If no engines are defined in a config, the native engine will be used. required: false From c405fc64c4c9367ef9d969b410f81f606d2e7ebd Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 13:25:05 +0200 Subject: [PATCH 43/50] fix indentation --- README.md | 29 ++++++++++++++++++----------- README.qmd | 6 +++--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1e259d4..525af3a 100644 --- a/README.md +++ b/README.md @@ -5,24 +5,31 @@ This repository stores [Github Actions](https://github.com/features/actions) useful for building and publishing [Viash](https://viash.io) components: - 1. [viash-io/viash-actions/ns-build@v6](ns-build) - viash ns build - 1. [viash-io/viash-actions/ns-list@v6](ns-list) - viash ns list - 1. [viash-io/viash-actions/setup@v6](setup) - Setup Viash +1. [viash-io/viash-actions/ns-build@v6](ns-build) - viash ns build +2. [viash-io/viash-actions/ns-list@v6](ns-list) - viash ns list +3. [viash-io/viash-actions/setup@v6](setup) - Setup Viash There are also some actions that are commonly used in Viash projects: - 1. [viash-io/viash-actions/project/build-target@v6](project/build-target) - Build target directory - 1. [viash-io/viash-actions/project/detect-changed-components@v6](project/detect-changed-components) - Detect components with changed files - 1. [viash-io/viash-actions/project/is-pr@v6](project/is-pr) - Is PR - 1. [viash-io/viash-actions/project/sync-and-cache-s3@v6](project/sync-and-cache-s3) - Sync and cache an S3 bucket - 1. [viash-io/viash-actions/project/update-docker-engine@v6](project/update-docker-engine) - Update Docker Engine +1. [viash-io/viash-actions/project/build-target@v6](project/build-target) - + Build target directory +2. [viash-io/viash-actions/project/detect-changed-components@v6](project/detect-changed-components) - + Detect components with changed files +3. [viash-io/viash-actions/project/is-pr@v6](project/is-pr) - Is PR +4. [viash-io/viash-actions/project/sync-and-cache-s3@v6](project/sync-and-cache-s3) - + Sync and cache an S3 bucket +5. [viash-io/viash-actions/project/update-docker-engine@v6](project/update-docker-engine) - + Update Docker Engine Finally, there are some [Viash Pro](https://www.data-intuitive.com/services/viashpro.html) actions: - 1. [viash-io/viash-actions/pro/build-nextflow-params@v6](pro/build-nextflow-params) - Build parameter yaml - 1. [viash-io/viash-actions/pro/build-nextflow-schemas@v6](pro/build-nextflow-schemas) - Build nf-tower schemas - 1. [viash-io/viash-actions/pro/generate-documentation-qmd@v6](pro/generate-documentation-qmd) - Build and publish qmd +1. [viash-io/viash-actions/pro/build-nextflow-params@v6](pro/build-nextflow-params) - + Build parameter yaml +2. [viash-io/viash-actions/pro/build-nextflow-schemas@v6](pro/build-nextflow-schemas) - + Build nf-tower schemas +3. [viash-io/viash-actions/pro/generate-documentation-qmd@v6](pro/generate-documentation-qmd) - + Build and publish qmd We recommend using `v6` for your actions. diff --git a/README.qmd b/README.qmd index 559866c..263e9bc 100644 --- a/README.qmd +++ b/README.qmd @@ -23,21 +23,21 @@ actions <- tibble( This repository stores [Github Actions](https://github.com/features/actions) useful for building and publishing [Viash](https://viash.io) components: -```{r} +```{r output="asis"} #| echo: false cat(actions %>% filter(namespace == "") %>% pull(str) %>% paste(collapse = "")) ``` There are also some actions that are commonly used in Viash projects: -```{r} +```{r output="asis"} #| echo: false cat(actions %>% filter(namespace == "project") %>% pull(str) %>% paste(collapse = "")) ``` Finally, there are some [Viash Pro](https://www.data-intuitive.com/services/viashpro.html) actions: -```{r} +```{r output="asis"} #| echo: false cat(actions %>% filter(namespace == "pro") %>% pull(str) %>% paste(collapse = "")) ``` From 32af76256f83681b7c84ee545508b7340f56e7e2 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 13:29:45 +0200 Subject: [PATCH 44/50] update readme --- README.md | 27 +++++++++++++-------------- README.qmd | 4 ++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 525af3a..9becc8c 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,33 @@ # Github Actions for Viash -This repository stores [Github -Actions](https://github.com/features/actions) useful for building and -publishing [Viash](https://viash.io) components: +This repository stores Github Actions useful for building and publishing +[Viash](https://viash.io) components: -1. [viash-io/viash-actions/ns-build@v6](ns-build) - viash ns build -2. [viash-io/viash-actions/ns-list@v6](ns-list) - viash ns list -3. [viash-io/viash-actions/setup@v6](setup) - Setup Viash +1. [`viash-io/viash-actions/ns-build@v6`](ns-build) - viash ns build +2. [`viash-io/viash-actions/ns-list@v6`](ns-list) - viash ns list +3. [`viash-io/viash-actions/setup@v6`](setup) - Setup Viash There are also some actions that are commonly used in Viash projects: -1. [viash-io/viash-actions/project/build-target@v6](project/build-target) - +1. [`viash-io/viash-actions/project/build-target@v6`](project/build-target) - Build target directory -2. [viash-io/viash-actions/project/detect-changed-components@v6](project/detect-changed-components) - +2. [`viash-io/viash-actions/project/detect-changed-components@v6`](project/detect-changed-components) - Detect components with changed files -3. [viash-io/viash-actions/project/is-pr@v6](project/is-pr) - Is PR -4. [viash-io/viash-actions/project/sync-and-cache-s3@v6](project/sync-and-cache-s3) - +3. [`viash-io/viash-actions/project/is-pr@v6`](project/is-pr) - Is PR +4. [`viash-io/viash-actions/project/sync-and-cache-s3@v6`](project/sync-and-cache-s3) - Sync and cache an S3 bucket -5. [viash-io/viash-actions/project/update-docker-engine@v6](project/update-docker-engine) - +5. [`viash-io/viash-actions/project/update-docker-engine@v6`](project/update-docker-engine) - Update Docker Engine Finally, there are some [Viash Pro](https://www.data-intuitive.com/services/viashpro.html) actions: -1. [viash-io/viash-actions/pro/build-nextflow-params@v6](pro/build-nextflow-params) - +1. [`viash-io/viash-actions/pro/build-nextflow-params@v6`](pro/build-nextflow-params) - Build parameter yaml -2. [viash-io/viash-actions/pro/build-nextflow-schemas@v6](pro/build-nextflow-schemas) - +2. [`viash-io/viash-actions/pro/build-nextflow-schemas@v6`](pro/build-nextflow-schemas) - Build nf-tower schemas -3. [viash-io/viash-actions/pro/generate-documentation-qmd@v6](pro/generate-documentation-qmd) - +3. [`viash-io/viash-actions/pro/generate-documentation-qmd@v6`](pro/generate-documentation-qmd) - Build and publish qmd We recommend using `v6` for your actions. diff --git a/README.qmd b/README.qmd index 263e9bc..8601fc3 100644 --- a/README.qmd +++ b/README.qmd @@ -16,12 +16,12 @@ actions <- tibble( action = map(file, yaml::read_yaml), action_name = map_chr(action, "name"), namespace = ifelse(grepl("/", path), gsub("/.*", "", path), ""), - str = paste0("1. [", repo_name, "/", path, "@", latest_stable_version, "](", path, ") - ", action_name, "\n") + str = paste0("1. [`", repo_name, "/", path, "@", latest_stable_version, "`](", path, ") - ", action_name, "\n") ) ``` -This repository stores [Github Actions](https://github.com/features/actions) useful for building and publishing [Viash](https://viash.io) components: +This repository stores Github Actions useful for building and publishing [Viash](https://viash.io) components: ```{r output="asis"} #| echo: false From 9b43ba26e8603e3bacf51644b42a2bc3d20bb89e Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 13:30:37 +0200 Subject: [PATCH 45/50] simplify readme --- README.md | 30 +++++++++++++++--------------- README.qmd | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9becc8c..1b009db 100644 --- a/README.md +++ b/README.md @@ -4,30 +4,30 @@ This repository stores Github Actions useful for building and publishing [Viash](https://viash.io) components: -1. [`viash-io/viash-actions/ns-build@v6`](ns-build) - viash ns build -2. [`viash-io/viash-actions/ns-list@v6`](ns-list) - viash ns list -3. [`viash-io/viash-actions/setup@v6`](setup) - Setup Viash +1. [`ns-build`](ns-build) - viash ns build +2. [`ns-list`](ns-list) - viash ns list +3. [`setup`](setup) - Setup Viash There are also some actions that are commonly used in Viash projects: -1. [`viash-io/viash-actions/project/build-target@v6`](project/build-target) - - Build target directory -2. [`viash-io/viash-actions/project/detect-changed-components@v6`](project/detect-changed-components) - +1. [`project/build-target`](project/build-target) - Build target + directory +2. [`project/detect-changed-components`](project/detect-changed-components) - Detect components with changed files -3. [`viash-io/viash-actions/project/is-pr@v6`](project/is-pr) - Is PR -4. [`viash-io/viash-actions/project/sync-and-cache-s3@v6`](project/sync-and-cache-s3) - - Sync and cache an S3 bucket -5. [`viash-io/viash-actions/project/update-docker-engine@v6`](project/update-docker-engine) - +3. [`project/is-pr`](project/is-pr) - Is PR +4. [`project/sync-and-cache-s3`](project/sync-and-cache-s3) - Sync and + cache an S3 bucket +5. [`project/update-docker-engine`](project/update-docker-engine) - Update Docker Engine Finally, there are some [Viash Pro](https://www.data-intuitive.com/services/viashpro.html) actions: -1. [`viash-io/viash-actions/pro/build-nextflow-params@v6`](pro/build-nextflow-params) - - Build parameter yaml -2. [`viash-io/viash-actions/pro/build-nextflow-schemas@v6`](pro/build-nextflow-schemas) - - Build nf-tower schemas -3. [`viash-io/viash-actions/pro/generate-documentation-qmd@v6`](pro/generate-documentation-qmd) - +1. [`pro/build-nextflow-params`](pro/build-nextflow-params) - Build + parameter yaml +2. [`pro/build-nextflow-schemas`](pro/build-nextflow-schemas) - Build + nf-tower schemas +3. [`pro/generate-documentation-qmd`](pro/generate-documentation-qmd) - Build and publish qmd We recommend using `v6` for your actions. diff --git a/README.qmd b/README.qmd index 8601fc3..aadffec 100644 --- a/README.qmd +++ b/README.qmd @@ -16,7 +16,7 @@ actions <- tibble( action = map(file, yaml::read_yaml), action_name = map_chr(action, "name"), namespace = ifelse(grepl("/", path), gsub("/.*", "", path), ""), - str = paste0("1. [`", repo_name, "/", path, "@", latest_stable_version, "`](", path, ") - ", action_name, "\n") + str = paste0("1. [`", path, "`](", path, ") - ", action_name, "\n") ) ``` From d120674d8595c0d1eb70941856c52e6bfd11a3b4 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 13:40:08 +0200 Subject: [PATCH 46/50] fix check-concurrent-pr --- CHANGELOG.md | 2 + project/check-concurrent-pr/README.md | 47 +++++++++++++++++++ .../{is-pr => check-concurrent-pr}/README.qmd | 0 project/check-concurrent-pr/action.yml | 47 +++++++++++++++++++ project/is-pr/README.md | 42 ----------------- project/is-pr/action.yml | 26 ---------- 6 files changed, 96 insertions(+), 68 deletions(-) create mode 100644 project/check-concurrent-pr/README.md rename project/{is-pr => check-concurrent-pr}/README.qmd (100%) create mode 100644 project/check-concurrent-pr/action.yml delete mode 100644 project/is-pr/README.md delete mode 100644 project/is-pr/action.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d69e78..310b0e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ * `project/build-target`: Created an action for building a target directory using `viash ns build` and generating a matrix of the components for which Docker images need to be built and pushed (PR #27). +* `project/check-concurrent-pr`: Created an action for checking if a push event is concurrent with a pull request (PR #27). + ## Major changes * All actions were updated to work with Viash 0.9 and later (PR #27). diff --git a/project/check-concurrent-pr/README.md b/project/check-concurrent-pr/README.md new file mode 100644 index 0000000..609639e --- /dev/null +++ b/project/check-concurrent-pr/README.md @@ -0,0 +1,47 @@ + + +# check-concurrent-pr + + + +Assuming that an action is triggered by both a push event and a pull +request, this action will: + +- Return ‘true’ if the branch is the default branch +- Return ‘true’ if the event is not a push event +- Return ‘true’ if the commit message contains ‘ci force’ +- Return ‘false’ if a PR exists for the branch, else ‘true’ + +### Inputs + +### Outputs + +- `run`: Returns “true” if the branch has a PR and this run was not + triggered by a push event, else “false”. + +## Examples + +``` yaml +name: Demo of check-concurrent-pr + +on: + push: + pull_request: + +jobs: + demo: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Check for concurrent PRs + uses: viash-io/viash-actions/is-pr@v6 + id: is_pr + + - run: | + echo "Is PR: ${{ steps.is_pr.outputs.check }}" +``` diff --git a/project/is-pr/README.qmd b/project/check-concurrent-pr/README.qmd similarity index 100% rename from project/is-pr/README.qmd rename to project/check-concurrent-pr/README.qmd diff --git a/project/check-concurrent-pr/action.yml b/project/check-concurrent-pr/action.yml new file mode 100644 index 0000000..d3c3917 --- /dev/null +++ b/project/check-concurrent-pr/action.yml @@ -0,0 +1,47 @@ +name: Check for concurrent PRs +author: Data Intuitive +description: > + Assuming that an action is triggered by both a push event and a pull request, this action will: + + - Return 'true' if the branch is the default branch + - Return 'true' if the event is not a push event + - Return 'true' if the commit message contains 'ci force' + - Return 'false' if a PR exists for the branch, else 'true' +outputs: + run: + description: 'Returns "true" if the branch has a PR and this run was not triggered by a push event, else "false".' + value: ${{ steps.check.outputs.run }} +runs: + using: 'composite' + steps: + - name: 'Check whether the branch has a PR and if this run was triggered by a push event' + shell: bash + id: check + run: | + # if the branch is the default branch, always run + if [[ "$GITHUB_REF_NAME" == "$GITHUB_DEFAULT_BRANCH" ]]; then + echo "run=true" >> $GITHUB_OUTPUT + exit 0 + fi + + # if the event is not a push event, always run + if [[ "${{ github.event_name == 'push' }}" == "false" ]]; then + echo "run=true" >> $GITHUB_OUTPUT + exit 0 + fi + + # if the commit message contains 'ci force', always run + if [[ "${{ contains(github.event.head_commit.message, 'ci force') }}" == "true" ]]; then + echo "run=true" >> $GITHUB_OUTPUT + exit 0 + fi + + # if a PR exists for the branch, do not run + pull_request=$(gh pr list -R ${{ github.repository }} -H ${{ github.ref_name }} --json url --state open --limit 1 | jq '.[0].url') + if [[ "$pull_request" == "null" ]]; then + echo "run=true" >> $GITHUB_OUTPUT + else + echo "run=false" >> $GITHUB_OUTPUT + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/project/is-pr/README.md b/project/is-pr/README.md deleted file mode 100644 index 8faf9ec..0000000 --- a/project/is-pr/README.md +++ /dev/null @@ -1,42 +0,0 @@ - - -# is-pr - - - -Check whether the branch has a PR and if this run was triggered by a -push event. - -### Inputs - -### Outputs - -- `check`: Returns “true” if the branch has a PR and this run was not - triggered by a push event, else “false”. - -## Examples - -``` yaml -name: Demo of is-pr - -on: - push: - pull_request: - -jobs: - demo: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Is PR - uses: viash-io/viash-actions/is-pr@v6 - id: is_pr - - - run: | - echo "Is PR: ${{ steps.is_pr.outputs.check }}" -``` diff --git a/project/is-pr/action.yml b/project/is-pr/action.yml deleted file mode 100644 index db3261d..0000000 --- a/project/is-pr/action.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Is PR -author: Data Intuitive -description: > - Check whether the branch has a PR and if this run was triggered by a push event. -outputs: - check: - description: 'Returns "true" if the branch has a PR and this run was not triggered by a push event, else "false".' - value: ${{ steps.github_cli.outputs.check }} - -runs: - using: 'composite' - steps: - - name: 'Check whether the branch has a PR and if this run was triggered by a push event' - shell: bash - id: github_cli - run: | - pull_request=$(gh pr list -R ${{ github.repository }} -H ${{ github.ref_name }} --json url --state open --limit 1 | jq '.[0].url') - - # If the branch has a PR and this run was triggered by a push event, do not run - if [[ "$pull_request" != "null" && "$GITHUB_REF_NAME" != "main" && "${{ github.event_name == 'push' }}" == "true" && "${{ !contains(github.event.head_commit.message, 'ci force') }}" == "true" ]]; then - echo "check=false" >> $GITHUB_OUTPUT - else - echo "check=true" >> $GITHUB_OUTPUT - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4f2175c8a610541a11ebac07862e20002dae1ac5 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 13:44:48 +0200 Subject: [PATCH 47/50] fix fallback --- project/detect-changed-components/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/detect-changed-components/action.yml b/project/detect-changed-components/action.yml index 99284c0..1cfda0e 100644 --- a/project/detect-changed-components/action.yml +++ b/project/detect-changed-components/action.yml @@ -174,8 +174,8 @@ runs: { "name": (.name // .functionality.name), "namespace": (.namespace // .functionality.namespace // ""), - "config": .build_info.config, - "dir": .build_info.config | capture("^(?.*\/)").dir + "config": (.build_info.config // .info.config), + "dir": (.build_info.config // .info.config) | capture("^(?.*\/)").dir } ]' $comp_file ) From 8b95643767a419995ba6f05f8f5d9c54eafe92df Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 16:42:47 +0200 Subject: [PATCH 48/50] add paste --- pro/build-nextflow-schemas/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pro/build-nextflow-schemas/action.yml b/pro/build-nextflow-schemas/action.yml index 306c2ab..a75a987 100644 --- a/pro/build-nextflow-schemas/action.yml +++ b/pro/build-nextflow-schemas/action.yml @@ -73,6 +73,6 @@ runs: echo viash_tools/target/docker/nextflow/generate_schema/generate_schema \ - --input "$BUILT_CONFIGS" \ - --output "$NEXTFLOW_SCHEMAS" \ - ${{ inputs.enable_dataset_input }} + --input "$(echo "$BUILT_CONFIGS" | paste -sd ";")" \ + --output "$(echo "$NEXTFLOW_SCHEMAS" | paste -sd ";")" \ + ${{ inputs.enable_dataset_input == "true" ? "--enable_dataset_input" : "" }} From d43b0b27f350eedbf6b6d019ea6e4f338fd48034 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 27 Jun 2024 16:44:32 +0200 Subject: [PATCH 49/50] fix flag --- pro/build-nextflow-schemas/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pro/build-nextflow-schemas/action.yml b/pro/build-nextflow-schemas/action.yml index a75a987..c0b6f55 100644 --- a/pro/build-nextflow-schemas/action.yml +++ b/pro/build-nextflow-schemas/action.yml @@ -75,4 +75,4 @@ runs: viash_tools/target/docker/nextflow/generate_schema/generate_schema \ --input "$(echo "$BUILT_CONFIGS" | paste -sd ";")" \ --output "$(echo "$NEXTFLOW_SCHEMAS" | paste -sd ";")" \ - ${{ inputs.enable_dataset_input == "true" ? "--enable_dataset_input" : "" }} + $([[ "${{ inputs.enable_dataset_input }}" == "true" ]] && echo "--enable_dataset_input") From 6654611e1e6df0b9380a759f54d6dc01e23ad3bd Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 28 Jun 2024 08:51:12 +0200 Subject: [PATCH 50/50] add entry to changelog --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 310b0e1..edeb5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,11 @@ * `update-docker-engine` was moved to `project/update-docker-engine` (PR #27). -* `pro/build-nextflow-params` arguments `components` and `workflows` were removed in favour for the `target_dir` argument (PR #27). +* `pro/build-nextflow-params`: Arguments `components` and `workflows` were removed in favour for the `target_dir` argument (PR #27). -* `pro/build-nextflow-schemas` arguments `components` and `workflows` were removed in favour for the `target_dir` argument (PR #27). +* `pro/build-nextflow-schemas`: Arguments `components` and `workflows` were removed in favour for the `target_dir` argument (PR #27). + +* Removed `viash-hub/deploy`: Viash Hub pulls source code from GitHub and builds Viash packages accordingly, as opposed to pushing deployments using GitHub Actions (PR #27). ## New functionality