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

Add multi-repo collection #4

Merged
merged 1 commit into from
Mar 1, 2024
Merged
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
21 changes: 11 additions & 10 deletions collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ func (c *Collector) Run(ctx context.Context) {
defer func() { log.Print("Collector finished: ", ctx.Err()) }()

for ; ctx.Err() == nil; time.Sleep(c.cfg.Sleep) {
// TODO: loop over repos
if err := c.collectRepo(ctx, c.cfg.Repos[0]); err != nil {
log.Print(err)
for _, repo := range c.cfg.Repos {
if err := c.collectRepo(ctx, repo); err != nil {
log.Print(err)
}
}
}
}

func (c *Collector) collectRepo(ctx context.Context, repo string) error {
log.Printf("Collecting repo: %s", repo)
defer func() { log.Printf("Completed collecting repo: %s", repo) }()
log.Printf("Started collecting repo: %s", repo)
defer func() { log.Printf("Finished collecting repo: %s", repo) }()

// Recreate client on demand after errors and on startup
if c.client == nil {
Expand Down Expand Up @@ -156,20 +157,20 @@ func (c *Collector) collectRun(ctx context.Context, repo string, run *github.Wor
// Ignore runs without a created timestamp
case run.CreatedAt.Before(cutoff):
cutoff = run.CreatedAt.Time
log.Printf("Incomplete run: %d: %s (new cutoff: %v)",
run.GetID(), run.GetName(), cutoff)
log.Printf("open: %s/%d: %s (new cutoff: %v)",
repo, run.GetID(), run.GetName(), cutoff)
default:
log.Printf("Incomplete run: %d: %s", run.GetID(), run.GetName())
log.Printf("open: %s/%d: %s", repo, run.GetID(), run.GetName())
}
case c.seenRuns[run.GetID()]:
log.Printf("Ignoring seen run: %d: %s", run.GetID(), run.GetName())
log.Printf("seen: %s/%d: %s", repo, run.GetID(), run.GetName())
default:
if !ignoreCompleted {
err = c.collectJobs(ctx, repo, run)
}
if err == nil {
c.seenRuns[run.GetID()] = true
log.Printf("Completed: %d: %s\n", run.GetID(), run.GetName())
log.Printf("done: %s/%d: %s\n", repo, run.GetID(), run.GetName())
}
}

Expand Down
Loading