Skip to content
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

chore(pr-comments): generalization for triggering merged PR comments workflow #71039

Merged
merged 4 commits into from
Jul 19, 2024

Conversation

cathteng
Copy link
Member

@cathteng cathteng commented May 16, 2024

If we want to be able to have merged PR comments for SCMs other than GitHub, we'll need to generalize some of the flows. In this PR I generalize the flow to trigger the merged PR comments workflow.

  1. Check if the repo for the suspect commit has a provider that supports merged PR comments
  2. Move the custom logic needed to fetch the merge commit sha from the commit sha into the GitHub client, this can be repeated for other SCMs. We use this to find the PR associated with the merge commit sha in our db.

In a follow up PR, I will generalize the workflow itself.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 16, 2024
@cathteng cathteng changed the title chore(pr-comments): abstraction for triggering merged PR comments workflow chore(pr-comments): generalization for triggering merged PR comments workflow May 16, 2024
Copy link

codecov bot commented May 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.16%. Comparing base (028e402) to head (43f79bd).
Report is 148 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #71039      +/-   ##
==========================================
+ Coverage   78.13%   78.16%   +0.03%     
==========================================
  Files        6670     6672       +2     
  Lines      298465   298750     +285     
  Branches    51354    51427      +73     
==========================================
+ Hits       233212   233530     +318     
+ Misses      58993    58955      -38     
- Partials     6260     6265       +5     
Files Coverage Δ
src/sentry/integrations/github/client.py 83.42% <100.00%> (+0.43%) ⬆️
src/sentry/tasks/commit_context.py 98.38% <100.00%> (+2.32%) ⬆️

... and 107 files with indirect coverage changes

@cathteng cathteng marked this pull request as ready for review May 16, 2024 20:29
@cathteng cathteng requested review from a team as code owners May 16, 2024 20:29
@cathteng cathteng requested a review from a team May 16, 2024 20:29
@iamrajjoshi iamrajjoshi requested a review from a team May 21, 2024 19:13
src/sentry/integrations/github/client.py Show resolved Hide resolved
src/sentry/integrations/github/client.py Outdated Show resolved Hide resolved
src/sentry/integrations/github/client.py Outdated Show resolved Hide resolved
@getsantry
Copy link
Contributor

getsantry bot commented Jun 13, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jun 13, 2024
@cathteng cathteng removed the Stale label Jun 20, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Jul 12, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jul 12, 2024
@cathteng cathteng requested a review from a team July 16, 2024 17:25
@cathteng cathteng removed the Stale label Jul 16, 2024
@@ -48,6 +48,8 @@
PR_COMMENT_TASK_TTL = timedelta(minutes=5).total_seconds()
PR_COMMENT_WINDOW = 14 # days

PR_COMMENT_SUPPORTED_PROVIDERS = {"integrations:github"}
Copy link
Member Author

@cathteng cathteng Jul 16, 2024

Choose a reason for hiding this comment

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

when all SCMs have implemented the get_merge_commit_sha_from_commit function AND we have a generalized merged PR comment workflow, we can remove this

response = self.get_pullrequest_from_commit(repo, sha)
if not response or (isinstance(response, list) and len(response) != 1):
# the response should return a single merged PR, return if multiple
return None
Copy link
Member

Choose a reason for hiding this comment

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

What does it mean if we return on multiple? Should we be logging it?

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 response should return a single merged PR, return if multiple
return None

pull_request = response[0]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I like the idiom (pull_request,) = response because it communicates the expectation that the length is 1 and raises otherwise.

@cathteng cathteng merged commit df3499a into master Jul 19, 2024
50 checks passed
@cathteng cathteng deleted the cathy/merged-pr-comments/abstract-trigger-flow branch July 19, 2024 17:39
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants