defenseunicorns / maru-runner

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

Dynamically set default variables #15

Open AustinAbro321 opened 4 months ago

AustinAbro321 commented 4 months ago

Is your feature request related to a problem? Please describe

Ability to dynamically set variables. For example currently I am building a task file similar to the one below. I always want the MODULES variable available to my tasks, so I'd rather not have to include the set-modules-variables task each time. I either want the variables to be able to be set with a dynamic default or I want a task that will always run before any of my other tasks. Personally I like the latter more, but I can see the argument for either, maybe even both.

  - name: set-modules-variable
    actions:
      - cmd: echo $(find . -type f -name 'go.mod' -exec dirname {} \; | cut -c 3-)
        setVariables:
          - name: MODULES

  - 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

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

  - name: test-all
    description: Run unit tests in all packages
    actions:
      - task: set-modules-variable
      - cmd: |
          for dir in ${MODULES}; do
            uds run test-pkg --set PKG=$dir
          done