From 391089567ef1a205326ea3ac103afe859f6b362b Mon Sep 17 00:00:00 2001 From: Shawna Monero <66325812+smonero@users.noreply.github.com> Date: Tue, 7 May 2024 08:48:12 -0700 Subject: [PATCH] put automated PRs in slow queue (#753) --- server/neptune/lyft/activities/github.go | 18 ++++++++++++++++-- .../lyft/workflows/prrevision/workflow.go | 4 ++-- .../workflows/activities/github/pull.go | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/server/neptune/lyft/activities/github.go b/server/neptune/lyft/activities/github.go index 8d1dcaac0..c9ee83ae7 100644 --- a/server/neptune/lyft/activities/github.go +++ b/server/neptune/lyft/activities/github.go @@ -44,9 +44,11 @@ func (a *Github) GithubListPRs(ctx context.Context, request ListPRsRequest) (Lis pullRequests := []internal.PullRequest{} for _, pullRequest := range prs { + isAutomated := IsPRAutomated(pullRequest) pullRequests = append(pullRequests, internal.PullRequest{ - Number: pullRequest.GetNumber(), - UpdatedAt: pullRequest.GetUpdatedAt(), + Number: pullRequest.GetNumber(), + UpdatedAt: pullRequest.GetUpdatedAt(), + IsAutomatedPR: isAutomated, }) } @@ -55,6 +57,18 @@ func (a *Github) GithubListPRs(ctx context.Context, request ListPRsRequest) (Lis }, nil } +func IsPRAutomated(pr *github.PullRequest) bool { + if pr == nil || len(pr.Labels) == 0 { + return false + } + for _, label := range pr.Labels { + if label.GetName() == "automated" { + return true + } + } + return false +} + type ListModifiedFilesRequest struct { Repo internal.Repo PullRequest internal.PullRequest diff --git a/server/neptune/lyft/workflows/prrevision/workflow.go b/server/neptune/lyft/workflows/prrevision/workflow.go index 404a66cf1..a73b7e139 100644 --- a/server/neptune/lyft/workflows/prrevision/workflow.go +++ b/server/neptune/lyft/workflows/prrevision/workflow.go @@ -132,8 +132,8 @@ func (r *Runner) listModifiedFilesAsync(ctx workflow.Context, req Request, prs [ oldPRCounter := r.Scope.SubScope("open_prs").Counter(fmt.Sprintf("more_than_%d_days", r.SlowProcessingCutOffDays)) newPRCounter := r.Scope.SubScope("open_prs").Counter(fmt.Sprintf("less_than_%d_days", r.SlowProcessingCutOffDays)) for _, pr := range prs { - // schedule on slow tq if pr is not updated within x days - if !r.isPrUpdatedWithinDays(ctx, pr, r.SlowProcessingCutOffDays) { + // schedule on slow tq if pr is not updated within x days, or if its an automated PR (aka refactorator PR, a PR with the label "automated") + if !r.isPrUpdatedWithinDays(ctx, pr, r.SlowProcessingCutOffDays) || pr.IsAutomatedPR { options := workflow.GetActivityOptions(ctx) options.TaskQueue = SlowTaskQueue ctx = workflow.WithActivityOptions(ctx, options) diff --git a/server/neptune/workflows/activities/github/pull.go b/server/neptune/workflows/activities/github/pull.go index b20628833..a25a909a5 100644 --- a/server/neptune/workflows/activities/github/pull.go +++ b/server/neptune/workflows/activities/github/pull.go @@ -8,6 +8,8 @@ import ( type PullRequest struct { Number int UpdatedAt time.Time + // Whether the PR has a label of "automated" or not, useful for identifying refactorator PRs + IsAutomatedPR bool } type PullRequestState string