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

Cannot include multiple time the same Taskfile with differents namespaces #1606

Closed
vmaerten opened this issue Apr 20, 2024 · 7 comments · Fixed by #1607
Closed

Cannot include multiple time the same Taskfile with differents namespaces #1606

vmaerten opened this issue Apr 20, 2024 · 7 comments · Fixed by #1607
Labels
area: reader Changes related to the Taskfile reader.

Comments

@vmaerten
Copy link
Member

Hi,

Following this comment, I've opened an issue to track this.

I am using this pattern a lot, in almost in every project (around 20). The idea is to have on Taskfile per language and standardise all Tasks for all projects.

Here the repo to reproduce : https://github.com/vmaerten/taskfile-demo
You can run go run ./cmd/task --dir ./taskfile-demo deploy/dev -f

I have this error :

❯ go run ./cmd/task --dir ../../perso/taskfile-demo deploy/dev                                                                                                                                                                                                                                                      20:36:48
panic: interface conversion: interface {} is ast.Include, not *ast.Include

goroutine 7 [running]:
github.com/go-task/task/v3/taskfile.(*Reader).include.func1.1()
	/home/valentin/dev/fork/task/taskfile/reader.go:152 +0x8a8
golang.org/x/sync/errgroup.(*Group).Go.func1()
	/home/valentin/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
	/home/valentin/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x96
exit status 2


I've given a talk at devoxxfr last thurday presenting Task (using this repo), and when discussing with attendees, multiple people have the same use case.
I think @davinkevin has the same use case.

The next release will most likely break some setup. Is it possible to get DAG working with this setup ?

@pd93
Copy link
Member

pd93 commented Apr 21, 2024

@vmaerten @davinkevin It is definitely possible! Please could you give the changes in #1607 a go. Thanks

@vmaerten
Copy link
Member Author

Hi !
Thanks a lot for working on it !
I've tried and I got some weird behavior, it seems to work most of the time but (seems) to have a race condition and sometimes it does not work.

I've been running task deploy/dev 15 times and here the result :

Task's output
task on  fix-multiple-includes [?] via 🐹 v1.21.9 via  v21.5.0 on ☁️   pubstackdev took 8s                                                                                                                                                                                                                                  
  for counter in {1..15}; do echo "run $counter"; go run ./cmd/task --dir ../perso/taskfile-demo deploy/dev -f; done                                                                                                                                                                                                18:21:37 run 1                                                                                                                                                                                                                                                                                                                        
task: [cli:build] go build                                                                                                                                                                                                                                                                                                   
task: [backend:build] go build                                                                                                                                                                                                                                                                                               task: [deploy] echo "Deploying .. dev "                                                                                                                                                                                                                                                                                      
Deploying .. dev                                                                                                                                                                                                                                                                                                             
run 2
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 3
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 4
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 5
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 6
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 7
task: [backend:build] go build
task: [cli:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 8
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 9
task: [backend:build] go build
task: [cli:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 10
edge already exists
exit status 1
run 11
task: [cli:build] go build
task: Failed to run task "deploy/dev": task: Task "backend:build" does not exist
exit status 201
run 12
task: [backend:build] go build
task: [cli:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 13
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 14
task: [cli:build] go build
task: [backend:build] go build
task: [deploy] echo "Deploying .. dev "
Deploying .. dev 
run 15
task: [backend:build] go build
task: Failed to run task "deploy/dev": task: Task "cli:build" does not exist

I have 3 kind of errors :

  • edge already exists
  • Failed to run task "deploy/dev": task: Task "backend:build" does not exist
  • Failed to run task "deploy/dev": task: Task "cli:build" does not exist

The taskfile is the following : https://github.com/vmaerten/taskfile-demo/blob/main/Taskfile.yml

Let me know if you need more precision or if I can help :)

@pd93 pd93 added type: bug Something not working as intended. area: reader Changes related to the Taskfile reader. and removed state: needs triage Waiting to be triaged by a maintainer. labels Apr 21, 2024
@pd93
Copy link
Member

pd93 commented Apr 21, 2024

Can you confirm that you're running on b0e58c6? I've checked out your project and am unable to reproduce.

@vmaerten
Copy link
Member Author

Yes :
image

But I can also provide a Github action that fail with this error, however it seems harder to trigger it in GH action (https://github.com/vmaerten/taskfile-demo/actions/runs/8774178400/job/24075110053 or https://github.com/vmaerten/taskfile-demo/actions/runs/8774252202/job/24075264726)

@pd93
Copy link
Member

pd93 commented Apr 21, 2024

@vmaerten Thanks, as you said, it looks like a simple race condition between the go routines. I've added a mutex and pushed a commit. Please let me know if this works for you.

@vmaerten
Copy link
Member Author

I think it's working now! I've run over 500 tasks and noone failed 🔥
Thanks for fixing this 💯

Small thing aside, not sure this is related, and this is non blocking at all, sometimes (only on shared included Taskfile), the output is not in green :
image
image
As I said, it does not bother me, I just wanted to show you this

@pd93
Copy link
Member

pd93 commented Apr 21, 2024

Thanks for fixing this

No problem! Thanks for being proactive and spotting this before it got released.

As for the output, I have noticed this before, but never found the root cause. It can happen in other situations too. I have some plans to look into our formatter at some point. I'll definitely keep this in mind when I get to it.

@pd93 pd93 removed the type: bug Something not working as intended. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: reader Changes related to the Taskfile reader.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants