Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Task dependency logic #166

Open
JaseKoonce opened this issue Nov 1, 2024 · 0 comments
Open

Improve Task dependency logic #166

JaseKoonce opened this issue Nov 1, 2024 · 0 comments
Labels
enhancement ✨ New feature or request

Comments

@JaseKoonce
Copy link

As of right now I find it very difficult to architect tasks in a way that they work well if they are invoked from either the main task file or independently (uds run deploy-all vs uds run deploy:deploy-uds-core).

Sorry for the long example, struggling to explain in a simpler or less verbose manner.
example:

Tasks.yaml

includes:
  - setup: ./tasks/setup.yaml
  - deploy: ./tasks/deploy.yaml

tasks:
  - name: deploy-all
    description: "Use the pre-published Bundle and deploy all uds-core prerequisites and the uds-bundle"
    actions:
      - task: setup:complete-setup
      - task: deploy:complete-deploy

deploy.yaml

tasks:

  - name: complete-deploy
    description: "Chain together all the tasks needed for a regular uds core deployment"
    actions:
      - task: deploy-base-bundle
      - task: deploy-core-bundle
 
  - name: deploy-base-bundle
    description: "Deploy the UDS Core Standard Bundle"
    actions:
      - cmd: echo "deploying uds bundle for ${ENV}"
      - cmd: sleep 7 # give time to cancel if its the wrong environment
      - cmd: "uds deploy ${BASE_BUNDLE_OCI_URL} --confirm --no-progress"
        dir: "bundles/${ENV}"

  - name: deploy-core-bundle
    description: "Deploy the UDS Core Standard Bundle"
    actions:
      - cmd: echo "deploying uds bundle for ${ENV}"
      - cmd: sleep 7 # give time to cancel if its the wrong environment
      - cmd: "uds deploy ${CORE_BUNDLE_OCI_URL} --confirm --no-progress && echo succeeded || echo failed"
        dir: "bundles/${ENV}"
        setVariables:
          - name: STATUS

Explanation of issue:

Based on the files I provided you can run uds run deploy-all and everything will work fine. A pre-req for either of the deployment tasks are the setup tasks. What I am struggling with is how I can extend this pattern in a way that my tasks work well when invoked from either a global task or the individual task (uds run deploy-all vs uds run deploy:deploy-uds-core) . To dive further into the issues my options to fix the issue is to add the "setup" tasks as actions for all of the deploy tasks:

 - name: deploy-core-bundle
    description: "Deploy the UDS Core Standard Bundle"
    actions:
      - task: *all the setup pre-reqs
      - cmd: echo "deploying uds bundle for ${ENV}"
      - cmd: sleep 7 # give time to cancel if its the wrong environment
      - cmd: "uds deploy ${CORE_BUNDLE_OCI_URL} --confirm --no-progress && echo succeeded || echo failed"
        dir: "bundles/${ENV}"
        setVariables:
          - name: STATUS

Once you do this all the tasks will work both from the global or individual task, but now I repeat unnecessary tasks when i invoke the global tasks. Another option is to remove the setup task from the global task and instead only include them in the deploy task. This is probably the best way to do it currently, but could really muddy up our task files.

Tasks.yaml

includes:
   // ~REMOVED~//
  - deploy: ./tasks/deploy.yaml

tasks:
  - name: deploy-all
    description: "Use the pre-published Bundle and deploy all uds-core prerequisites and the uds-bundle"
    actions:
      // ~REMOVED~//
      - task: deploy:complete-deploy

deploy.yaml # We now have to include the setup tasks in this file

 - name: deploy-core-bundle
    description: "Deploy the UDS Core Standard Bundle"
    actions:
      - task: *all the setup pre-reqs
      - cmd: echo "deploying uds bundle for ${ENV}"
      - cmd: sleep 7 # give time to cancel if its the wrong environment
      - cmd: "uds deploy ${CORE_BUNDLE_OCI_URL} --confirm --no-progress && echo succeeded || echo failed"
        dir: "bundles/${ENV}"
        setVariables:
          - name: STATUS

Describe the solution you'd like

Possibly adding a way to define task dependencies and detect whether or not they have ran previously.

@JaseKoonce JaseKoonce added the enhancement ✨ New feature or request label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant