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

Optimize API calls #1033

Merged
merged 23 commits into from Jul 6, 2023
Merged

Optimize API calls #1033

merged 23 commits into from Jul 6, 2023

Conversation

dsame
Copy link
Contributor

@dsame dsame commented Jun 15, 2023

Description:

Each next run should not proceed the issues proceed during the previous run. In the other case running from the very beginning never reach the issues beyond API limit.

Changes:

  1. removed unnecessary extra call to getPullRequest API, this implied adding isDraft property and refactoring unit tests
  2. Introduced and implemented IState interface with persist, rehydrate and reset method
  • rehydrate is called before the processing
  • persist is called after the processing
  • reset when all the issues are processed and the next run should be started from the beginning
  1. Every issue is marked as processed with IState.isIssueProcessed method and it is skipped during the processing if IState.isIssueProcessed returns true for it

Implementation details:

  • getStateInstance introduced for mocking during testing
  • persistence implemented with @actions/http-client (to store state) and octokit (to remove state)

Related issue:
link to the related issue.

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

@dsame dsame force-pushed the apirate branch 2 times, most recently from 3e8b587 to 41108c8 Compare June 22, 2023 11:49
@dsame dsame force-pushed the apirate branch 2 times, most recently from c988721 to 6afea3f Compare June 22, 2023 12:25
@dsame dsame force-pushed the apirate branch 15 times, most recently from 46a9b53 to 6148637 Compare June 25, 2023 13:56
@dsame dsame force-pushed the apirate branch 9 times, most recently from 9f8d82d to 75127e6 Compare July 5, 2023 14:35
@dsame dsame force-pushed the apirate branch 2 times, most recently from a6c5bfe to dcfe49d Compare July 5, 2023 15:11
Copy link
Contributor

@dusan-trickovic dusan-trickovic left a comment

Choose a reason for hiding this comment

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

Everything looks alright to me :) Tested a workflow run using this branch and everything works error-free. The comments I left below are just nitpicks and can be ignored, as there are no problems present. Thank you!

src/classes/state/state-cache-storage.ts Show resolved Hide resolved
src/classes/state/state-cache-storage.ts Show resolved Hide resolved
@dsame dsame merged commit 465330b into actions:main Jul 6, 2023
8 checks passed
@dsame dsame linked an issue Jul 13, 2023 that may be closed by this pull request
5 tasks
Comment on lines +32 to +33
unprocessed issue skipping the issues proceeded during the previous run(s). The state is reset when all the issues are
proceeded. This should be considered for scheduling workflow runs.
Copy link

Choose a reason for hiding this comment

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

Typos in the readme:
s/proceeded/processed/g

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