defenseunicorns / maru-runner

The Unicorn Task Runner
Apache License 2.0
8 stars 0 forks source link

UDS Runner: Unable to use `$INPUT_` in `tasks[].actions[].dir` #87

Open zack-is-cool opened 5 months ago

zack-is-cool commented 5 months ago

Environment

App version: v0.9.2

Steps to reproduce

Given this demo:


#!/usr/bin/env bash

# make temp dir
DEMO_DIR=$(mktemp -d)
pushd $DEMO_DIR

# create some dir
mkdir -p tasks
mkdir -p foo
echo "hello" > foo/hello.txt

# Generate the taskfiles with some heredocs
cat <<'EOF' > tasks.yaml
includes:
  - test: ./tasks/test-inputs.yaml

tasks:
  - name: test-inputs
    actions: 
      - task: test:input-checker
        with:
          file_name: "hello.txt"
          file_path: ./foo
EOF

cat <<'EOF' > tasks/test-inputs.yaml
tasks:
  - name: input-checker
    inputs:
      file_name:
        description: "Name of the file"
        required: true
      file_path:
        description: "Path of the file"
        required: true
    actions:
      - description: "use dir to enter dir using go template and cat file"
        dir: ${{ .inputs.file_path }}
        cmd: |
          set -x
          # get basename of cwd
          echo "cwd: $(basename $(pwd))"
          cat ${{ .inputs.file_name }}
      - description: "get an error using $INPUT_ vars outside of cmd"
        dir: ${INPUT_FILE_PATH}
        cmd: |
          set -x
          # get basename of cwd
          echo "cwd: $(basename $(pwd))"
          cat ${INPUT_FILE_NAME}
EOF

# Run the task
uds run test-inputs

while (( $? == 0 )); do popd  > /dev/null 2>&1; done
rm -rf "$DEMO_DIR"
unset DEMO_DIR

Expected result

Be able to template out entire tasks with $INPUT_ vars

Actual Result

You get this error trying to use an $INPUT_ var in dir: for example

/var/folders/bf/tkdyvkq57lq56fck6q_rnlv80000gn/T/tmp.OygwW0UA73 /var/folders/bf/tkdyvkq57lq56fck6q_rnlv80000gn/T/tmp.UUuKPb0asw ~/uds-run-scratch

 NOTE  Saving log file to
       /var/folders/bf/tkdyvkq57lq56fck6q_rnlv80000gn/T/uds-2024-02-27-15-24-11-475390842.log
     +++ pwd                                                                                                                                                                                                                                                                                 
     ++ basename /private/var/folders/bf/tkdyvkq57lq56fck6q_rnlv80000gn/T/tmp.OygwW0UA73/foo                                                                                                                                                                                                 
     + echo 'cwd: foo'                                                                                                                                                                                                                                                                       
     + cat hello.txt                                                                                                                                                                                                                                                                         
     cwd: foo                                                                                                                                                                                                                                                                                
     hello                                                                                                                                                                                                                                                                                   
  ✔  Completed "use dir to enter dir using go template and cat file"                                                                                                                                                                                                                         
     ERROR:  Failed to run action: command "get an error using $INPUT_ vars outside of cmd" timed out after 0                                                                                                                                                                                
             seconds