-
Notifications
You must be signed in to change notification settings - Fork 607
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
dev-ux: create an issue for each TODO introduced in a merged PR #6636
Conversation
id: todos | ||
run: | | ||
git fetch origin main | ||
todos=$(git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.merge_commit_sha }} --unified=0 | awk '/^\+.*TODO:/ { sub(/^.*TODO:\s*/, ""); sub(/^ */, ""); $0=toupper(substr($0,1,1)) substr($0,2); print $0 }') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this line greps "TODO:"-patterned lines from a diff introduced by a merged pull request. It does that by only checking lines starting with +
sign, since git diff
marks added files with a plus in the output. Also, it removes all whitespaces after :
and capitalizes a first non-whitespace character
SAVEIFS=$IFS # Save current IFS (Internal Field Separator) | ||
IFS=$'\n' # Change IFS to newline char | ||
todos=("${{ steps.todos.outputs.todo_list }}") # split the `todo_list` string into an array by the same name | ||
IFS=$SAVEIFS # Restore original IFS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this is just a way of converting todo_list
from string with newlines to an array so we could iterate over todos
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues \ | ||
-d '{"title":"'"$todo"'","body":"Auto-generated issue triggered by the merge of ${{ github.event.pull_request.html_url }} with an introduced TODO","assignees":["${{ github.event.pull_request.user.login }}"],"labels":["T:auto"]}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: unfortunately it is not possible to use an existing github action for issue creation, since a PR can potentially introduce multiple TODOs. That is because we need to iterate over all of them, but as of my knowledge, if we used an existing action for opening an issue, we would have to iterate over a workflow's step, which is not currently possible
I don't really want this, but if other people want it happy to try |
Is there a sample issue that was created by this workflow? |
I would find it useful. If folks disagree, can we make this actionable on a label - "A:TODO"? CC: @pysel |
sure, you can check |
yes, I was also thinking about that |
I think a variation of this would actually be nice: Require that any TODO that is merged has an in line comment below it with the github issue linked. I think its better than just making a cookie cutter issue for it |
I am with @czarcas7ic 's idea on this: although it would add one more step for us that would be more uncomfortable, I do think its needed + good practice |
@czarcas7ic should we then close this PR and go with a different workflow, or should we merge them together and automatically append a link of a newly created issue after TODO line? |
@pysel I think the latter might be too much automation if I understand you correctly. I think the best flow would be as follows:
Apologize for making this work go to waste, I just think the above flow will work a lot better for everyone |
Closes: #6399
What is the purpose of the change
Add a workflow that runs when a PR is merged to main, checking if the PR has some TODOs left by searching for
TODO: <something>
pattern. If found, creates an issue assigned to the author of an initial PR with a title<something>
.Also, for convenience, attaches a
T:auto
label to this issueNote: if this PR gets merged, I suggest people start avoiding leaving TODOs like "fix this", "refactor this", etc, because it would make little sense in the issue title
Testing and Verifying
Fork
Documentation and Release Note
NA