You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/23 20:11:23 UTC

[GitHub] [beam] Abacn opened a new pull request, #22032: Enable close issue as not planned

Abacn opened a new pull request, #22032:
URL: https://github.com/apache/beam/pull/22032

   Fixes #22031
   
   * Make use of state_reason attribute
   
   * Run on only issue comment and exclude pull request comment
   
   * Added documentation
   
   **Please** add a meaningful description for your change here
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164823097

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
damccorm commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164844813

   > Should we allow close issue for those only assigned to them? (Currently anyone can use close-issue phrase, and this does not change with this pr)
   
   I think yes for 2 reasons:
   1) Kenn and I created a ton of issues on behalf of other people as part of the migration. Their owners need to be able to close
   2) Anyone can self-assign anyways


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1165051923

   Changes applied.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164823107

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm merged pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
damccorm merged PR #22032:
URL: https://github.com/apache/beam/pull/22032


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164823094

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on a diff in pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
Abacn commented on code in PR #22032:
URL: https://github.com/apache/beam/pull/22032#discussion_r906085000


##########
.github/workflows/self-assign.yml:
##########
@@ -34,10 +35,15 @@ jobs:
           curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
           curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
         fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          echo "Closing issue $ISSUE_NUMBER"
+        ISSUE_ASSIGNEE="$(jq '.issue.assignee.login' $GITHUB_EVENT_PATH | tr -d \")"
+        if [[ $ISSUE_ASSIGNEE == $LOGIN && $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then

Review Comment:
   Agree. adjusted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164825904

   Example: https://github.com/Abacn/beam/issues/39


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164823106

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] asf-ci commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
asf-ci commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164823101

   Can one of the admins verify this patch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #22032:
URL: https://github.com/apache/beam/pull/22032#discussion_r905967736


##########
.github/workflows/self-assign.yml:
##########
@@ -34,10 +35,15 @@ jobs:
           curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
           curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
         fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          echo "Closing issue $ISSUE_NUMBER"
+        ISSUE_ASSIGNEE="$(jq '.issue.assignee.login' $GITHUB_EVENT_PATH | tr -d \")"
+        if [[ $ISSUE_ASSIGNEE == $LOGIN && $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then

Review Comment:
   ```suggestion
           if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
   ```
   
   I'm sorry, I misspoke (mistyped?) earlier, though my reasoning was still correct. I don't think we should restrict issue close to the assignee. Closing an issue as a non-assignee is probably fairly common (e.g. an owner of a migrated ticket needs to close it), and its not doing anything permissions-wise since anyone can self-assign. I can't think of a scenario where restricting like this helps us.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164826379

   R: @damccorm


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #22032:
URL: https://github.com/apache/beam/pull/22032#discussion_r905436484


##########
.github/workflows/self-assign.yml:
##########
@@ -34,10 +35,26 @@ jobs:
           curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
           curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/labels/awaiting%20triage
         fi
-        if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
-          echo "Closing issue $ISSUE_NUMBER"
+        INPUT_CLOSE_BRACKET="$INPUT_CLOSE"'\(([^()]*)\)'
+        INPUT_CLOSE_BRACKET_BACKTICK="\`$INPUT_CLOSE_BRACKET\`"
+        ISSUE_CLOSE_CONFIG=""
+        if [[ ! $BODY =~ $INPUT_CLOSE_BRACKET_BACKTICK ]]; then
+          if [[ $BODY =~ $INPUT_CLOSE_BRACKET ]]; then
+            if [[ ${BASH_REMATCH[1]} == "completed" ]] || [[ ${BASH_REMATCH[1]} == "not_planned" ]]; then
+              # close issue with specified reason. Supported reasons are "completed" or "not_planned".
+              ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"'${BASH_REMATCH[1]}\"
+            else
+              echo "Unknown issue close reason: ${BASH_REMATCH[1]}"
+            fi
+          elif [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"* ]]; then
+            # Close issue without specify a reason. Will be closed as complete by default.
+            ISSUE_CLOSE_CONFIG='"state":"closed"'
+          fi
+        fi
+        if [[ -n $ISSUE_CLOSE_CONFIG ]]; then

Review Comment:
   ```suggestion
           if [[ $BODY == *"$INPUT_CLOSE"* && $BODY != *"\`$INPUT_CLOSE\`"*  ]]; then
              $ISSUE_CLOSE_CONFIG='"state":"closed"'
              if [[ $BODY == *"not_planned"* ]]; then
                 $ISSUE_CLOSE_CONFIG='"state":"closed","state_reason":"not_planned"'
              fi
   ```
   
   I think we can vastly simplify this. This uses 3 things:
   1) anything closed is already closed as completed. So we don't have to check that.
   2) anything closed as not planned will have the not_planned suffix somewhere and its really unlikely to appear elsewhere (and the cost of messing that up is low).
   3) If they enter an invalid input (e.g. `.close-issue(abc)`) closing is better than silently failing (which is currently what you're trying to do.
   
   IMO simplicity is much better than trying to make this 100% perfect. This is already more complex than I'd like as a bash script and probably should be migrated to a javascript action soon



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] Abacn commented on pull request #22032: Enable close issue as not planned

Posted by GitBox <gi...@apache.org>.
Abacn commented on PR #22032:
URL: https://github.com/apache/beam/pull/22032#issuecomment-1164824663

   Should we allow close issue for those only assigned to them?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org