Skip to content

perf: resolve atmos versions with less GitHub API calls - #116

Open
Jochem Lugtenburg (jochem725) wants to merge 1 commit into
cloudposse:mainfrom
jochem725:reduce-github-api-calls
Open

perf: resolve atmos versions with less GitHub API calls#116
Jochem Lugtenburg (jochem725) wants to merge 1 commit into
cloudposse:mainfrom
jochem725:reduce-github-api-calls

Conversation

@jochem725

Copy link
Copy Markdown

what

This aims to reduce the number of calls to Github by:

  • getAtmos: for an exact version, probe the tool cache before any network call.
  • getMatchingVersion: resolve exact versions via getReleaseByTag and latest via getLatestRelease (1 call each), each falling back to enumeration on a miss.
  • resolveFromReleaseList: paginate the range/fallback path newest-first with per_page 100 and stop as soon as a match is found.

why

Version resolution paginates the entire cloudposse/atmos release list on every job, even when the tool cache is used. When running drift-detection in large projects this quickly runs into Github rate limits with a large number of calls per job.

references

N/A

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dfe1fa90-6afd-4169-81e9-2bb07f1b8476

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

Atmos release resolution

Layer / File(s) Summary
Targeted release lookup and fallback
src/installer.ts, src/__tests__/setup-atmos.test.ts
The installer uses exact-tag and latest-release requests before paginated fallback. Tests cover caching, pagination, 404 handling, non-404 errors, and architecture fallback.
Cache-aware installation
src/installer.ts, src/__tests__/setup-atmos.test.ts
The installer checks exact-version caches before GitHub requests and centralizes cached-tool handling.
Integration version matrix
.github/workflows/main.yml
The integration workflow tests latest and pinned version 1.224.1, then verifies the pinned resolved version.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: reducing GitHub API calls during Atmos version resolution.
Description check ✅ Passed The description directly explains the API call reductions, implementation areas, motivation, and fallback behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/__tests__/setup-atmos.test.ts (2)

98-112: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move the ARM release fixture.

githubReleaseArm is a GitHub API response fixture. Put it under src/__fixtures__/ and import it into this suite.

As per coding guidelines, place related fixtures under src/__fixtures__/.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/__tests__/setup-atmos.test.ts` around lines 98 - 112, Move the
githubReleaseArm fixture out of setup-atmos.test.ts into the shared
src/__fixtures__ location, export it from the fixture module, and import it into
the test suite where it is used. Preserve the fixture’s current values and
structure.

Source: Coding guidelines


29-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use nock for the GitHub release API responses.

jest.mock("octokit") replaces the module used by createOctokit, so these tests only exercise local method calls. Use nock with the available nock/jest-nock dependency to mock the tagged, latest, and paginated release requests, and include afterEach(() => nock.cleanAll()) around the matching tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/__tests__/setup-atmos.test.ts` around lines 29 - 35, Replace the octokit
method mocks in the affected tests with nock interceptors for the tagged,
latest, and paginated GitHub release API requests used by createOctokit.
Configure each response to match the expected request and add afterEach(() =>
nock.cleanAll()) around these tests to remove interceptors between cases.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/__tests__/setup-atmos.test.ts`:
- Around line 98-112: Move the githubReleaseArm fixture out of
setup-atmos.test.ts into the shared src/__fixtures__ location, export it from
the fixture module, and import it into the test suite where it is used. Preserve
the fixture’s current values and structure.
- Around line 29-35: Replace the octokit method mocks in the affected tests with
nock interceptors for the tagged, latest, and paginated GitHub release API
requests used by createOctokit. Configure each response to match the expected
request and add afterEach(() => nock.cleanAll()) around these tests to remove
interceptors between cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57e13b61-fc59-4c0f-9e55-fb9fb0d7e25b

📥 Commits

Reviewing files that changed from the base of the PR and between 89c34b2 and e858ba1.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (3)
  • .github/workflows/main.yml
  • src/__tests__/setup-atmos.test.ts
  • src/installer.ts

Version resolution paginated the entire cloudposse/atmos release list
(~29 requests) on every job, before checking the tool cache. At drift-scan
scale this exhausts the rate limit and trips GitHub's secondary/burst limit.

- getAtmos: for an exact version, probe the tool cache before any network
  call (0 calls on a warm cache). Gated on semver.valid so ranges never
  match a stale cached version.
- getMatchingVersion: resolve exact versions via getReleaseByTag and `latest`
  via getLatestRelease (1 call each), each falling back to enumeration on a
  miss so resolution can never regress.
- resolveFromReleaseList: paginate the range/fallback path newest-first with
  per_page 100 and stop as soon as a match is found (~9 requests down to ~1).

Adds call-count and fallback tests; rebuilds dist.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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