Skip to content

Commit

Permalink
put automated PRs in slow queue (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
smonero authored May 7, 2024
1 parent 6229197 commit 3910895
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
18 changes: 16 additions & 2 deletions server/neptune/lyft/activities/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server/neptune/lyft/workflows/prrevision/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions server/neptune/workflows/activities/github/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3910895

Please sign in to comment.