Skip to content

Commit

Permalink
Merge branch 'main' into feature/protected-branches
Browse files Browse the repository at this point in the history
  • Loading branch information
inferno-chromium committed Jan 5, 2021
2 parents 650fe0a + b506c6f commit 938b9f2
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions checks/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ import (
var lookbackDays int = 90

func init() {
registerCheck("Active", IsActive)
}

func IsActive(c checker.Checker) checker.CheckResult {
return checker.MultiCheck(
PeriodicCommits,
PeriodicReleases,
)(c)
registerCheck("Active", PeriodicCommits)
}

func PeriodicCommits(c checker.Checker) checker.CheckResult {
Expand All @@ -55,27 +48,6 @@ func PeriodicCommits(c checker.Checker) checker.CheckResult {
c.Logf("commits in last %d days: %d", lookbackDays, totalCommits)
return checker.CheckResult{
Pass: totalCommits >= 2,
Confidence: 7,
}
}

func PeriodicReleases(c checker.Checker) checker.CheckResult {
releases, _, err := c.Client.Repositories.ListReleases(c.Ctx, c.Owner, c.Repo, &github.ListOptions{})
if err != nil {
return checker.RetryResult(err)
}

tz, _ := time.LoadLocation("UTC")
threshold := time.Now().In(tz).AddDate(0, 0, -1*lookbackDays)
totalReleases := 0
for _, r := range releases {
if r.GetCreatedAt().After(threshold) {
totalReleases++
}
}
c.Logf("releases in last %d days: %d", lookbackDays, totalReleases)
return checker.CheckResult{
Pass: totalReleases > 0,
Confidence: 10,
}
}

0 comments on commit 938b9f2

Please sign in to comment.