Cache action pin resolutions in memory across workflow compilations#3688
Cache action pin resolutions in memory across workflow compilations#3688
Conversation
- Add actionCache and actionResolver fields to Compiler struct - Implement getSharedActionResolver() to lazily initialize shared cache - Update ParseWorkflowFile to use shared cache instead of creating new ones - Add tests to verify cache is shared across multiple workflow compilations This change ensures that when compiling multiple workflows, the same action@version is resolved only once, with subsequent lookups using the in-memory cache. This significantly reduces GitHub API calls during compilation. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements in-memory caching of action pin resolutions across workflow compilations by moving the ActionCache and ActionResolver from per-workflow instances to shared compiler-level instances. This optimization significantly reduces GitHub API calls when compiling multiple workflows that use common actions.
Key changes:
- Added
actionCacheandactionResolverfields to theCompilerstruct for sharing across all workflows - Implemented lazy initialization via
getSharedActionResolver()to create cache/resolver on first use - Updated
ParseWorkflowFile()to reuse shared cache instances instead of creating new ones per workflow
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/workflow/compiler.go | Added shared cache fields to Compiler struct and implemented lazy initialization method; updated ParseWorkflowFile to use shared instances instead of creating new ones |
| pkg/workflow/compiler_shared_cache_test.go | Added comprehensive tests verifying cache instance sharing and persistence across multiple workflow compilations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot there is still a lot of checking for udpates using |
Add GetSharedActionCache() method to expose compiler's shared cache. Update validation functions to use shared cache instead of creating new ActionCache instances for each workflow. This ensures action SHA validation benefits from cached resolutions, eliminating redundant GitHub API queries during make recompile. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
... Fixed in commit d828378. The issue was that action SHA validation was creating a new With the fix, you should see cache hits during |
The action pin resolver created a new cache per workflow, causing repeated GitHub API queries for identical action@version pairs during
make recompile.Changes
Moved cache to compiler level
actionCacheandactionResolverfields toCompilerstructgetSharedActionResolver()ParseWorkflowFileto reuse shared instancesGetSharedActionCache()public method to expose shared cacheBefore:
After:
Impact
With 77 workflows using common actions:
actions/checkout@v5resolved once instead of 77 timesactions/upload-artifact@v5shows 11+ cache hits in logsEnable with
DEBUG=workflow:action_resolver,workflow:action_sha_checkerto observe cache behavior in both compilation and validation phases.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.