Skip to content

Call tasks within other tasks with dynamic variables #16

@AustinAbro321

Description

@AustinAbro321

Is your feature request related to a problem? Please describe

I am building out a task that calls other tasks with an input. The input is dynamic, generated from a for loop, and I want to call the child task with it. I can do this with uds run but this is not ideal in a few ways.

  - name: build-pkg
    description: Run unit tests for one package
    actions:
      - cmd: cd "${PKG}" &&  go build -o ../build/${PKG} .

  - name: build-all
    description: Run unit tests in all packages
    actions:
      - task: set-modules-variable
      - cmd: |
          for dir in ${MODULES}; do
            uds run build-pkg --set PKG=$dir
          done
  • I get error output for both tasks at the same time. I'm not sure the best way to give the output, but it does feel messy and hard to parse when I have both outputs going to me, if we controlled this flow I think we could make it look cleaner.
 NOTE  Saving log file to /tmp/runner-2024-03-08-09-00-10-2665304748.log
     helpers                                                                                                                                             
  ✔  Completed "echo $(find . -type f -name 'go.mod' -exec dirname {} \; ..."                                                                            
                                                                                                                                                         
      NOTE  Saving log file to /tmp/runner-2024-03-08-09-00-10-62828390.log                                                                              
                                                                                                                                                         
 Waiting for "cd "${PKG}" &&  go build -o ../build/${PKG} . && exit 1" (no timeout)                                                                      
  ⠋  Waiting for "cd "${PKG}" &&  go build -o ../build/${PKG} . && exit 1" (no timeout) (0s)                                                             
     ERROR:  Failed to run action: command "cd "${PKG}" && go build -o ../build/${PKG} . && exit 1" timed out                                            
                  after 0 seconds                                                                                                                        
     ERROR:  Failed to run action: command "for dir in ${MODULES}; do; uds run build-pkg --set PKG=..." timed out                                        
             after 0 seconds
  • I lose any variables that I set in previous actions
  • uds run starts in the current directory of the task, which can be a different starting point than the user expects

Describe the solution you'd like

  • Given I have a task called base-task
  • When I am in another task and run task:base-task
  • Then base-task is run as if I had run it using the task: base-task syntax.

^ This is just one idea and might not work, but I think it would be nice to have a solution that can accomplish something similar

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions