actions / toolkit

The GitHub ToolKit for developing GitHub Actions.
https://github.com/features/actions
MIT License
4.94k stars 1.42k forks source link

Support storing and restoring cache entries as buffers. #1760

Open iclanton opened 3 months ago

iclanton commented 3 months ago

Describe the enhancement

The GitHub Actions cache feature currently only supports storing and restoring cache entries that point to files on disk. This works great for things like node_modules folders, and other kinds of data that are produced during an Actions run that are well-known to the pipeline definition, but works less well for build output in complex repos that doesn't follow as predictable a structure, or has structure that is difficult to model in a YAML pipeline.

The Rush monorepo manager has built-in support for caching build output, which is facilitated through plugins that store and retrieve NodeJS Buffers. Rush currently supports remote build cache storage on Azure Storage, Amazon S3, and providers that support generic HTTP operations like Gradle. I've put together a prototype (currently on a branch, not yet in a PR) Rush plugin that adds support for GitHub Actions, but it requires either duplicating a nontrivial amount of code in the @actions/cache package to directly call functions from the @actions/http-client package, or expanded APIs in the @actions/cache package.   Code Snippet

I've pushed a branch to my fork of this repo with proposed new APIs in the @actions/cache package. These are currently not exposed from the package's entrypoint. The contributing guide asks that PRs not be raised without prompting, so I haven't opened a PR.

iclanton commented 3 months ago

I went ahead an opened a PR with the proposed change: https://github.com/actions/toolkit/pull/1762