test-infra icon indicating copy to clipboard operation
test-infra copied to clipboard

prow: Add support for closing issues as Not Planned

Open MadhavJivrajani opened this issue 3 years ago • 10 comments

This commit adds support for closing issues as Not Planned by utilising the new state_reason attribute of the GH API. The default value of this attribute, if not set, is completed which is the current behaviour.

Changes to the github client:

  • The IssueClient interface is modified to include a method called CloseIssueAsNotPlanned which sets the state_reason attribute to not_planned
  • The Issue type is also modified to now have the StateReason field.
  • Subsequent changes to the fake client are made to set the StateReason field to completed or not_planned depending on the method invoked.

Changes to lifecycle plugin:

  • The /close command is extended to be used as /close not-planned if an issue is to be closed as Not Planned.

Ref #26380


/assign @nikhita @cblecker /cc @mrbobbytables @jberkus

MadhavJivrajani avatar Jul 26 '22 05:07 MadhavJivrajani

Also, tried this out in a playground gh org, test issue link: https://github.com/uwubernetes/label-sync-test/issues/1

Command:

curl -X PATCH -H "Authorization: token <TOKEN>" \                                                                     
  https://api.github.com/repos/uwubernetes/label-sync-test/issues/1 \
  -d '{"state":"closed","state_reason":"not_planned"}'

For some reason the state_reason attribute hasn't made its way into the API docs yet :/

MadhavJivrajani avatar Jul 26 '22 05:07 MadhavJivrajani

/sig contributor-experience

MadhavJivrajani avatar Jul 26 '22 05:07 MadhavJivrajani

+1 from me on the general idea, but I'm going to leave it to our GH admins to decide on the code.

jberkus avatar Jul 26 '22 17:07 jberkus

Couple of comments, but LGTM otherwise. Thanks for working on this, @MadhavJivrajani!

nikhita avatar Jul 28 '22 09:07 nikhita

Done, thanks for the review @nikhita!

MadhavJivrajani avatar Jul 28 '22 09:07 MadhavJivrajani

@palnabarun: Closed this PR.

In response to this:

This regex will match the following which feels a little odd to allow.

/close




not-planned

If users are not allowed to have new lines between /close and not-planned, the regex needs to be something like

regexp.MustCompile(`(?mi)^/close not-planned\s*$`) // allows only one space
(or)
regexp.MustCompile(`(?mi)^/close[ ]+not-planned\s*$`) // allowed one or more spaces (which feels a little weird too)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jul 29 '22 04:07 k8s-ci-robot

Awesome! This proves the regex needs to be improved :p

/reopen

MadhavJivrajani avatar Jul 29 '22 04:07 MadhavJivrajani

@MadhavJivrajani: Reopened this PR.

In response to this:

Awesome! This proves the regex needs to be improved :p

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jul 29 '22 04:07 k8s-ci-robot

@palnabarun I've addressed your comments, thanks!

MadhavJivrajani avatar Aug 04 '22 05:08 MadhavJivrajani

Hi, can we merge this? I want to use this feature

upodroid avatar Sep 15 '22 17:09 upodroid

/approve

stevekuznetsov avatar Sep 15 '22 19:09 stevekuznetsov

Nice work @MadhavJivrajani - thank you for the contribution!

stevekuznetsov avatar Sep 15 '22 19:09 stevekuznetsov

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MadhavJivrajani, palnabarun, stevekuznetsov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Sep 15 '22 19:09 k8s-ci-robot

@MadhavJivrajani: Reopened this PR.

In response to this:

Awesome! This proves the regex needs to be improved :p

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Lyllt8 avatar Apr 27 '23 09:04 Lyllt8