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

put automated PRs in slow queue #753

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading