Skip to content

Commit

Permalink
ref(15): Start testing wild integration with Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanjerome committed Aug 25, 2023
1 parent 9ce19bf commit 7a2ec3c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
64 changes: 32 additions & 32 deletions src/lib/workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
set -euo pipefail

#@desc Check prerequisites for workflow.
#@ex workflow::check_prerequisites
#@ex workflow_check_prerequisites
#@const JQ (read-only)
#@return 255 if the prerequisites are not met
workflow::check_prerequisites() {
workflow_check_prerequisites() {
log::debug "Check prerequisites for workflow"

local status=0
Expand All @@ -32,12 +32,12 @@ workflow::check_prerequisites() {
}

#@desc Check if the workflow definition file exists.
#@ex workflow::check_workflow_definition_path
#@ex workflow_check_workflow_definition_path
#@arg workflow_definition_path: path to the workflow definition file
#@stderr Writes the fatal message to stdout if the workflow definition file does not exist and exit 255
#@stdout Writes the info message to stdout if the workflow definition file exists
#@return workflow_definition_path: path to the workflow definition file
workflow::check_workflow_definition_path() {
workflow_check_workflow_definition_path() {
local path="${1:-}"

log::debug "Check workflow definition path"
Expand All @@ -57,12 +57,12 @@ workflow::check_workflow_definition_path() {
}

#@desc Get containers' names from a JSON workflow definition.
#@ex workflow::workflow::get_workflows_containers_names \"config/workflow-default.json\"
#@ex workflow::workflow_get_workflows_containers_names \"config/workflow-default.json\"
#@const JQ (read-only)
#@const workflow_definition_path (read-only)
#@stdout Writes debug messages to stdout
#@return All found containers' names of the workflow as array
workflow::get_workflows_containers_names() {
workflow_get_workflows_containers_names() {
local workflow_definition_path="${1:-}"

local containers_names=()
Expand All @@ -81,14 +81,14 @@ workflow::get_workflows_containers_names() {
}

#@desc Load step definition from an item and the workflow definition file.
#@ex workflow::load_step_definition \"step1\" \"config/workflow-default.json\"
#@ex workflow_load_step_definition \"step1\" \"config/workflow-default.json\"
#@const JQ (read-only)
#@const workflow_definition_path (read-only)
#@arg item_id: id of the item to load
#@arg workflow_definition_path: path to the workflow definition file
#@stdout Writes debug messages to stdout
#@return Step definition as array
workflow::load_workflow_definition() {
workflow_load_workflow_definition() {
local item_id="${1:-}"
local workflow_definition_path="${2:-}"

Expand All @@ -103,12 +103,12 @@ workflow::load_workflow_definition() {
}

#@desc Load step values as environment variables from a step definition as JSON.
#@ex workflow::load_step_values \"[\"id\":\"step1\",\"name\":\"Step 1\",\"description\":\"Step 1 description\",\"type\":\"command\",\"command\":\"echo 'Step 1'\"]\"
#@ex workflow_load_step_values \"[\"id\":\"step1\",\"name\":\"Step 1\",\"description\":\"Step 1 description\",\"type\":\"command\",\"command\":\"echo 'Step 1'\"]\"
#@const JQ (read-only)
#@arg step_definition: step definition to load
#@stdout Writes debug messages to stdout
#@return The step values
workflow::load_step_values() {
workflow_load_step_values() {
local step_definition="${1}"
local initializer
# shellcheck disable=SC2128 disable=SC2086
Expand All @@ -120,11 +120,11 @@ workflow::load_step_values() {
}

#@desc Iterate over workflow.
#@ex workflow::iterate_over_workflow \"config/workflow-default.json\" \"action1 action2 action3\"
#@ex workflow_iterate_over_workflow \"config/workflow-default.json\" \"action1 action2 action3\"
#@const workflow_definition_path (read-only)
#@arg workflow_definition_path: path to the workflow definition file
#@arg workflows_id: array of workflows id
workflow::iterate_over_workflow() {
workflow_iterate_over_workflow() {
local workflow_definition_path="${1}"
shift
local workflows_id=("$@")
Expand All @@ -134,36 +134,36 @@ workflow::iterate_over_workflow() {

local step_definition
# shellcheck disable=SC2207
step_definition=($(workflow::load_workflow_definition "$item" "$workflow_definition_path"))
step_definition=($(workflow_load_workflow_definition "$item" "$workflow_definition_path"))

# shellcheck disable=SC2128 disable=SC2145
log::debug "Step definition is ${step_definition[@]}"

workflow::load_step_values "${step_definition[@]}"
workflow_load_step_values "${step_definition[@]}"
done
}

#@desc Load workflow definition from a file.
#@ex workflow::load \"config/workflow-default.json\"
#@ex workflow_load \"config/workflow-default.json\"
#@const JQ (read-only)
#@arg workflow_definition_path: path to the workflow definition file
#@stdout Writes the workflow definition details to stdout
workflow::load() {
local workflow_definition_path="${1:-}"

workflow_definition_path=$(workflow::check_workflow_definition_path "$workflow_definition_path")
workflow::check_prerequisites

local workflows_id=()
# shellcheck disable=SC2207
workflows_id+=($(workflow::get_workflows_id "$workflow_definition_path"))

# shellcheck disable=SC2145
log::debug "Caller Workflows id are: ${workflows_id[@]}"
log::debug "Length Workflows id are: ${#workflows_id[@]}"

workflow::iterate_over_workflow "$workflow_definition_path" "${workflows_id[@]}"
}
#workflow_load() {
# local workflow_definition_path="${1:-}"
#
# workflow_definition_path=$(workflow_check_workflow_definition_path "$workflow_definition_path")
# workflow_check_prerequisites
#
# local workflows_id=()
# # shellcheck disable=SC2207
# workflows_id+=($(workflow::get_workflows_id "$workflow_definition_path"))
#
# # shellcheck disable=SC2145
# log::debug "Caller Workflows id are: ${workflows_id[@]}"
# log::debug "Length Workflows id are: ${#workflows_id[@]}"
#
# workflow_iterate_over_workflow "$workflow_definition_path" "${workflows_id[@]}"
#}

# Call the load function with the specified workflow definition path
# workflow::load "config/workflow-default.json"
# workflow_load "config/workflow-default.json"
2 changes: 1 addition & 1 deletion vars/wildPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def call() {
script: '''
#!/usr/bin/env bash
source ${wild_path}/src/lib/workflow.sh
workflow::get_workflows_containers_names ${wild_path}/test/config/workflow-default.json
workflow_get_workflows_containers_names ${wild_path}/test/config/workflow-default.json
''',
returnStdout: true)
}
Expand Down

0 comments on commit 7a2ec3c

Please sign in to comment.