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

Issues not being closed when the comment is not in the main commit on push #178

Open
LouDnl opened this issue Feb 8, 2024 · 4 comments
Open

Comments

@LouDnl
Copy link

LouDnl commented Feb 8, 2024

I have been using this action for a while now and am very pleased with how it works, but am running into some minor things I can't seem to solve.

  1. When removal of a comment in the code with one of the identifiers (TODO as example) is pushed to github the issue is automatically closed. But when this commit is part of a larger set of commits issues do not always get closed. It is as if the action only runs on the latest commit of a push? It seems that it is not always this case though, I can't put my finger on it.
  2. If you have multiple branches and a pull request is created from one to the other, issues are duplicated.

Action config:

  name: "Create issues from TODO and BUG entries"
  on:
    push:
      branches: [ develop ] # develop branch only due to duplicate issues after pull requests on master
  
    workflow_dispatch:
      inputs:
        MANUAL_COMMIT_REF:
          description: "The SHA of the commit to get the diff for"
          required: true
        MANUAL_BASE_REF:
          description: "By default, the commit entered above is compared to the one directly before it; to go back further, enter an earlier SHA here"
          required: false
  jobs:
    managetodos:
      name: Add TODO's and BUGs from code
      runs-on: "ubuntu-latest"
      steps:
        - uses: "actions/checkout@v3"
        - name: "TODO's to Issues"
          uses: "alstr/todo-to-issue-action@master"
          with:
            AUTO_ASSIGN: true
            IDENTIFIERS: '[{"name": "TODO", "labels": ["TODO", "new", "auto generated"]},
                           {"name": "BUG", "labels": ["BUG", "new", "auto generated"]},
                           {"name": "ISSUE", "labels": ["ISSUE", "new", "auto generated"]},
                           {"name": "FIXME", "labels": ["FIXME", "new", "auto generated"]}]'
          env:
            MANUAL_COMMIT_REF: ${{ inputs.MANUAL_COMMIT_REF }}
            MANUAL_BASE_REF: ${{ inputs.MANUAL_BASE_REF }}
@alstr
Copy link
Owner

alstr commented Feb 10, 2024

Thanks for the feedback. Those are two areas that I would like to improve going forward as they are admittedly not perfect.

Issues not being closed

This is still somewhat experimental. If the issue to be closed appears in the diff file, it should be closed.

This is the line that should be retrieving the diff file:

# There are several commits: compare with the oldest one

If you can check the diff url and see if the issue closed is marked as a deletion, that would be a helpful starting point.

Duplication of issues

The action does initially retrieve issues that it has previously created to try and avoid creating them again:

for existing_issue in self.existing_issues:

Whether this works is predicated on (1) the issue already existing from a prior action run, and (2) the issue having the todo label:

def _get_existing_issues(self, page=1):

The issue title would also need to be the same.

If one of those conditions isn't satisfied then it won't appear in the existing issues list, and it could be created again under certain circumstances. I would need to try and get to the bottom of what is happening there, but this isn't a failproof system at best and could do with improvement.

By the way, I'd use the v4 version of the action rather than master, just for stability reasons.

@LouDnl
Copy link
Author

LouDnl commented Feb 10, 2024

Thanks for your reply @alstr I will have a deeper look and switched to v4.12.2.
I noticed that whenever issues arent closed it logs Issue could not be closed from here

print('Issue could not be closed')

@LouDnl
Copy link
Author

LouDnl commented Feb 10, 2024

@alstr I have checked one of my recent commit diff urls (got the sha's from the actions log). There is one issue found (the issue # is not logged) but the diff shows below. There indeed was an issue but it was not automatically closed, I have to close it by hand.

partial log:
image

diff:
image

@alstr
Copy link
Owner

alstr commented Feb 17, 2024

That means that it's trying to close the issue but the GitHub API call is failing for some reason.

I've just run a test and issue closing worked for me, so it's not a problem with the API itself.

It could be permissions related but if you can create issues then that doesn't seem likely.

Could you try the comment on a line of its own (creating and closing a new issue) and see if there's any change? Comments on the end of a line might not work reliably yet. The data might be malformed.

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

No branches or pull requests

2 participants