Skip to content

Add the labels flowchart to the README. #500

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

Merged
merged 4 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,40 @@ Labels PRs for documentation as `type-documentation`
- ### Copies main labels to backport
Copies labels from main PRs to backport PRs

## PR State Machine

This diagram represent the state machine for pull requests, and the labels
applied by Bedevere.

The colors represent who can make a state change or who is currently
blocking the PR from moving forward:
* Yellow: the PR creator
* Green: core developers
* Blue: anyone

<!--
Changes to the labels in this flowchart should be reflected
in the devguide: https://devguide.python.org/triage/labels/
-->

```mermaid
flowchart TD
A([New PR]):::creator
A -- by contributor --> B[Awaiting review]:::anyone
A -- by core dev --> C[Awaiting core review]:::coredev
B & C -- new review by\nanother contributor --> C
C & B & E -- new core review\nrequests changes --> D[Awaiting changes]:::creator
D -- changes by contributor --> E[Awaiting change review]:::coredev
C & E & B -- new core review\napproves ---> F[Awaiting merge]:::coredev
classDef creator stroke:#CC0;
classDef anyone stroke:#00C;
classDef coredev stroke:#0C0;
classDef triager stroke:#C0C;
linkStyle 0,1,7 stroke:#CC0,color:auto;
linkStyle 2,3 stroke:#00C,color:auto;
linkStyle 4,5,6,8,9,10 stroke:#0C0,color:auto;
```

## *Aside*: where does the name come from?
Since this bot is about identifying pull requests that need changes,
it seemed fitting to name it after Sir Bedevere who knew
Expand Down
42 changes: 6 additions & 36 deletions bedevere/stage.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,11 @@
"""Label a pull request based on what its waiting on."""

# The following is the state machine for the flow of a PR
# (written as a DOT file; you can use Graphviz or
# http://www.webgraphviz.com/ to view the graph):
"""
digraph "PR stages" {
/* Colours represent who can make a state change or who is currently
blocking the PR from moving forward.

Blue: Anyone
Orange: PR creator
Green: Core developer
Purple: Triager Actions
*/

"New PR" [color=orange]
"Awaiting review" [shape=box, color=blue]
"Awaiting core review" [shape=box, color=green]
"Awaiting changes" [shape=box, color=orange]
"Awaiting change review" [shape=box, color=green]
"Awaiting merge" [shape=box, color=green]

"New PR" -> "Awaiting review" [label="New PR by a contributor", color=orange]
"Awaiting review" -> "Awaiting core review" [label="New review by another contributor", color=blue]
"Awaiting core review" -> "Awaiting core review" [label="New review by another contributor", color=blue]
"Awaiting core review" -> "Awaiting changes" [label="New core review requests changes", color=green]
"Awaiting changes" -> "Awaiting change review" [label="Changes are done by contributor\nBedevere requests review from core-dev", color=orange]
"Awaiting change review" -> "Awaiting changes" [label="New core review requests changes", color=green]
"Awaiting change review" -> "Awaiting merge" [label="New core review approves", color=green]

"Awaiting review" -> "Awaiting merge" [label="New core review approves", color=green]
"Awaiting review" -> "Awaiting changes" [label="New core review requests changes", color=green]
"Awaiting core review" -> "Awaiting merge" [label="New core review approves", color=green]

"New PR" -> "Awaiting core review" [label="New PR by core devs", color=green]
}
"""
# The state machine for the flow of a PR is currently
# documented with a Mermaid graph in the README.
# The graph replaces a previous version (written as
# a DOT file) that was included here.
#
# Changes to this file should be reflected in the README.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line necessary?

I'm not even sure the comments are necessary. They are probably relevant now but in 6/12 months time they will probably just become dead weight. I would be okay with removing them as well, but I'll leave that decision to you!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The one about updating the README is important to ensure the graph in the README keeps matching the code (and in turn the comment in the README ensures the devguide is updated -- assuming people see the comments).

The one about the previous version is not particularly important, but without it someone might end up wasting time looking for that graph they once saw in the code. Having a couple of extra lines for this comment is not a big cost.


import datetime
import enum
Expand Down