Skip to content

fix(164): Handling of pagination when >5 workflow dispatches happen #165

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

OscarVanL
Copy link

Fixes the handling of paginated responses by using octokit.paginate to follow all the paginated responses.

I expect you will have some comments, I admit I am not experienced with Typescript and have done my best.

To alleviate scaling/performance issues this would introduce on repositories with large numbers of workflow dispatches, the created filter is now used to only include workflow dispatches that happened since the dispatch-workflow action was started.

Justification of per_page query arg removal

I expect the original reason for setting the per_page value of 5 / 10 is because when not using the created timestamp filter in the API query we'd always get the last 30 workflow dispatches. This is a pretty big API response if you're polling the API. In most use-cases having this many values is redundant as most users will not be initiating many workflow dispatches in a short period.

Since making this change to add the created: >startTime filter, when the action first starts polling the API, it gets empty responses:

##[debug]Fetched Workflow Runs
##[debug]Repository: REDACTED
##[debug]Branch: main
##[debug]Runs Fetched: []

And when the API "catches up" to include the workflows we dispatched it then has only those workflows that were dispatched since the action started:

##[debug]Fetched Workflow Runs
##[debug]Repository: REDACTED
##[debug]Branch: main
##[debug]Runs Fetched: [14331544135,14331544132,14331544175,14331544174,14331544257,14331544318]

In this case, I think it is appropriate to move to the default page size (30). In most cases, the response will have far fewer values (most of the time, either 0 or 1 values) as the timestamp filter addresses the original need for the small page sizes. A larger page size better handles the use-case I described in my original issue: #164

…spatches are not missed.

Add filter for created timestamp to mitigate the potential for scaling issues (if we follow
all the API pages for all workflow dispatches in history, this will take longer and longer.
We only actually care about workflow dispatches since this action started).
…is is superceded by filtering by 'created'. Fixup tests
Comment on lines -14 to -15
export type WorkflowRunResponse = GetResponseTypeFromEndpointMethod<
typeof octokit.rest.actions.listWorkflowRuns
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect the typing here can probably be improved, but I'm not really sure what to put here.

Comment on lines -154 to -155
const workflowRuns: WorkflowRun[] = response.data.workflow_runs.map(
workflowRun => ({
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required because of the poor usage of type annotations for the paginated responses. Maybe there's something we can do better here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant