Skip to content

Commit 2654b91

Browse files
committed
Add additional report data
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent afdf7ab commit 2654b91

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

main.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ func main() {
4949
totalJobs int
5050
totalPrivate int
5151
totalPublic int
52+
longestBuild time.Duration
53+
actors map[string]bool
5254
)
5355

56+
actors = make(map[string]bool)
57+
5458
fmt.Printf("Fetching last %d days of data (created>=%s)\n", since, created.Format("2006-01-02"))
5559

5660
var repos, allRepos []*github.Repository
@@ -154,6 +158,9 @@ func main() {
154158
log.Printf("Fetching jobs for: run ID: %d, startedAt: %s, conclusion: %s", run.GetID(), run.GetRunStartedAt().Format("2006-01-02 15:04:05"), run.GetConclusion())
155159
workflowJobs := []*github.WorkflowJob{}
156160

161+
if a := run.GetActor(); a != nil {
162+
actors[a.GetLogin()] = true
163+
}
157164
page := 0
158165
for {
159166
log.Printf("Fetching jobs for: %d, page %d", run.GetID(), page)
@@ -165,6 +172,13 @@ func main() {
165172
log.Fatal(err)
166173
}
167174

175+
for _, job := range jobs.Jobs {
176+
dur := job.GetCompletedAt().Time.Sub(job.GetStartedAt().Time)
177+
if dur > longestBuild {
178+
longestBuild = dur
179+
}
180+
}
181+
168182
workflowJobs = append(workflowJobs, jobs.Jobs...)
169183

170184
if len(jobs.Jobs) == 0 {
@@ -193,12 +207,18 @@ func main() {
193207
}
194208
}
195209

210+
fmt.Println("\nUsage report generated by self-actuated/actions-usage.\n")
196211
fmt.Printf("Total repos: %d\n", len(allRepos))
197212
fmt.Printf("Total private repos: %d\n", totalPrivate)
198213
fmt.Printf("Total public repos: %d\n", totalPublic)
199214
fmt.Println()
200215
fmt.Printf("Total workflow runs: %d\n", totalRuns)
201216
fmt.Printf("Total workflow jobs: %d\n", totalJobs)
217+
fmt.Println()
218+
fmt.Printf("Total users: %d\n", len(actors))
219+
fmt.Printf("Longest build: %s\n", longestBuild.Round(time.Second))
220+
fmt.Printf("Average build time: %s\n", (allUsage / time.Duration(totalJobs)).Round(time.Second))
221+
202222
mins := fmt.Sprintf("%.0f mins", allUsage.Minutes())
203223
fmt.Printf("Total usage: %s (%s)\n", allUsage.String(), mins)
204224
}

0 commit comments

Comments
 (0)