mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-10 19:50:30 +00:00
I have heard from some user that they have hundred thousands of `status=completed` workflow runs in their repository which effectively blocked TotalNumberOfQueuedAndInProgressWorkflowRuns from working because of GitHub API rate limit due to excessive paginated requests. This fixes that by separating list-workflow-runs calls to two - one for `queued` and one for `in_progress`, which can make the minimum API call from 1 to 2, but allows it to work regardless of number of remaining `completed` workflow runs.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package fake
|
|
|
|
import "net/http"
|
|
|
|
type FixedResponses struct {
|
|
ListRepositoryWorkflowRuns *Handler
|
|
ListWorkflowJobs *MapHandler
|
|
ListRunners http.Handler
|
|
}
|
|
|
|
type Option func(*ServerConfig)
|
|
|
|
func WithListRepositoryWorkflowRunsResponse(status int, body, queued, in_progress string) Option {
|
|
return func(c *ServerConfig) {
|
|
c.FixedResponses.ListRepositoryWorkflowRuns = &Handler{
|
|
Status: status,
|
|
Body: body,
|
|
Statuses: map[string]string{
|
|
"queued": queued,
|
|
"in_progress": in_progress,
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
func WithListWorkflowJobsResponse(status int, bodies map[int]string) Option {
|
|
return func(c *ServerConfig) {
|
|
c.FixedResponses.ListWorkflowJobs = &MapHandler{
|
|
Status: status,
|
|
Bodies: bodies,
|
|
}
|
|
}
|
|
}
|
|
|
|
func WithListRunnersResponse(status int, body string) Option {
|
|
return func(c *ServerConfig) {
|
|
c.FixedResponses.ListRunners = &ListRunnersHandler{
|
|
Status: status,
|
|
Body: body,
|
|
}
|
|
}
|
|
}
|
|
|
|
func WithFixedResponses(responses *FixedResponses) Option {
|
|
return func(c *ServerConfig) {
|
|
c.FixedResponses = responses
|
|
}
|
|
}
|