From 34e8211b821ff368e7ea92da8416e52fd5564e68 Mon Sep 17 00:00:00 2001 From: Shawna Monero Date: Mon, 6 May 2024 16:21:21 -0700 Subject: [PATCH 1/3] put automatetd PRs in slow queeu --- server/neptune/lyft/activities/github.go | 20 +++++++++++++++++-- .../lyft/workflows/prrevision/workflow.go | 4 ++-- .../workflows/activities/github/pull.go | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/server/neptune/lyft/activities/github.go b/server/neptune/lyft/activities/github.go index 8d1dcaac0..fdac7f233 100644 --- a/server/neptune/lyft/activities/github.go +++ b/server/neptune/lyft/activities/github.go @@ -44,9 +44,13 @@ 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 +59,18 @@ func (a *Github) GithubListPRs(ctx context.Context, request ListPRsRequest) (Lis }, nil } +func IsPRAutomated(pr *github.PullRequest) bool { + if pr.Labels == nil { + 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 From 195426fc46af1f5f4e60c02847e314d54158fcc6 Mon Sep 17 00:00:00 2001 From: Shawna Monero Date: Mon, 6 May 2024 17:31:46 -0700 Subject: [PATCH 2/3] put automatetd PRs in slow queeu --- server/neptune/lyft/activities/github.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/neptune/lyft/activities/github.go b/server/neptune/lyft/activities/github.go index fdac7f233..cd21e32fd 100644 --- a/server/neptune/lyft/activities/github.go +++ b/server/neptune/lyft/activities/github.go @@ -44,9 +44,7 @@ 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(), From b86811313dd2b05325867e2783f10edefbed6ebb Mon Sep 17 00:00:00 2001 From: Shawna Monero Date: Tue, 7 May 2024 08:21:16 -0700 Subject: [PATCH 3/3] addressing comment --- server/neptune/lyft/activities/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/neptune/lyft/activities/github.go b/server/neptune/lyft/activities/github.go index cd21e32fd..c9ee83ae7 100644 --- a/server/neptune/lyft/activities/github.go +++ b/server/neptune/lyft/activities/github.go @@ -58,7 +58,7 @@ func (a *Github) GithubListPRs(ctx context.Context, request ListPRsRequest) (Lis } func IsPRAutomated(pr *github.PullRequest) bool { - if pr.Labels == nil { + if pr == nil || len(pr.Labels) == 0 { return false } for _, label := range pr.Labels {