-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
New workflow for synchronization of labels #35172
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #35172 +/- ##
===========================================
- Coverage 88.62% 88.60% -0.02%
===========================================
Files 2148 2148
Lines 398855 398855
===========================================
- Hits 353480 353418 -62
- Misses 45375 45437 +62 see 28 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
PR starts as non-draft. Hence this means a new PR gets "s: needs review" from the start. But an author of a PR may want to see checks reports before he/she adds "s: needs review" or even "s: needs work" for failed checks. |
Whenever I created a PR I had the choice to create it as a draft or ready for review. But I can't say which setting is responsible for that. If a PR has been created as ready for review you can change it to a draft using GH functionality. In this case the I've added a table to the PR description, to make this more clear. |
Yes. I have the choice too. I learned that just now (or I knew but forgot). It seems very easy to miss that. But the situation I described is somewhat different. One may think that his PR is not a draft but needs affirmative checks (github workflows) for sanity or some discussion before proceeding to "needs review". This PR itself seems an example of this situation :-)
A flowchart of the full development workflow may also help for this discussion. |
I now agree that the author should set the PR as a draft in this situation. As the authors who is not in the triage team cannot add labels, the draft/ready-for-review setting is the only available way to express the state of the PR.
Hence "s: needs review" just reflects the yes/no draft state as the table shows. |
This is one reason (see also the discussion in this sage-devel thread). Another one: If a PR is not a draft it is ready for review by GitHub terminology. So, if we like to avoid confusion between similar concepts (ready for review versus needs review) it's better to synchronize these, too.
Yes, accidentally.
Good idea! Are mermaid code-blocks the tool we use for that? |
Yes, it works nicely. |
Testing sync_labels (sagemath#35172)
I've added |
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.
Wow, very nice! For my taste its a tad to axiomatized, but from my point of view we can try this out and adapt it later once we run into situations where the automatization is to rigid.
The added workflow is failing at the moment though.
Perhaps this is already the established manual workflow on GitHub: sequenceDiagram
participant new PR
participant draft
participant needs review
participant needs info
participant needs work
new PR -->> draft: open as draft
new PR -->> needs review: open
draft -->> needs review: ready for review
needs review -->> draft: draft
needs review ->> needs info: needs info
needs info -->> needs review: ready for review
needs review ->> needs work: Change Requested
needs work -->> needs review: ready for review
needs review ->> positive review: Approved
Are your diagrams conformant with this? |
I would say: Yes! |
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.
I don't have much time at the moment for a proper review, but what I've seen by skimming over this PR it looks good to me.
No problem. Anyhow, we should give the community a look at the workflow before we proceed. Also, I just realized I missed a point (see sagemath/trac-to-github#117 (comment)) which should be done before. |
But one point is still unclear: The vertical lines in your chart appear to represent the Trac status except the one labeled |
I intended them to represent labels except the
I added Could a comment with sole content "needs review" or "needs info" may trigger the actions, by your script? |
Happy vacation! |
No problem. Everything was absolutely necessary. |
Many thanks! Also for your review! |
One feature of the new workflow is to automatically remove "positive review" label (or rather all status labels) from the merged PRs. Right? Then we need this feature as soon as possible. Could we turn this on? I think turning this feature on does not need explicit agreement from sage-devel, but would need an anouncement. |
According to my #35172 (comment) I've created #35927 to track the going live of the bot. We should fix a date to turn the closed trigger on. @tobiasdiez can you do the job of setting the corresponding variables?
If yes, what would be a good date? |
Nice! So as soon as Tobias set the variables, the bot starts to listen to the "closed" event (only). Right? Then let's have at least a week before Tobias setting the variables, after you make an announcement in sage-devel. |
Yes, I can do this whenever you want. From my point of view we can also switch it on immediately. |
I "feel" so with the |
Exactly! |
I agree. There will definitely be steps that need to be announced. Therefore, for didactic reasons, it would not make sense to start with an exception. Will next Tuesday July 18th be OK? What time of day suits you @tobiasdiez ? BTW: maybe one of you knows about an oddity that happened to my (completely unrelated) PR #35800. It has been merged into the current beta:
However, it is still open and not marked as merged. I suspect this is caused by a sequence of two shared commits with Travis that I accepted in the web interface, followed by a legacy commit that I pushed (after the pull) from my local repository. |
Yes, that should work for me. |
Many thanks! I've just announced the date on #35927 (comment) and sage-devel. |
@tobiasdiez, Did you do it? |
@dima would you take care of #35172 (comment)? We are not on schedule. |
Sorry for the delay, I've set the variables now. |
<!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> This is a follow up PR of sagemath#35172. It addresses the issues observed in the second step of going live (sagemath#35927 (comment)) of the label sync bot, which had to be disabled after a day (sagemath#35927 (comment)). As observed in sagemath#36177 (comment), this was caused by a bug concerning the `reviewDecision` in case the reviewer does not have appropriate access rights to the repository. In this case `gh pr view` returns None as `reviewDecision` which has been mapped to `COMMENTED` by caching reasons. The bug is that comparisons with `reviewDecision` have not been adapted to the cached value. Furthermore, the log-file sequence displayed in sagemath#36177 (comment) shows another unexpected behavior: ``` > INFO:root:Proper reviews after 2023-09-02T07:55:03Z for pull request sagemath#36177: [{'id': 'PRR_kwDOI5-Tx85f2_5f', 'author': {'login': 'dcoudert'}, 'authorAssociation': 'CONTRIBUTOR', 'body': 'LGTM.', 'submittedAt': '2023-09-02T13:23:57Z', 'includesCreatedEdit': False, 'reactionGroups': [], 'state': 'APPROVED', 'commit': {'oid': '626b764283b5005ab3a64661f7cc74efcd31adb9'}}, {'id': 'PRR_kwDOI5-Tx85f3sRb', 'author': {'login': 'tobiasdiez'}, 'authorAssociation': 'CONTRIBUTOR', 'body': "Let's see if its works when admins approve a PR", 'submittedAt': '2023-09-03T06:08:30Z', 'includesCreatedEdit': False, 'reactionGroups': [], 'state': 'APPROVED', 'commit': {'oid': '626b764283b5005ab3a64661f7cc74efcd31adb9'}}] ``` Here I had expected `'authorAssociation': 'MEMBER'` instead of `'authorAssociation': 'CONTRIBUTOR'` as it is shown when I do the query on my local command-line: ``` gh pr view sagemath#36177 --json reviews { "reviews": [ { "author": { "login": "dcoudert" }, "authorAssociation": "MEMBER", "body": "LGTM.", "submittedAt": "2023-09-02T13:23:57Z", "includesCreatedEdit": false, "reactionGroups": [], "state": "APPROVED" }, { "author": { "login": "tobiasdiez" }, "authorAssociation": "MEMBER", "body": "Let's see if its works when admins approve a PR", "submittedAt": "2023-09-03T06:08:30Z", "includesCreatedEdit": false, "reactionGroups": [], "state": "APPROVED" } ] } ``` As described in flutter/flutter#101012 this is caused since the github bot is not a member of the sagemath organisation and most of our members (me too) have set the private role which makes their membership just visible to other members. This is relevant in the `approve_allowed` method: ``` def approve_allowed(self): r""" Return if the actor has permission to approve this PR. """ revs = self.get_reviews(complete=True) if not any(rev['authorAssociation'] in ('MEMBER', 'OWNER') for rev in revs): info('PR %s can\'t be approved because of missing member review' % (self._issue)) return False .... ``` where the bot checks if it should set the `approved` state by itself. This did also fail in the example (from the [log-file](https://github.co m/sagemath/sage/actions/runs/6060223064/job/16444158489)): ``` INFO:root:PR pull request sagemath#36177 doesn't have positve review (by decision) INFO:root:PR pull request sagemath#36177 can't be approved because of missing member review ``` I think we can eliminate the check for a member review entirely as it is an unnecessary restriction. The check is only relevant if an `s: positive review` label is added, which can only be done by Triage members who know what they are doing. Even if we just added `CONTRIBUTOR` to the list, it would still be restrictive, as it would not be possible to set `s: positive review` when there is no review (this would be annoying for trivial PR that just has some PEP8 fixes). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36213 Reported by: Sebastian Oehms Reviewer(s): Tobias Diez
<!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> This is a follow up PR of sagemath#35172. It addresses the issues observed in the second step of going live (sagemath#35927 (comment)) of the label sync bot, which had to be disabled after a day (sagemath#35927 (comment)). As observed in sagemath#36177 (comment), this was caused by a bug concerning the `reviewDecision` in case the reviewer does not have appropriate access rights to the repository. In this case `gh pr view` returns None as `reviewDecision` which has been mapped to `COMMENTED` by caching reasons. The bug is that comparisons with `reviewDecision` have not been adapted to the cached value. Furthermore, the log-file sequence displayed in sagemath#36177 (comment) shows another unexpected behavior: ``` > INFO:root:Proper reviews after 2023-09-02T07:55:03Z for pull request sagemath#36177: [{'id': 'PRR_kwDOI5-Tx85f2_5f', 'author': {'login': 'dcoudert'}, 'authorAssociation': 'CONTRIBUTOR', 'body': 'LGTM.', 'submittedAt': '2023-09-02T13:23:57Z', 'includesCreatedEdit': False, 'reactionGroups': [], 'state': 'APPROVED', 'commit': {'oid': '626b764283b5005ab3a64661f7cc74efcd31adb9'}}, {'id': 'PRR_kwDOI5-Tx85f3sRb', 'author': {'login': 'tobiasdiez'}, 'authorAssociation': 'CONTRIBUTOR', 'body': "Let's see if its works when admins approve a PR", 'submittedAt': '2023-09-03T06:08:30Z', 'includesCreatedEdit': False, 'reactionGroups': [], 'state': 'APPROVED', 'commit': {'oid': '626b764283b5005ab3a64661f7cc74efcd31adb9'}}] ``` Here I had expected `'authorAssociation': 'MEMBER'` instead of `'authorAssociation': 'CONTRIBUTOR'` as it is shown when I do the query on my local command-line: ``` gh pr view sagemath#36177 --json reviews { "reviews": [ { "author": { "login": "dcoudert" }, "authorAssociation": "MEMBER", "body": "LGTM.", "submittedAt": "2023-09-02T13:23:57Z", "includesCreatedEdit": false, "reactionGroups": [], "state": "APPROVED" }, { "author": { "login": "tobiasdiez" }, "authorAssociation": "MEMBER", "body": "Let's see if its works when admins approve a PR", "submittedAt": "2023-09-03T06:08:30Z", "includesCreatedEdit": false, "reactionGroups": [], "state": "APPROVED" } ] } ``` As described in flutter/flutter#101012 this is caused since the github bot is not a member of the sagemath organisation and most of our members (me too) have set the private role which makes their membership just visible to other members. This is relevant in the `approve_allowed` method: ``` def approve_allowed(self): r""" Return if the actor has permission to approve this PR. """ revs = self.get_reviews(complete=True) if not any(rev['authorAssociation'] in ('MEMBER', 'OWNER') for rev in revs): info('PR %s can\'t be approved because of missing member review' % (self._issue)) return False .... ``` where the bot checks if it should set the `approved` state by itself. This did also fail in the example (from the [log-file](https://github.co m/sagemath/sage/actions/runs/6060223064/job/16444158489)): ``` INFO:root:PR pull request sagemath#36177 doesn't have positve review (by decision) INFO:root:PR pull request sagemath#36177 can't be approved because of missing member review ``` I think we can eliminate the check for a member review entirely as it is an unnecessary restriction. The check is only relevant if an `s: positive review` label is added, which can only be done by Triage members who know what they are doing. Even if we just added `CONTRIBUTOR` to the list, it would still be restrictive, as it would not be possible to set `s: positive review` when there is no review (this would be annoying for trivial PR that just has some PEP8 fixes). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36213 Reported by: Sebastian Oehms Reviewer(s): Tobias Diez
<!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> This is a follow up PR of sagemath#35172. It addresses the issues observed in the second step of going live (sagemath#35927 (comment)) of the label sync bot, which had to be disabled after a day (sagemath#35927 (comment)). As observed in sagemath#36177 (comment), this was caused by a bug concerning the `reviewDecision` in case the reviewer does not have appropriate access rights to the repository. In this case `gh pr view` returns None as `reviewDecision` which has been mapped to `COMMENTED` by caching reasons. The bug is that comparisons with `reviewDecision` have not been adapted to the cached value. Furthermore, the log-file sequence displayed in sagemath#36177 (comment) shows another unexpected behavior: ``` > INFO:root:Proper reviews after 2023-09-02T07:55:03Z for pull request sagemath#36177: [{'id': 'PRR_kwDOI5-Tx85f2_5f', 'author': {'login': 'dcoudert'}, 'authorAssociation': 'CONTRIBUTOR', 'body': 'LGTM.', 'submittedAt': '2023-09-02T13:23:57Z', 'includesCreatedEdit': False, 'reactionGroups': [], 'state': 'APPROVED', 'commit': {'oid': '626b764283b5005ab3a64661f7cc74efcd31adb9'}}, {'id': 'PRR_kwDOI5-Tx85f3sRb', 'author': {'login': 'tobiasdiez'}, 'authorAssociation': 'CONTRIBUTOR', 'body': "Let's see if its works when admins approve a PR", 'submittedAt': '2023-09-03T06:08:30Z', 'includesCreatedEdit': False, 'reactionGroups': [], 'state': 'APPROVED', 'commit': {'oid': '626b764283b5005ab3a64661f7cc74efcd31adb9'}}] ``` Here I had expected `'authorAssociation': 'MEMBER'` instead of `'authorAssociation': 'CONTRIBUTOR'` as it is shown when I do the query on my local command-line: ``` gh pr view sagemath#36177 --json reviews { "reviews": [ { "author": { "login": "dcoudert" }, "authorAssociation": "MEMBER", "body": "LGTM.", "submittedAt": "2023-09-02T13:23:57Z", "includesCreatedEdit": false, "reactionGroups": [], "state": "APPROVED" }, { "author": { "login": "tobiasdiez" }, "authorAssociation": "MEMBER", "body": "Let's see if its works when admins approve a PR", "submittedAt": "2023-09-03T06:08:30Z", "includesCreatedEdit": false, "reactionGroups": [], "state": "APPROVED" } ] } ``` As described in flutter/flutter#101012 this is caused since the github bot is not a member of the sagemath organisation and most of our members (me too) have set the private role which makes their membership just visible to other members. This is relevant in the `approve_allowed` method: ``` def approve_allowed(self): r""" Return if the actor has permission to approve this PR. """ revs = self.get_reviews(complete=True) if not any(rev['authorAssociation'] in ('MEMBER', 'OWNER') for rev in revs): info('PR %s can\'t be approved because of missing member review' % (self._issue)) return False .... ``` where the bot checks if it should set the `approved` state by itself. This did also fail in the example (from the [log-file](https://github.co m/sagemath/sage/actions/runs/6060223064/job/16444158489)): ``` INFO:root:PR pull request sagemath#36177 doesn't have positve review (by decision) INFO:root:PR pull request sagemath#36177 can't be approved because of missing member review ``` I think we can eliminate the check for a member review entirely as it is an unnecessary restriction. The check is only relevant if an `s: positive review` label is added, which can only be done by Triage members who know what they are doing. Even if we just added `CONTRIBUTOR` to the list, it would still be restrictive, as it would not be possible to set `s: positive review` when there is no review (this would be annoying for trivial PR that just has some PEP8 fixes). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36213 Reported by: Sebastian Oehms Reviewer(s): Tobias Diez
…tion <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> Unfortunately the fix in sagemath#36213 has not been completed properly. There is still a `return` from the `get_review_decision` method which is not `None` where it should be. This is fixed here. Sorry for this unnecessary trouble and my lack of attention! In a next step this PR fixes a bug which has been noticed by an accidentally activation of the `unlabeled` trigger (see sagemath#36292 (comment)). Simultanously the `labeled`-trigger has been disabled. This is an unrealistic setting which was not covered by the code. Explicitely, a state label could not be removed even though other state labels where set (examples sagemath#36128 and sagemath#36020). This PR leads to the following changes of behavior: 1. The reaction on the `unlabeled`-event is reduced to the case of the last label 2. The `unlabeled`-event will not lead to a rejection of the removal any more 3. Instead of a warning comment a hint comment is posted. We found a way to test the bot a little more realistically (see soehms#11). Additional problems emerged and were also resolved. This led to the following changes in the workflow: 4. A bug in `actor_valid` is fixed (see soehms#10 (comment)) 5. Preparing to use our own bot user (e.g. [sagemathadmins](/~https://github.com/sagemathadmins)) (see soehms#11 (comment)) 6. Waiver of observing the `reviewDecision` feature provided by GitHub (see 2. in soehms#11 (comment)) 7. Allow the user to revert his decision of label selection (see soehms#11 (comment)) 8. Don't reject label addition any more, except in the case where the author tries to set `s: positive review` to his own PR which has no reviews from others (see soehms#11 (comment)) 9. Dismiss stale reviews of the bot after a push to the branch and on submission of a new review which is more than just a comment (see soehms#11 (comment)). Despite the fact that the testing was now more realistic, it is still not guaranteed that the bot's behavior in `sagemath/sage` will be completely covered by our testing. The changes in this PR cannot be activated immediately after merging into the develop branch due to a bug in the GitHub web interface observed during testing in soehms#11 (see soehms#11 (comment) and soehms#11 (comment)). The problem is that the panel at the top right of the webpage that contains the labels does not update immediately after the bot changes the labels. Since this might cause confusion, I'll create a bug report about it. The going-live of the sync bot will be stalled at least until we received an answer. This PR changes the following flowcharts from sagemath#35172 : ##### What happens when adding `s: needs review` to a PR? ```mermaid --- title: add the needs review label --- flowchart LR %% vertices trigger([label\n 's: needs review'\n added]) mark_as_ready([mark as\n ready for\n review]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_review_valid[[needs review\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_review_valid needs_review_valid -- true ---> remove_other_labels needs_review_valid -- false ---> is_draft is_draft -- yes ---> mark_as_ready is_draft -- no ---> warning_about_label_addition mark_as_ready --> remove_other_labels ``` The warning is posted as a comment which will be deleted after 5 minutes. ```mermaid --- title: needs review valid? --- flowchart LR %% vertices needs_review_valid([needs review\n valid?]) true([true]) false([false]) latest_review_by_actor{latest review\n by actor} needs_work_valid[[needs work\n valid?]] positive_review_valid[[positive review\n valid?]] is_draft{is PR\n a draft?} %% edges needs_review_valid ---> is_draft is_draft -- yes ---> false is_draft -- no ---> latest_review_by_actor latest_review_by_actor -- yes ---> true latest_review_by_actor -- no ---> needs_work_valid needs_work_valid -- true ---> false needs_work_valid -- false ---> positive_review_valid positive_review_valid -- true ---> false positive_review_valid -- false ---> true ``` ```mermaid --- title: needs work valid? --- flowchart LR %% vertices needs_work_valid([needs work\n valid?]) true([true]) false([false]) latest_review_request_changes{latest proper\n review requests\n changes?} %% edges needs_work_valid --> latest_review_request_changes latest_review_request_changes -- yes ---> true latest_review_request_changes -- no ---> false ``` ```mermaid --- title: positive review valid? --- flowchart LR %% vertices positive_review_valid([positive review\n valid?]) true([true]) false([false]) latest_proper_review_approved{latest proper\n review\n approved?} %% edges positive_review_valid --> latest_proper_review_approved latest_proper_review_approved -- yes ---> true latest_proper_review_approved -- no ---> false ``` Here, proper means that the review is more than a comment. ##### What happens when adding s: needs work to a PR? ```mermaid --- title: add the needs work label --- flowchart LR %% vertices trigger([label\n 's: needs work'\n added]) request_changes([request changes]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_work_valid[[needs work\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_work_valid needs_work_valid -- true ---> remove_other_labels needs_work_valid -- false ---> is_draft is_draft -- yes ---> warning_about_label_addition is_draft -- no ---> request_changes request_changes --> remove_other_labels ``` ##### What happens when adding `s: positive review` to a PR? ```mermaid --- title: add the positive review label --- flowchart LR %% vertices trigger([label\n 's: positive review'\n added]) positive_review_valid[[positive review\n valid?]] approve_pr([approve]) remove_other_labels([remove other\n state labels]) actor_valid[[actor valid?]] approve_allowed[[approve\n allowed?]] warning_about_label_addition([warning\n about label\n addition]) reject_label_addition[[reject\n label\n addition]] %% edges trigger --> positive_review_valid positive_review_valid -- yes ---> remove_other_labels positive_review_valid -- no ---> actor_valid actor_valid -- yes ---> approve_allowed actor_valid -- no ---> reject_label_addition approve_allowed -- yes ---> approve_pr approve_allowed -- no ---> warning_about_label_addition approve_pr --> remove_other_labels ``` The boxes `actor_valid` and `reject_label_addition` are unchanged. ```mermaid --- title: approve allowed? --- flowchart LR %% vertices trigger([approve\n allowed?]) true([true]) false([false]) review_of_others_request_changes{changes\n requested by\n someone\n else exists?} %% edges trigger --> review_of_others_request_changes review_of_others_request_changes -- yes ---> false review_of_others_request_changes -- no ---> true ``` Here, only reviews of someone else are considered which are more recent than any commit. ##### What happens when a state label is added to an issue? ```mermaid --- title: add a state label to an issue --- flowchart LR %% vertices trigger([label added]) warning_about_label_addition([warning\n about label\n addition]) nothing([do nothing]) is_needs_info{is label\n 's: needs info'?} %% edges trigger --> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> warning_about_label_addition ``` ##### What happens when removing a state label from a PR? ```mermaid --- title: remove a state label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_state_label{other state\n labels exist?} is_needs_info{is label\n 's: needs info'?} %% edges trigger --> other_state_label other_state_label -- yes ---> nothing other_state_label -- no ---> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> hint_about_label_removal ``` The hint is postet as a comment which will be deleted after 5 minutes. ##### What happens when adding a priority label? ```mermaid --- title: add a priority label --- flowchart LR %% vertices trigger([label added]) remove_other_labels([remove other\n priority labels]) %% edges trigger --> remove_other_labels ``` ##### What happens when removing a priority label? ```mermaid --- title: remove a priority label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_prio_label{other priority\n labels exist?} %% edges trigger --> other_prio_label other_prio_label -- yes ---> nothing other_prio_label -- no ---> hint_about_label_removal ``` ##### What happens when a PR is approved? ```mermaid --- title: approve --- flowchart LR %% vertices trigger([approve\n]) select_positive_review(['s: positive review'\n label selected]) nothing([do nothing]) positive_review_valid[[positive review\n valid?]] pending_review_requests{pending\n review requests\n exists?} actor_authorized{is actor\n a member of\n Triage?} %% edges trigger ---> pending_review_requests pending_review_requests -- yes ---> nothing pending_review_requests -- no ---> actor_authorized actor_authorized -- yes ---> positive_review_valid actor_authorized -- no ---> nothing positive_review_valid -- true ---> select_positive_review positive_review_valid -- false ---> nothing ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36292 Reported by: Sebastian Oehms Reviewer(s): Kwankyu Lee
…tion <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> Unfortunately the fix in sagemath#36213 has not been completed properly. There is still a `return` from the `get_review_decision` method which is not `None` where it should be. This is fixed here. Sorry for this unnecessary trouble and my lack of attention! In a next step this PR fixes a bug which has been noticed by an accidentally activation of the `unlabeled` trigger (see sagemath#36292 (comment)). Simultanously the `labeled`-trigger has been disabled. This is an unrealistic setting which was not covered by the code. Explicitely, a state label could not be removed even though other state labels where set (examples sagemath#36128 and sagemath#36020). This PR leads to the following changes of behavior: 1. The reaction on the `unlabeled`-event is reduced to the case of the last label 2. The `unlabeled`-event will not lead to a rejection of the removal any more 3. Instead of a warning comment a hint comment is posted. We found a way to test the bot a little more realistically (see soehms#11). Additional problems emerged and were also resolved. This led to the following changes in the workflow: 4. A bug in `actor_valid` is fixed (see soehms#10 (comment)) 5. Preparing to use our own bot user (e.g. [sagemathadmins](/~https://github.com/sagemathadmins)) (see soehms#11 (comment)) 6. Waiver of observing the `reviewDecision` feature provided by GitHub (see 2. in soehms#11 (comment)) 7. Allow the user to revert his decision of label selection (see soehms#11 (comment)) 8. Don't reject label addition any more, except in the case where the author tries to set `s: positive review` to his own PR which has no reviews from others (see soehms#11 (comment)) 9. Dismiss stale reviews of the bot after a push to the branch and on submission of a new review which is more than just a comment (see soehms#11 (comment)). Despite the fact that the testing was now more realistic, it is still not guaranteed that the bot's behavior in `sagemath/sage` will be completely covered by our testing. The changes in this PR cannot be activated immediately after merging into the develop branch due to a bug in the GitHub web interface observed during testing in soehms#11 (see soehms#11 (comment) and soehms#11 (comment)). The problem is that the panel at the top right of the webpage that contains the labels does not update immediately after the bot changes the labels. Since this might cause confusion, I'll create a bug report about it. The going-live of the sync bot will be stalled at least until we received an answer. This PR changes the following flowcharts from sagemath#35172 : ##### What happens when adding `s: needs review` to a PR? ```mermaid --- title: add the needs review label --- flowchart LR %% vertices trigger([label\n 's: needs review'\n added]) mark_as_ready([mark as\n ready for\n review]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_review_valid[[needs review\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_review_valid needs_review_valid -- true ---> remove_other_labels needs_review_valid -- false ---> is_draft is_draft -- yes ---> mark_as_ready is_draft -- no ---> warning_about_label_addition mark_as_ready --> remove_other_labels ``` The warning is posted as a comment which will be deleted after 5 minutes. ```mermaid --- title: needs review valid? --- flowchart LR %% vertices needs_review_valid([needs review\n valid?]) true([true]) false([false]) latest_review_by_actor{latest review\n by actor} needs_work_valid[[needs work\n valid?]] positive_review_valid[[positive review\n valid?]] is_draft{is PR\n a draft?} %% edges needs_review_valid ---> is_draft is_draft -- yes ---> false is_draft -- no ---> latest_review_by_actor latest_review_by_actor -- yes ---> true latest_review_by_actor -- no ---> needs_work_valid needs_work_valid -- true ---> false needs_work_valid -- false ---> positive_review_valid positive_review_valid -- true ---> false positive_review_valid -- false ---> true ``` ```mermaid --- title: needs work valid? --- flowchart LR %% vertices needs_work_valid([needs work\n valid?]) true([true]) false([false]) latest_review_request_changes{latest proper\n review requests\n changes?} %% edges needs_work_valid --> latest_review_request_changes latest_review_request_changes -- yes ---> true latest_review_request_changes -- no ---> false ``` ```mermaid --- title: positive review valid? --- flowchart LR %% vertices positive_review_valid([positive review\n valid?]) true([true]) false([false]) latest_proper_review_approved{latest proper\n review\n approved?} %% edges positive_review_valid --> latest_proper_review_approved latest_proper_review_approved -- yes ---> true latest_proper_review_approved -- no ---> false ``` Here, proper means that the review is more than a comment. ##### What happens when adding s: needs work to a PR? ```mermaid --- title: add the needs work label --- flowchart LR %% vertices trigger([label\n 's: needs work'\n added]) request_changes([request changes]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_work_valid[[needs work\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_work_valid needs_work_valid -- true ---> remove_other_labels needs_work_valid -- false ---> is_draft is_draft -- yes ---> warning_about_label_addition is_draft -- no ---> request_changes request_changes --> remove_other_labels ``` ##### What happens when adding `s: positive review` to a PR? ```mermaid --- title: add the positive review label --- flowchart LR %% vertices trigger([label\n 's: positive review'\n added]) positive_review_valid[[positive review\n valid?]] approve_pr([approve]) remove_other_labels([remove other\n state labels]) actor_valid[[actor valid?]] approve_allowed[[approve\n allowed?]] warning_about_label_addition([warning\n about label\n addition]) reject_label_addition[[reject\n label\n addition]] %% edges trigger --> positive_review_valid positive_review_valid -- yes ---> remove_other_labels positive_review_valid -- no ---> actor_valid actor_valid -- yes ---> approve_allowed actor_valid -- no ---> reject_label_addition approve_allowed -- yes ---> approve_pr approve_allowed -- no ---> warning_about_label_addition approve_pr --> remove_other_labels ``` The boxes `actor_valid` and `reject_label_addition` are unchanged. ```mermaid --- title: approve allowed? --- flowchart LR %% vertices trigger([approve\n allowed?]) true([true]) false([false]) review_of_others_request_changes{changes\n requested by\n someone\n else exists?} %% edges trigger --> review_of_others_request_changes review_of_others_request_changes -- yes ---> false review_of_others_request_changes -- no ---> true ``` Here, only reviews of someone else are considered which are more recent than any commit. ##### What happens when a state label is added to an issue? ```mermaid --- title: add a state label to an issue --- flowchart LR %% vertices trigger([label added]) warning_about_label_addition([warning\n about label\n addition]) nothing([do nothing]) is_needs_info{is label\n 's: needs info'?} %% edges trigger --> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> warning_about_label_addition ``` ##### What happens when removing a state label from a PR? ```mermaid --- title: remove a state label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_state_label{other state\n labels exist?} is_needs_info{is label\n 's: needs info'?} %% edges trigger --> other_state_label other_state_label -- yes ---> nothing other_state_label -- no ---> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> hint_about_label_removal ``` The hint is postet as a comment which will be deleted after 5 minutes. ##### What happens when adding a priority label? ```mermaid --- title: add a priority label --- flowchart LR %% vertices trigger([label added]) remove_other_labels([remove other\n priority labels]) %% edges trigger --> remove_other_labels ``` ##### What happens when removing a priority label? ```mermaid --- title: remove a priority label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_prio_label{other priority\n labels exist?} %% edges trigger --> other_prio_label other_prio_label -- yes ---> nothing other_prio_label -- no ---> hint_about_label_removal ``` ##### What happens when a PR is approved? ```mermaid --- title: approve --- flowchart LR %% vertices trigger([approve\n]) select_positive_review(['s: positive review'\n label selected]) nothing([do nothing]) positive_review_valid[[positive review\n valid?]] pending_review_requests{pending\n review requests\n exists?} actor_authorized{is actor\n a member of\n Triage?} %% edges trigger ---> pending_review_requests pending_review_requests -- yes ---> nothing pending_review_requests -- no ---> actor_authorized actor_authorized -- yes ---> positive_review_valid actor_authorized -- no ---> nothing positive_review_valid -- true ---> select_positive_review positive_review_valid -- false ---> nothing ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36292 Reported by: Sebastian Oehms Reviewer(s): Kwankyu Lee
…tion <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> Unfortunately the fix in sagemath#36213 has not been completed properly. There is still a `return` from the `get_review_decision` method which is not `None` where it should be. This is fixed here. Sorry for this unnecessary trouble and my lack of attention! In a next step this PR fixes a bug which has been noticed by an accidentally activation of the `unlabeled` trigger (see sagemath#36292 (comment)). Simultanously the `labeled`-trigger has been disabled. This is an unrealistic setting which was not covered by the code. Explicitely, a state label could not be removed even though other state labels where set (examples sagemath#36128 and sagemath#36020). This PR leads to the following changes of behavior: 1. The reaction on the `unlabeled`-event is reduced to the case of the last label 2. The `unlabeled`-event will not lead to a rejection of the removal any more 3. Instead of a warning comment a hint comment is posted. We found a way to test the bot a little more realistically (see soehms#11). Additional problems emerged and were also resolved. This led to the following changes in the workflow: 4. A bug in `actor_valid` is fixed (see soehms#10 (comment)) 5. Preparing to use our own bot user (e.g. [sagemathadmins](/~https://github.com/sagemathadmins)) (see soehms#11 (comment)) 6. Waiver of observing the `reviewDecision` feature provided by GitHub (see 2. in soehms#11 (comment)) 7. Allow the user to revert his decision of label selection (see soehms#11 (comment)) 8. Don't reject label addition any more, except in the case where the author tries to set `s: positive review` to his own PR which has no reviews from others (see soehms#11 (comment)) 9. Dismiss stale reviews of the bot after a push to the branch and on submission of a new review which is more than just a comment (see soehms#11 (comment)). Despite the fact that the testing was now more realistic, it is still not guaranteed that the bot's behavior in `sagemath/sage` will be completely covered by our testing. The changes in this PR cannot be activated immediately after merging into the develop branch due to a bug in the GitHub web interface observed during testing in soehms#11 (see soehms#11 (comment) and soehms#11 (comment)). The problem is that the panel at the top right of the webpage that contains the labels does not update immediately after the bot changes the labels. Since this might cause confusion, I'll create a bug report about it. The going-live of the sync bot will be stalled at least until we received an answer. This PR changes the following flowcharts from sagemath#35172 : ##### What happens when adding `s: needs review` to a PR? ```mermaid --- title: add the needs review label --- flowchart LR %% vertices trigger([label\n 's: needs review'\n added]) mark_as_ready([mark as\n ready for\n review]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_review_valid[[needs review\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_review_valid needs_review_valid -- true ---> remove_other_labels needs_review_valid -- false ---> is_draft is_draft -- yes ---> mark_as_ready is_draft -- no ---> warning_about_label_addition mark_as_ready --> remove_other_labels ``` The warning is posted as a comment which will be deleted after 5 minutes. ```mermaid --- title: needs review valid? --- flowchart LR %% vertices needs_review_valid([needs review\n valid?]) true([true]) false([false]) latest_review_by_actor{latest review\n by actor} needs_work_valid[[needs work\n valid?]] positive_review_valid[[positive review\n valid?]] is_draft{is PR\n a draft?} %% edges needs_review_valid ---> is_draft is_draft -- yes ---> false is_draft -- no ---> latest_review_by_actor latest_review_by_actor -- yes ---> true latest_review_by_actor -- no ---> needs_work_valid needs_work_valid -- true ---> false needs_work_valid -- false ---> positive_review_valid positive_review_valid -- true ---> false positive_review_valid -- false ---> true ``` ```mermaid --- title: needs work valid? --- flowchart LR %% vertices needs_work_valid([needs work\n valid?]) true([true]) false([false]) latest_review_request_changes{latest proper\n review requests\n changes?} %% edges needs_work_valid --> latest_review_request_changes latest_review_request_changes -- yes ---> true latest_review_request_changes -- no ---> false ``` ```mermaid --- title: positive review valid? --- flowchart LR %% vertices positive_review_valid([positive review\n valid?]) true([true]) false([false]) latest_proper_review_approved{latest proper\n review\n approved?} %% edges positive_review_valid --> latest_proper_review_approved latest_proper_review_approved -- yes ---> true latest_proper_review_approved -- no ---> false ``` Here, proper means that the review is more than a comment. ##### What happens when adding s: needs work to a PR? ```mermaid --- title: add the needs work label --- flowchart LR %% vertices trigger([label\n 's: needs work'\n added]) request_changes([request changes]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_work_valid[[needs work\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_work_valid needs_work_valid -- true ---> remove_other_labels needs_work_valid -- false ---> is_draft is_draft -- yes ---> warning_about_label_addition is_draft -- no ---> request_changes request_changes --> remove_other_labels ``` ##### What happens when adding `s: positive review` to a PR? ```mermaid --- title: add the positive review label --- flowchart LR %% vertices trigger([label\n 's: positive review'\n added]) positive_review_valid[[positive review\n valid?]] approve_pr([approve]) remove_other_labels([remove other\n state labels]) actor_valid[[actor valid?]] approve_allowed[[approve\n allowed?]] warning_about_label_addition([warning\n about label\n addition]) reject_label_addition[[reject\n label\n addition]] %% edges trigger --> positive_review_valid positive_review_valid -- yes ---> remove_other_labels positive_review_valid -- no ---> actor_valid actor_valid -- yes ---> approve_allowed actor_valid -- no ---> reject_label_addition approve_allowed -- yes ---> approve_pr approve_allowed -- no ---> warning_about_label_addition approve_pr --> remove_other_labels ``` The boxes `actor_valid` and `reject_label_addition` are unchanged. ```mermaid --- title: approve allowed? --- flowchart LR %% vertices trigger([approve\n allowed?]) true([true]) false([false]) review_of_others_request_changes{changes\n requested by\n someone\n else exists?} %% edges trigger --> review_of_others_request_changes review_of_others_request_changes -- yes ---> false review_of_others_request_changes -- no ---> true ``` Here, only reviews of someone else are considered which are more recent than any commit. ##### What happens when a state label is added to an issue? ```mermaid --- title: add a state label to an issue --- flowchart LR %% vertices trigger([label added]) warning_about_label_addition([warning\n about label\n addition]) nothing([do nothing]) is_needs_info{is label\n 's: needs info'?} %% edges trigger --> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> warning_about_label_addition ``` ##### What happens when removing a state label from a PR? ```mermaid --- title: remove a state label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_state_label{other state\n labels exist?} is_needs_info{is label\n 's: needs info'?} %% edges trigger --> other_state_label other_state_label -- yes ---> nothing other_state_label -- no ---> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> hint_about_label_removal ``` The hint is postet as a comment which will be deleted after 5 minutes. ##### What happens when adding a priority label? ```mermaid --- title: add a priority label --- flowchart LR %% vertices trigger([label added]) remove_other_labels([remove other\n priority labels]) %% edges trigger --> remove_other_labels ``` ##### What happens when removing a priority label? ```mermaid --- title: remove a priority label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_prio_label{other priority\n labels exist?} %% edges trigger --> other_prio_label other_prio_label -- yes ---> nothing other_prio_label -- no ---> hint_about_label_removal ``` ##### What happens when a PR is approved? ```mermaid --- title: approve --- flowchart LR %% vertices trigger([approve\n]) select_positive_review(['s: positive review'\n label selected]) nothing([do nothing]) positive_review_valid[[positive review\n valid?]] pending_review_requests{pending\n review requests\n exists?} actor_authorized{is actor\n a member of\n Triage?} %% edges trigger ---> pending_review_requests pending_review_requests -- yes ---> nothing pending_review_requests -- no ---> actor_authorized actor_authorized -- yes ---> positive_review_valid actor_authorized -- no ---> nothing positive_review_valid -- true ---> select_positive_review positive_review_valid -- false ---> nothing ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36292 Reported by: Sebastian Oehms Reviewer(s): Kwankyu Lee
…tion <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> Unfortunately the fix in sagemath#36213 has not been completed properly. There is still a `return` from the `get_review_decision` method which is not `None` where it should be. This is fixed here. Sorry for this unnecessary trouble and my lack of attention! In a next step this PR fixes a bug which has been noticed by an accidentally activation of the `unlabeled` trigger (see sagemath#36292 (comment)). Simultanously the `labeled`-trigger has been disabled. This is an unrealistic setting which was not covered by the code. Explicitely, a state label could not be removed even though other state labels where set (examples sagemath#36128 and sagemath#36020). This PR leads to the following changes of behavior: 1. The reaction on the `unlabeled`-event is reduced to the case of the last label 2. The `unlabeled`-event will not lead to a rejection of the removal any more 3. Instead of a warning comment a hint comment is posted. We found a way to test the bot a little more realistically (see soehms#11). Additional problems emerged and were also resolved. This led to the following changes in the workflow: 4. A bug in `actor_valid` is fixed (see soehms#10 (comment)) 5. Preparing to use our own bot user (e.g. [sagemathadmins](/~https://github.com/sagemathadmins)) (see soehms#11 (comment)) 6. Waiver of observing the `reviewDecision` feature provided by GitHub (see 2. in soehms#11 (comment)) 7. Allow the user to revert his decision of label selection (see soehms#11 (comment)) 8. Don't reject label addition any more, except in the case where the author tries to set `s: positive review` to his own PR which has no reviews from others (see soehms#11 (comment)) 9. Dismiss stale reviews of the bot after a push to the branch and on submission of a new review which is more than just a comment (see soehms#11 (comment)). Despite the fact that the testing was now more realistic, it is still not guaranteed that the bot's behavior in `sagemath/sage` will be completely covered by our testing. The changes in this PR cannot be activated immediately after merging into the develop branch due to a bug in the GitHub web interface observed during testing in soehms#11 (see soehms#11 (comment) and soehms#11 (comment)). The problem is that the panel at the top right of the webpage that contains the labels does not update immediately after the bot changes the labels. Since this might cause confusion, I'll create a bug report about it. The going-live of the sync bot will be stalled at least until we received an answer. This PR changes the following flowcharts from sagemath#35172 : ##### What happens when adding `s: needs review` to a PR? ```mermaid --- title: add the needs review label --- flowchart LR %% vertices trigger([label\n 's: needs review'\n added]) mark_as_ready([mark as\n ready for\n review]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_review_valid[[needs review\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_review_valid needs_review_valid -- true ---> remove_other_labels needs_review_valid -- false ---> is_draft is_draft -- yes ---> mark_as_ready is_draft -- no ---> warning_about_label_addition mark_as_ready --> remove_other_labels ``` The warning is posted as a comment which will be deleted after 5 minutes. ```mermaid --- title: needs review valid? --- flowchart LR %% vertices needs_review_valid([needs review\n valid?]) true([true]) false([false]) latest_review_by_actor{latest review\n by actor} needs_work_valid[[needs work\n valid?]] positive_review_valid[[positive review\n valid?]] is_draft{is PR\n a draft?} %% edges needs_review_valid ---> is_draft is_draft -- yes ---> false is_draft -- no ---> latest_review_by_actor latest_review_by_actor -- yes ---> true latest_review_by_actor -- no ---> needs_work_valid needs_work_valid -- true ---> false needs_work_valid -- false ---> positive_review_valid positive_review_valid -- true ---> false positive_review_valid -- false ---> true ``` ```mermaid --- title: needs work valid? --- flowchart LR %% vertices needs_work_valid([needs work\n valid?]) true([true]) false([false]) latest_review_request_changes{latest proper\n review requests\n changes?} %% edges needs_work_valid --> latest_review_request_changes latest_review_request_changes -- yes ---> true latest_review_request_changes -- no ---> false ``` ```mermaid --- title: positive review valid? --- flowchart LR %% vertices positive_review_valid([positive review\n valid?]) true([true]) false([false]) latest_proper_review_approved{latest proper\n review\n approved?} %% edges positive_review_valid --> latest_proper_review_approved latest_proper_review_approved -- yes ---> true latest_proper_review_approved -- no ---> false ``` Here, proper means that the review is more than a comment. ##### What happens when adding s: needs work to a PR? ```mermaid --- title: add the needs work label --- flowchart LR %% vertices trigger([label\n 's: needs work'\n added]) request_changes([request changes]) remove_other_labels([remove other\n state labels]) warning_about_label_addition([warning\n about label\n addition]) needs_work_valid[[needs work\n valid?]] is_draft{is PR\n a draft?} %% edges trigger --> needs_work_valid needs_work_valid -- true ---> remove_other_labels needs_work_valid -- false ---> is_draft is_draft -- yes ---> warning_about_label_addition is_draft -- no ---> request_changes request_changes --> remove_other_labels ``` ##### What happens when adding `s: positive review` to a PR? ```mermaid --- title: add the positive review label --- flowchart LR %% vertices trigger([label\n 's: positive review'\n added]) positive_review_valid[[positive review\n valid?]] approve_pr([approve]) remove_other_labels([remove other\n state labels]) actor_valid[[actor valid?]] approve_allowed[[approve\n allowed?]] warning_about_label_addition([warning\n about label\n addition]) reject_label_addition[[reject\n label\n addition]] %% edges trigger --> positive_review_valid positive_review_valid -- yes ---> remove_other_labels positive_review_valid -- no ---> actor_valid actor_valid -- yes ---> approve_allowed actor_valid -- no ---> reject_label_addition approve_allowed -- yes ---> approve_pr approve_allowed -- no ---> warning_about_label_addition approve_pr --> remove_other_labels ``` The boxes `actor_valid` and `reject_label_addition` are unchanged. ```mermaid --- title: approve allowed? --- flowchart LR %% vertices trigger([approve\n allowed?]) true([true]) false([false]) review_of_others_request_changes{changes\n requested by\n someone\n else exists?} %% edges trigger --> review_of_others_request_changes review_of_others_request_changes -- yes ---> false review_of_others_request_changes -- no ---> true ``` Here, only reviews of someone else are considered which are more recent than any commit. ##### What happens when a state label is added to an issue? ```mermaid --- title: add a state label to an issue --- flowchart LR %% vertices trigger([label added]) warning_about_label_addition([warning\n about label\n addition]) nothing([do nothing]) is_needs_info{is label\n 's: needs info'?} %% edges trigger --> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> warning_about_label_addition ``` ##### What happens when removing a state label from a PR? ```mermaid --- title: remove a state label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_state_label{other state\n labels exist?} is_needs_info{is label\n 's: needs info'?} %% edges trigger --> other_state_label other_state_label -- yes ---> nothing other_state_label -- no ---> is_needs_info is_needs_info -- yes ---> nothing is_needs_info -- no ---> hint_about_label_removal ``` The hint is postet as a comment which will be deleted after 5 minutes. ##### What happens when adding a priority label? ```mermaid --- title: add a priority label --- flowchart LR %% vertices trigger([label added]) remove_other_labels([remove other\n priority labels]) %% edges trigger --> remove_other_labels ``` ##### What happens when removing a priority label? ```mermaid --- title: remove a priority label --- flowchart LR %% vertices trigger([label removed]) nothing([do nothing]) hint_about_label_removal([hint\n about label\n removal]) other_prio_label{other priority\n labels exist?} %% edges trigger --> other_prio_label other_prio_label -- yes ---> nothing other_prio_label -- no ---> hint_about_label_removal ``` ##### What happens when a PR is approved? ```mermaid --- title: approve --- flowchart LR %% vertices trigger([approve\n]) select_positive_review(['s: positive review'\n label selected]) nothing([do nothing]) positive_review_valid[[positive review\n valid?]] pending_review_requests{pending\n review requests\n exists?} actor_authorized{is actor\n a member of\n Triage?} %% edges trigger ---> pending_review_requests pending_review_requests -- yes ---> nothing pending_review_requests -- no ---> actor_authorized actor_authorized -- yes ---> positive_review_valid actor_authorized -- no ---> nothing positive_review_valid -- true ---> select_positive_review positive_review_valid -- false ---> nothing ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36292 Reported by: Sebastian Oehms Reviewer(s): Kwankyu Lee
📚 Description
This PR is a continuation of sagemath/trac-to-github#187.
It implements GitHub actions to synchronize the labels migrated from Trac selection lists (according to issue sagemath/trac-to-github#117). These are the priority and state labels (type labels are not considered here since their meaning has changed).
The bot will not be active immediatly after this PR is merged. It needs to be activated by a maintainer of the repository by adding the variable
SYNC_LABELS_ACTIVE
with valueyes
underAnother repository variable
SYNC_LABELS_IGNORE_EVENTS
can be used to disable the bot on specific GitHub triggers. For example,SYNC_LABELS_IGNORE_EVENTS = ["unlabeled", "submitted"]
causes the bot to suspend responding to these events.At the moment the script takes care that there is just one item present from each list and it sets
s: needs review
on a non draft PR opening. Furthermore, it reacts on review approval and change requests setting according labels automatically (after some checks). Conversely, setting a state label will lead to automatic approval resp. change request under certain circumstances. If there is need to reject it a warning comment is posted.For a detailed description of the workflows see the flowcharts below. In summary, the bot keeps the meaning consistent along the rows in the table below:
The review decision is not given explicitly on all cases. Implicitly it can be read of the list of all reviews. So if there is at least one review requesting changes younger than any commit the review decision is interpreted as
CHANGES REQUESTED
. If there is at least one approved review younger than any commit but none requesting changes the review decision is interpreted asAPPROVED
.Please consider this implementation just as a base of discussion.
Open problems and questions
s: needs info
.Notes on testing
The failure of the Synchronize selection list labeled / synchronize (pull_request) check is to be expected (see #35172 (comment)) since it is trying to download the python file from the upstream repository (
sagemath/sage
). Therefore testing the script must be done relative to my fork (soehms/sage
). First examples are soehms#1 and soehms#2. It would be helpful if others would open PRs there in order to test the review functionality which I can't do by myself.Flowcharts
What happens when a PR changes its state?
What happens when a PR is opened?
What happens when a PR is closed or reopened or converted to a draft?
What happens when a draft is ready for review or the branch of a PR is synchronized?
Here, proper means that the review is more than a comment.
Here, proper means that the review is more than a comment.
What happens when changes are requested for a PR?
What happens when a PR is approved?
What happens when state or priority labels are changed?
What happens when adding
s: positive review
to a PR?Here, only reviews of someone else are considered which are more recent than any commit.
What happens when adding
s: needs work
to a PR?What happens when adding
s: needs review
to a PR?What happens when adding
s: needs info
?What happens when adding a state label to an issue?
What happens when removing a state label from a PR?
Nothing happens when a state label is removed from an issue.
What happens when adding a priority label?
What happens when removing a priority label?
📝 Checklist
⌛ Dependencies