Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Add PR review reminder DAG #553

Merged
merged 15 commits into from
Jun 23, 2022
Merged

Add PR review reminder DAG #553

merged 15 commits into from
Jun 23, 2022

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented Jun 9, 2022

Fixes

Fixes WordPress/openverse#1540 by @zackkrida

Description

Adds a new DAG to run daily and get PR review reminders.

Testing Instructions

Checkout this PR locally, add a GitHub PAT with access to the relevant repositories, and do a dry run to check if it will ping as expected.

Also check out the unit tests.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@openverse-bot openverse-bot added this to In progress in Openverse PRs Jun 9, 2022
@openverse-bot openverse-bot added 🟧 priority: high Stalls work on the project or its dependents 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Jun 9, 2022
@sarayourfriend sarayourfriend changed the title [WIP] Add PR review reminder DAG Add PR review reminder DAG Jun 15, 2022
@sarayourfriend sarayourfriend marked this pull request as ready for review June 15, 2022 21:57
@sarayourfriend sarayourfriend requested a review from a team as a code owner June 15, 2022 21:57
@openverse-bot openverse-bot moved this from In progress to Needs review in Openverse PRs Jun 15, 2022
return Urgency("low", 5)


def days_without_weekends(today: datetime, delta: timedelta) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be super cool if we could also get the AFK status here...

The DAG does not ping on Saturday and Sunday and accounts for weekend days
when determining how much time has passed since the review.

Unfortunately the DAG does not know when someone is on vacation. It is up to the
Copy link
Contributor

Choose a reason for hiding this comment

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

The answer to my comment above is here :)

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

This will be a great addition to our workflow!

Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

This is awesome!! I'm very excited to have this as part of our workflow 🚀

I'm not sure how to test the other stuff as it all depends on GitHub responses. I could record some of them but it's a real pain without setting up infrastructure for that.

I think that's a solid idea, it's what we do for the provider API script tests: https://github.com/WordPress/openverse-catalog/tree/main/tests/dags/providers/provider_api_scripts/resources.

env.template Outdated Show resolved Hide resolved
openverse_catalog/dags/common/github.py Outdated Show resolved Hide resolved
openverse_catalog/dags/common/github.py Outdated Show resolved Hide resolved
openverse_catalog/dags/common/pr_review_reminders.py Outdated Show resolved Hide resolved
openverse_catalog/dags/common/pr_review_reminders.py Outdated Show resolved Hide resolved
openverse_catalog/dags/common/pr_review_reminders.py Outdated Show resolved Hide resolved
openverse_catalog/dags/common/pr_review_reminders.py Outdated Show resolved Hide resolved
openverse_catalog/dags/maintenance/pr_review_reminders.py Outdated Show resolved Hide resolved
openverse_catalog/dags/maintenance/pr_review_reminders.py Outdated Show resolved Hide resolved
openverse_catalog/dags/maintenance/pr_review_reminders.py Outdated Show resolved Hide resolved
@AetherUnbound
Copy link
Contributor

One more point I noticed while looking over this again - currently this is the structure:

common/
    github.py
    pr_review_reminders.py
maintenance/
    pr_review_reminders.py

The common directory is great for functions/classes/etc that we're likely to reuse, but I think it'd be best to keep operational code that's specific to a DAG as close to the DAG as possible. @stacimc and I discussed this a bit recently with the updated provider DAG factory. The following would probably work great, as it follows some other conventions we have:

common/
    github.py
maintenance/
    pr_review_reminders/    
        pr_review_reminders.py
        pr_review_reminders_dag.py  # or pr_review_reminders_workflow.py

What do you think? This puts the PR review specific code next to the DAG, since I think we're unlikely to reuse those functions in the same way we could reuse github.py.

@sarayourfriend
Copy link
Contributor Author

Thanks for the thorough review @AetherUnbound. This should be ready for another one now.

Comment on lines +21 to +30
class Urgency:
@dataclass
class Urgency:
label: str
days: int

CRITICAL = Urgency("critical", 1)
HIGH = Urgency("high", 2)
MEDIUM = Urgency("medium", 4)
LOW = Urgency("low", 5)
Copy link
Contributor Author

@sarayourfriend sarayourfriend Jun 23, 2022

Choose a reason for hiding this comment

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

It's kind of annoying that you can't reference a class within its own definition. I wish there was something like an enum that also allowed for complex, named values. This is probably the first time I've ever thought to myself "wow I really wish $x$ Java feature existed here" 😂

Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

Looks great! These tests are super thorough 🚀 Just a couple of requests/questions, nothing to stop a merge.

docker-compose.override.yml Show resolved Hide resolved
Now() manager patches datetime return a fixed, settable, value
(freezes time)

https://stackoverflow.com/a/28073449 CC BY-SA 3.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for including this!

_pr_count = 1


def make_pull(priority: Urgency, past_due: bool) -> dict:
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mind adding a docstring here describing what this function does? I'm having a hard time following everything it's referencing.


for label in pull["labels"]:
if "priority" in label["name"]:
label.update(**_make_label(priority))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this step necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use the priority label on the PR to determine the urgency of the PR, so we have to update the priority label in the pull.json fixture to have the configured urgency. This allows us to test all four urgency levels.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh! So it's replacing whatever's in the fixture with what you're using in the test, makes sense 💯

Openverse PRs automation moved this from Needs review to Reviewer approved Jun 23, 2022
@sarayourfriend sarayourfriend merged commit f5de3e2 into main Jun 23, 2022
Openverse PRs automation moved this from Reviewer approved to Merged! Jun 23, 2022
@sarayourfriend sarayourfriend deleted the add/pr-reviews-ping branch June 23, 2022 21:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟧 priority: high Stalls work on the project or its dependents
Projects
No open projects
Openverse PRs
  
Merged!
Development

Successfully merging this pull request may close these issues.

Airflow DAG to ping pull request reviewers
4 participants