Skip to content

Conversation

@sedyh
Copy link
Contributor

@sedyh sedyh commented Apr 2, 2025

Hello. When I encountered that Task doesn't have fingerprinting for generated files, I started looking for workarounds by using status: test -f for each item in the generated list and suddenly realized that I can't just automate these type of checks because I can't loop over generated. The idea is to extend pr-1541: looping over dependencies with one more value.

This PR is for:

  • Adding generates value with for in cmds and deps.

There will be a second PR for:

  • Allowing regular cmds to run inside status for programmatic checks automation.

My workaround for checking generated files, that I want to run with this PR:

version: '3'

tasks:
  gen:
    sources:
      - protocol/**/*.proto
    generates:
      - pkg/protocol/**/*.pb.go
    status:
      - for: generates
        cmd: test -f {{.ITEM}}
    cmds:
      - buf generate

Original problem with the missing checks for generated files:

ls pkg/protocol
core  google

task gen       
task: Task "gen" is up to date

task clean     
task: [clean] rm -rf pkg/protocol/core

ls pkg/protocol
google

task gen       
task: Task "gen" is up to date # <<< must run again
version: '3'

tasks:
  gen:
    sources:
      - protocol/**/*
    generates:
      - pkg/protocol/**/*
    cmds:
      - mkdir -p pkg/protocol/google
      - touch pkg/protocol/google/important.pb.go
      - mkdir -p pkg/protocol/core
      - touch pkg/protocol/core/important.pb.go
  clean:
    cmds:
      - rm -rf pkg/protocol/core
  make:
    cmds:
      - mkdir -p protocol/google
      - touch protocol/google/important.proto
      - mkdir -p protocol/core
      - touch protocol/core/important.proto

@andreynering andreynering self-requested a review April 2, 2025 12:20
Copy link
Member

@pd93 pd93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far. If willing, could you please add this change to the schema reference and usage doc. We can probably combine the sections on looping over sources/generates rather than having separate ones.

@sedyh sedyh force-pushed the sedyh/for-generates branch 4 times, most recently from a0acc1e to 2776bbf Compare April 3, 2025 09:22
@sedyh sedyh requested a review from pd93 April 5, 2025 11:23
@vmaerten vmaerten self-requested a review April 5, 2025 19:32
Copy link
Member

@vmaerten vmaerten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good ! Can you update the schema.json in order to add this new property ?
It's under for_attribute

@sedyh sedyh force-pushed the sedyh/for-generates branch from 2776bbf to 3929428 Compare April 5, 2025 19:48
@sedyh
Copy link
Contributor Author

sedyh commented Apr 5, 2025

Sounds good ! Can you update the schema.json in order to add this new property ? It's under for_attribute

Yeah, sure. I've updated the enum values.

@sedyh sedyh requested a review from vmaerten April 5, 2025 19:49
Copy link
Member

@vmaerten vmaerten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@pd93 pd93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sedyh 🚀

@pd93 pd93 merged commit 6f0f38b into go-task:main Apr 5, 2025
14 checks passed
pd93 added a commit that referenced this pull request Apr 5, 2025
@pd93
Copy link
Member

pd93 commented Apr 5, 2025

FYI, made some changes to the docs in 669bf33.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants