Things will get complicated if your main task invoke a module A.taskA, then module A result in another task call to module B.taskB.
Many programming language has the issue of dependency hell. It will break simply becuase of different version of different modules
UP cmd support two approaches to manage the dependencies, the first one s to manage the dependency statically under a local directory, either it is a relative direectory to your work directory, or abosolute path in your system; the second one is to manage multiple versions of same module in its version directories
Simply saying, you will define all required modules and versions in that module’s configuration upconfig.yml file. It’s like a jailed execution for that module to pull all required modules and defined versions
myproject
├── hello-module
│  ├── up.yml
│  └── upconfig.yml
├── hi-module
│  └── up.yml
├── world-module
│  ├── up.yml
│  └── upconfig.yml
├── up.yml
└── upconfig.yml
In this case, the call flow is:
main task -> hello-module.Say_hello -> hi-module.Say_hi
The below module config to call hi-module will be under management of hello-module, in myproject/hello-module/upconfig.yml
Modules:
-
dir: hi-module/
alias: hi-module
Please notice that the world-module is configured in the same way, the hi-module is in its own path but not globally shared and dynamically linked
pros: * the callee module is statically linked * the callee module could be different version, so there is no compatibility issue at all, hence it will utterly avoid problems like below: * the time you upgrade is the time start failing * demanding one version fitting all * demanding you must upgrade all components’ version so that the code could work
con: * none
When your code is maturer enough, you might want to publish your own local module directory under your project code base. You wrap up code into an exported task, check in your module directory as a git repo. You can start sharing module with different teams and after that you can use the second way to refer to the module using your repo url and remove your local directory from your project code base.
version: 1.0.0
Verbose: vvv
MaxCallLayers: 8
RefDir: .
TaskFile: up.yml
ConfigDir: .
ConfigFile: upconfig.yml
Modules:
- #if there is no repo, then it will use the dir as module and incorporate as module
dir: hello-module/
alias: hello-module
tasks:
-
name: Main
desc: main entry
task:
-
func: call
do: hello-module.Say_hello
tasks:
-
name: Main
desc: main entry
task:
-
func: shell
desc: main job
do:
- echo "hello "
-
name: Say_hello
task:
-
func: cmd
vars:
a: aaa
do:
- name: print
cmd: "... hello"
-
func: call
do: hi-module.Say_hi
RefDir: .
TaskFile: up.yml
Modules:
-
dir: hi-module/
alias: hi-module
tasks:
-
name: Main
desc: main entry
task:
-
func: shell
desc: main job
do:
- echo "hello "
-
name: Say_hi
task:
-
func: cmd
vars:
a: aaa
do:
- name: print
cmd: "... hi"
loading [Config]: ./tests/modtests/0010/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/modtests/0010
WorkDir -> refdir
AbsWorkDir -> /up_project/up/tests/modtests/0010
TaskFile -> up.yml
Verbose -> v
ModuleName -> self
ShellType -> /bin/sh
MaxCallLayers -> 8
Timeout -> 3600000
MaxModuelCallLayers -> 256
EntryTask -> Main
ModRepoUsernameRef ->
ModRepoPasswordRef ->
work dir: /up_project/up/tests/modtests/0010
-exec task: Main
loading [Task]: ./up.yml
module: [self], instance id: [dev], exec profile: []
Task1: [Main ==> Main: main entry ]
-Step1:
loading [Config]: ./upconfig.yml
loading [Task]: ./up.yml
module: [hello-module], instance id: [nonamed], exec profile: []
WARN: [*be aware*] - [both instance id and exec profile are not set]
=>call module: [hello-module] task: [Say_hello]
Task2: [TODO: Main Caller Taskname ==> Say_hello: ]
-Step1:
~SubStep1: [print: ]
... hello
-Step2:
WARN: [config file does not exist] - [use builtin defaults]
loading [Task]: ./up.yml
module: [hi-module], instance id: [nonamed], exec profile: []
WARN: [*be aware*] - [both instance id and exec profile are not set]
=>call module: [hi-module] task: [Say_hi]
Task2: [TODO: Main Caller Taskname ==> Say_hi: ]
-Step1:
~SubStep1: [print: ]
... hi