Skip to content

perf: optimize release pagination with paginate.iterator() and early termination#93

Merged
joshjohanning merged 5 commits into
mainfrom
copilot/optimize-release-pagination
Apr 17, 2026
Merged

perf: optimize release pagination with paginate.iterator() and early termination#93
joshjohanning merged 5 commits into
mainfrom
copilot/optimize-release-pagination

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Release baseline selection fetched all release pages via octokit.paginate() before filtering. For repos with many releases, this means unnecessary API calls when the answer is typically on page 1.

Changes

  • src/index.js: Replace octokit.paginate() with octokit.paginate.iterator() — processes pages incrementally and breaks early when a page yields no better candidate than what we already have
  • __tests__/index.test.js: Add paginate.iterator mock + asyncPages async generator helper; update 5 release-related tests to use iterator mocks
  • package.json: Bump 3.1.0 → 3.1.1
let bestCandidate;
for await (const { data: page } of octokit.paginate.iterator(octokit.rest.repos.listReleases, { ... })) {
  let pageImprovedCandidate = false;
  for (const release of page) {
    const tag = release.tag_name;
    if (tag && semver.valid(tag) && semver.lt(tag, version)) {
      if (!bestCandidate || semver.lt(bestCandidate, tag)) {
        bestCandidate = tag;
        pageImprovedCandidate = true;
      }
    }
  }
  // GitHub returns releases newest-first; stop once a page doesn't improve our pick
  if (bestCandidate && !pageImprovedCandidate) break;
}

Short-circuit relies on GitHub's default newest-first ordering — if a page has candidates but none beat our current best, older pages won't either in the typical case.

Copilot AI and others added 2 commits April 16, 2026 02:23
Replace octokit.paginate() with octokit.paginate.iterator() for release
baseline selection. Processes pages one at a time and breaks early once
a candidate is found and a subsequent page yields no improvement.

Bump version to 3.1.1 (patch).

Agent-Logs-Url: https://github.com/joshjohanning/publish-github-action/sessions/03c9f543-69e7-4518-9ebb-84d8315725f2

Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com>
Copilot AI changed the title [WIP] Optimize short-circuit release pagination for baseline selection Optimize release pagination with paginate.iterator() and early termination Apr 16, 2026
Copilot AI requested a review from joshjohanning April 16, 2026 02:25
@joshjohanning joshjohanning marked this pull request as ready for review April 16, 2026 17:50
Copilot AI review requested due to automatic review settings April 16, 2026 17:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves release baseline selection performance in the Node.js GitHub Action by switching from fetching all release pages up front to iterating through release pages incrementally, aiming to reduce unnecessary GitHub API calls on repos with many releases.

Changes:

  • Update release baseline selection to use octokit.paginate.iterator() instead of octokit.paginate().
  • Update Jest tests to mock paginate.iterator() via an async generator helper.
  • Bump package version from 3.1.0 to 3.1.1 (and sync lockfile / coverage badge).
Show a summary per file
File Description
src/index.js Iterates release pages incrementally to find the best previous semver tag (adds early-termination logic).
__tests__/index.test.js Adds paginate.iterator mocking and updates release-baseline tests to use async page iteration.
package.json Version bump to 3.1.1.
package-lock.json Lockfile version sync to 3.1.1.
badges/coverage.svg Coverage badge updated to latest coverage percentage.

Copilot's findings

  • Files reviewed: 3/5 changed files
  • Comments generated: 2

Comment thread __tests__/index.test.js
Comment thread src/index.js
Validates that paginate.iterator() correctly finds the best
semver candidate across multiple pages with early termination.
@joshjohanning joshjohanning changed the title Optimize release pagination with paginate.iterator() and early termination feat: optimize release pagination with paginate.iterator() and early termination Apr 17, 2026
@joshjohanning joshjohanning changed the title feat: optimize release pagination with paginate.iterator() and early termination perf: optimize release pagination with paginate.iterator() and early termination Apr 17, 2026
@joshjohanning joshjohanning merged commit af6d48f into main Apr 17, 2026
4 checks passed
@joshjohanning joshjohanning deleted the copilot/optimize-release-pagination branch April 17, 2026 19:12
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.

Optimization: Short-circuit release pagination for baseline selection

3 participants