ribtoks / tdg-github-action

GitHub action for project management using TODO comments
MIT License
58 stars 5 forks source link

[Feature] Allow assigning Author on PR Branch #32

Closed rowi1de closed 9 months ago

rowi1de commented 1 year ago

It would be really helpful if it's possible to assign the PR Author if a push created a new issue

ribtoks commented 1 year ago

Good idea. I think this is the place that needs to be modified:

https://github.com/ribtoks/tdg-github-action/blob/a832e2bff8445b2bbc7482e31ea043237d5f159e/main.go#L299-L305

See if you want to work on it

ribtoks commented 1 year ago

I think we already allow to specify author in the tdg comment like

// TODO: fix this
// author=ribtoks

Which would tag the author in GitHub, thus creating a notification.

sidsprasad commented 10 months ago

@ribtoks that is a useful feature if the committer wants to assign someone explicitly. But if they don't do that, it would be nice to have an option in the yaml to assign to the author of the commit with the TODO.

ribtoks commented 10 months ago

@sidsprasad does the author=xyz field in the comment solve your issue? This is already supported in the comment body and you can write there anybody. If it does not solve the issue, could you explain how is it different from what you need?

sidsprasad commented 10 months ago

Yes, but if a repo already has a lot of TODOs, it's not ideal to change all the todos in the code to include author=xyz. Also, if someone doesn't include an author there, it would be great to have an option to assign it automatically to the user who created the TODO.

sidsprasad commented 10 months ago

@ribtoks Okay, I went through the code just now and I see that the logic is just doing a grep for the terms like TODO and create issues based on it, so might be a bit involved to add this change. Could I see the code in tdglib? I can't find it on gitlab. Maybe I could contribute to adding this feature. Specifically, I want to see the function tdglib.NewToDoGenerator and the structure tdglib.ToDoComment

ribtoks commented 10 months ago

@sidsprasad Just to be clear, so you would like to have a default "author" configuration in the action itself, that is different from the repository owner (current setting), if the author label was not set in the comment itself? Or you want the "author" to be set from the committer (git)? Because otherwise there's no way to guess who will be the PR reviewer. You might just as well edit assigners manually on GitHub after issues were created.

tdglib is on GitLab in the same project.

sidsprasad commented 10 months ago

@ribtoks I want the "Author" to be set as the commiter (The person who added the TODO), only if the TODO comment does not have author=xyz.

And thanks, will have a look at the code there! 😄

ribtoks commented 10 months ago

Ok, then please create an issue on GitLab and we can continue the conversation there. After it's implemented in tdg, the "fix" to this issue will be just updating Go module. I can advice where/how to implement, if you want to contribute it.

sidsprasad commented 10 months ago

@ribtoks Will do! Talk to you on gitlab

sidsprasad commented 9 months ago

@ribtoks HNY! 🥳 Thanks for your help in creating and closing the issue on Gitlab. I want to now work on actually having the issue assigned to the author on github over here. Could you plese give me some tips on how to run and debug the github action locally?

Also, we'd need to add the new flag in the code here and also update the Go module. Could you please advise on that as well?

ribtoks commented 9 months ago

@sidsprasad thank you for your contribution to tdg, btw!

To test, you can create a new temporary repository and use your fork/version of the action (e.g. sidsprasad/tdg-github-action@latest)

In general to see if tdg worked correctly, there's the DRY_RUN flag, but it does not call GitHub API in the end.

To update go module, you can do go get -u gitlab.com/ribtoks/tdg and then make vendors.

As for the new flag, check how any existing flag is used, like COMMENT_ON_ISSUES - it's defined in action.yml and used in main.go

sidsprasad commented 9 months ago

@ribtoks the following error occurs when I run the action on github now with the flag:

Error: exec: "git": executable file not found in $PATH

I guess the git command isn't installed by default on the github action runner 😅

sidsprasad commented 9 months ago

Okay, I added a new action in the action yml in my repo like this:

- name: Install Git
  run: sudo apt-get update && sudo apt-get install -y git

According to the output of that step, git is already installed. Investigating further.

sidsprasad commented 9 months ago

@ribtoks
Git commands seem to work fine if I add them in separate steps in the github action yml. But it doesn't work when run in Go for some reason. Trying to figure out why. Would you have any ideas on this?

ribtoks commented 9 months ago

@sidsprasad Sadly I don't know the reason. I guess it has something to do with $PATH environmental variable. When you launch git in Go app, it assumes to be present in $PATH. I'm not aware what happens when you do apt-get install git as to where it's installed. I guess you can do which git to debug etc.

sidsprasad commented 9 months ago

@ribtoks I wasn't looking at how the action was being run lol. Once I started doing that, I saw that it's being run on a docker image, and so the github env makes no difference. Gotta install git on the container. But since the final container is distroless, there is no shell. What do you think about changing from distroless to alpine? It would make the image slightly larger, but still wouldn't contain all the stuff from before the build.

ribtoks commented 9 months ago

I think it's OK to change to alpine.

sidsprasad commented 9 months ago

@ribtoks yeah, that did the trick, but now the next problem is that every git command gives an error Error: exit status 128. I think it has something to do with permissions. Trying to figure it out.

ribtoks commented 9 months ago

This is implemented in #60