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

Don't make heavy API requests multiple times #945

Merged
merged 1 commit into from
Mar 8, 2025
Merged

Conversation

smorimoto
Copy link
Member

Closes #943

Signed-off-by: Sora Morimoto <sora@morimoto.io>
@smorimoto smorimoto requested a review from Copilot March 8, 2025 02:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR aims to avoid making heavy API requests multiple times by caching results at module load time. The key changes are:

  • Replacing function calls with immediately invoked async functions for fetching the OCaml compiler version, Cygwin version, and the latest opam release.
  • Removing redundant exports and updating references across multiple modules.
  • Ensuring consistency in how heavy API requests are handled across the codebase.

Reviewed Changes

File Description
packages/setup-ocaml/src/version.ts Changed to cache the resolved compiler using an async IIFE.
packages/setup-ocaml/src/windows.ts Updated to cache the Cygwin version using an async IIFE.
packages/setup-ocaml/src/constants.ts Removed the old RESOLVED_COMPILER export and refined OCAML_COMPILER input.
packages/setup-ocaml/src/cache.ts Updated to use the new cached compiler and Cygwin version values.
packages/setup-ocaml/src/installer.ts Replaced RESOLVED_COMPILER usage with resolvedCompiler from version.ts.
packages/setup-ocaml/src/opam.ts Replaced the function call with an async IIFE for latest opam release retrieval.

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

@smorimoto smorimoto merged commit 8ca4c46 into master Mar 8, 2025
18 checks passed
@smorimoto smorimoto deleted the reduce-api-calls branch March 8, 2025 03:04
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.

Action fails early on with failure about inability to find an opam version
1 participant