Skip to content

Commit

Permalink
Add apply checks filter (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayyush authored Jul 15, 2022
1 parent ad672cb commit cca4b5e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
12 changes: 9 additions & 3 deletions server/events/vcs/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package vcs

func NewPullMergeabilityChecker(commitStatusPrefix string) MergeabilityChecker {
statusFilters := newValidStatusFilters(commitStatusPrefix)
checksFilters := newValidChecksFilters()
checksFilters := newValidChecksFilters(commitStatusPrefix)

return &PullMergeabilityChecker{
supplementalChecker: newSupplementalMergeabilityChecker(statusFilters, checksFilters),
Expand All @@ -13,6 +13,8 @@ func NewPullMergeabilityChecker(commitStatusPrefix string) MergeabilityChecker {

func newValidStatusFilters(commitStatusPrefix string) []ValidStatusFilter {
titleMatcher := StatusTitleMatcher{TitlePrefix: commitStatusPrefix}

// TODO: Remove apply status filter after github checks is fully rolled out.
applyStatusFilter := &ApplyStatusFilter{
statusTitleMatcher: titleMatcher,
}
Expand All @@ -22,9 +24,13 @@ func newValidStatusFilters(commitStatusPrefix string) []ValidStatusFilter {
}
}

func newValidChecksFilters() []ValidChecksFilter {
func newValidChecksFilters(commitStatusPrefix string) []ValidChecksFilter {
titleMatcher := StatusTitleMatcher{TitlePrefix: commitStatusPrefix}
applyChecksFilter := &ApplyChecksFilter{
statusTitleMatcher: titleMatcher,
}
return []ValidChecksFilter{
SuccessConclusionFilter,
SuccessConclusionFilter, applyChecksFilter,
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/events/vcs/inject_lyft.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func NewLyftPullMergeabilityChecker(commitStatusPrefix string) MergeabilityCheck
statusFilters := newValidStatusFilters(commitStatusPrefix)

statusFilters = append(statusFilters, lyft.NewSQFilter())
checksFilters := newValidChecksFilters()
checksFilters := newValidChecksFilters(commitStatusPrefix)

supplementalChecker := newSupplementalMergeabilityChecker(statusFilters, checksFilters)
supplementalChecker = lyft.NewOwnersStatusChecker(supplementalChecker)
Expand Down
18 changes: 18 additions & 0 deletions server/events/vcs/mergeability.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ type ValidChecksFilter interface {
Filter(status []*github.CheckRun) []*github.CheckRun
}

// ApplyChecksFilter filters statuses that correspond to atlantis apply
type ApplyChecksFilter struct {
statusTitleMatcher StatusTitleMatcher
}

func (d ApplyChecksFilter) Filter(checks []*github.CheckRun) []*github.CheckRun {
var filtered []*github.CheckRun
for _, check := range checks {
if d.statusTitleMatcher.MatchesCommand(*check.Name, "apply") {
continue
}

filtered = append(filtered, check)
}

return filtered
}

// ConclusionFilter filters checks that match a given conclusion
type ConclusionFilter string

Expand Down

0 comments on commit cca4b5e

Please sign in to comment.