Skip to content

Commit

Permalink
fix no workflow metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed May 13, 2024
1 parent dbfb412 commit 6f1eef8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions metrics_github_workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func (m *MetricsCollectorGithubWorkflows) getRepoList(org string) ([]*github.Rep
}

for {
m.Logger().Debugf(`fetching repository list with page "%d"`, opts.Page)

result, response, err := githubClient.Repositories.ListByOrg(m.Context(), org, &opts)
var ghRateLimitError *github.RateLimitError
if ok := errors.As(err, &ghRateLimitError); ok {
Expand Down Expand Up @@ -140,6 +142,8 @@ func (m *MetricsCollectorGithubWorkflows) getRepoWorkflows(org, repo string) ([]
opts := github.ListOptions{PerPage: 100, Page: 1}

for {
m.Logger().Debugf(`fetching workflows list for repo "%s" with page "%d"`, repo, opts.Page)

result, response, err := githubClient.Actions.ListWorkflows(m.Context(), org, repo, &opts)
var ghRateLimitError *github.RateLimitError
if ok := errors.As(err, &ghRateLimitError); ok {
Expand Down Expand Up @@ -209,8 +213,6 @@ func (m *MetricsCollectorGithubWorkflows) Collect(callback chan<- func()) {
}

for _, repo := range repositories {
var workflowRuns []*github.WorkflowRun

repositoryMetric.AddInfo(prometheus.Labels{
"org": org,
"repo": repo.GetName(),
Expand All @@ -237,7 +239,7 @@ func (m *MetricsCollectorGithubWorkflows) Collect(callback chan<- func()) {
})
}

if len(workflowRuns) >= 1 {
if len(workflows) >= 1 {
workflowRuns, err := m.getRepoWorkflowRuns(repo)
if err != nil {
panic(err)
Expand Down

0 comments on commit 6f1eef8

Please sign in to comment.