Skip to content

[feature] Improve task inheritance merging for globally scoped tasks #1840

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

Open
sybernatus opened this issue Feb 24, 2025 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@sybernatus
Copy link

Hello 🙂

Is your feature request related to a problem? Please describe.

Kind of...
I'm using moon to manage a lot of projects in a monorepo (100+) and differents technologies:

  • kustomize (kubectl)
  • nodejs
  • ansible
  • bash
  • markdown
  • etc.

Each project has a main technology but not only one.
For example, I have a main kustomize project (let's call it my-project for the example) but also containing some bash scripts & some markdown documents.

My first idea is that I'd like to write tests for each technologies & just setup the moon.yml depending on the technology.
For example with my-project:

  • a global test for all kustomize projects
  • a global test for all projects containing bash
  • a global test for all projects containing markdown

Example of test I'd like to turn in global tasks:

  • kustomize: test that the yaml is built correctly with kubectl kustomize base
  • bash: test that all dependencies are resolved
  • markdown: test that all local links are resolved

Problem is that there is only a shallow merged between global tasks and If I want a moon project to inherit the 3 tests, I have to create a tag- for each combinations.

Describe the solution you'd like

What I would like to do is define my 3 global tasks (from tags or languages), for example:

.moon/tasks/kustomize.yml

tasks:
  test:
    deps:
      - 'test.kustomize'
  test.kustomize:
    command:
      - "<my kustomize test>"

.moon/tasks/tag-bash.yml

tasks:
  test:
    deps:
      - 'test.bash'
  test.bash:
    command:
      - "<my bash test>"

.moon/tasks/tag-markdown.yml

tasks:
  test:
    deps:
      - 'test.markdown'
  test.markdown:
    command:
      - "<my markdown test>"

And as a result of all of this, I'd like to have a merge of the deps of my task test.
Giving this final template:

tasks:
  test:
    deps:
      - 'test.kustomize'
      - 'test.bash'
      - 'test.markdown'
  test.kustomize:
    command:
      - "<my kustomize test>"
  test.bash:
    command:
      - "<my bash test>"
  test.markdown:
    command:
      - "<my markdown test>"

Maybe by managing the merge option in the .moon/workspace.yml like:

globalTasks:
  options:
    merge: append

Describe alternatives you've considered

Today the only solutions I have found are to:

  • create one tag by project pattern based on their technology list
    • In that case, each tag containing a technology will have the same deplicated test
  • override at moon.yml level by
    • creating only the tasks test.<specific-test> in each tag- files
    • add all the tags in each moon.yml projects
    • create the task test on each moon.yml even if I have the same 100 times

Additional context

I have a lot of projects with different pattern and many more coming, I'd like to avoid duplicating this in every of them.

@sybernatus sybernatus added the enhancement New feature or request label Feb 24, 2025
@milesj
Copy link
Collaborator

milesj commented Feb 24, 2025

I do have plans to support deep merging but it is kind of a breaking change, so probably won't land until v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants