@actions/cache: optional S3 storage backend for self-hosted runners
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 28/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- aws, typescript
Direzione di ricerca
Start by reading the @actions/cache implementation and the related discussion in actions/cache#679; the issue names no specific source files or tests. The proposed first step is to move the existing v1 and v2 implementations behind CacheBackend without changing behavior. Done means maintainers agree with the direction; implementing S3 and its tests are later, separate steps.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the enhancement
Add an optional S3 storage backend to @actions/cache. The runner administrator turns it on with environment variables on the runner. Without them, nothing changes: the library keeps using the v1 or v2 cache service exactly as today.
On self-hosted runners in AWS, every cache restore and save goes to Azure Blob over the internet. That traffic leaves through a NAT gateway and is billed per GB. A large monorepo restoring 0.3–1.7 GB per job across hundreds of jobs a day turns into terabytes of NAT traffic, for data that could sit in a bucket in the same region and be read over a free S3 gateway endpoint.
Teams solve this today by forking actions/cache (runs-on/cache, tespkg/actions-cache, itchyny/s3-cache-action) or by running a cache server and binary-patching the runner to redirect ACTIONS_RESULTS_URL. The forks only cover workflows that switch uses: to the fork, so setup-* actions and anything else built on @actions/cache stays on the hosted service. None of the forks keep the hosted service's branch scoping, so any job holding the bucket credentials can overwrite the default branch's cache.
Related: #1051, actions/cache#679, #1695.
How the design answers the concerns raised in actions/cache#679
- "It should be a repo/org level setting and not a workflow setting." The backend is configured only through environment variables on the runner (
ACTIONS_CACHE_S3_BUCKET,ACTIONS_CACHE_S3_REGION, optionalACTIONS_CACHE_S3_PREFIXandACTIONS_CACHE_S3_ENDPOINT). There are no action inputs, so a workflow author can't redirect caches. It only applies to runners the administrator controls. - "How is the custom cache server endpoint secured?" No custom server is involved, and the runtime token is never sent anywhere new. The backend talks to S3 over HTTPS through the standard AWS SDK credential chain (instance role, IRSA, or credentials from
aws-actions/configure-aws-credentialswith GitHub OIDC). Access is governed by the bucket's IAM policy. - Cache management experience. Entries in S3 don't appear in the repository's cache UI or API. The bucket owner manages them, with a lifecycle rule for expiry. We'd document that limitation clearly.
Behaviour
- Object keys are
<prefix>/<owner>/<repo>/<ref>/<version>/<key>, whereversionis the existinggetCacheVersion()value, so compression method and cross-OS rules still apply. - Saves write only under the job's own ref. Restores look in the job's ref, then
GITHUB_BASE_REF, then the default branch, matching the hosted service's scoping. Since the ref is part of the object path, IAM can enforce it. For example, only a role trusted forref:refs/heads/mainmayPutObjectunder…/refs/heads/main/*. - Exact keys resolve with
HeadObject. Restore keys resolve by prefix withListObjectsV2, and the newest match wins. ACTIONS_CACHE_MODE,lookupOnly,CacheReadDeniedErrorandCacheWriteDeniedErrorkeep their current semantics. An S3AccessDeniedmaps to the matching denied error.- Uploads are multipart and parallel. Downloads use parallel ranged GETs.
- The AWS SDK is loaded lazily, only when the backend is configured.
Code Snippet
Runner environment, set by the administrator:
ACTIONS_CACHE_S3_BUCKET=my-runner-cache
ACTIONS_CACHE_S3_REGION=us-east-1
Library seam (first PR, no behaviour change):
export interface CacheBackend {
isAvailable(): boolean
restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions, enableCrossOsArchive?: boolean): Promise<string | undefined>
saveCache(paths: string[], key: string, options?: UploadOptions, enableCrossOsArchive?: boolean): Promise<number>
}
Additional information
Proposed sequence, each a separate PR:
- Refactor only: move the existing v1 and v2 implementations behind
CacheBackend, with no behaviour or public API change. A branch is ready to open if you're open to the direction. - Add the S3 backend with unit tests (mocked S3 client), including tests that the scoping matches the hosted service.
- In
actions/cache: bump@actions/cache, document the backend, and add an end-to-end workflow against a MinIO service container.
Per CONTRIBUTING, we'd like agreement on the direction before opening 2 and 3, and we're happy to write an ADR. Questions for maintainers:
- Is an administrator-configured S3 backend something you'd accept in
@actions/cache, or would you rather keep the library hosted-service-only? - If yes, is the extra dependency (
@aws-sdk/client-s3,@aws-sdk/lib-storage), loaded lazily, acceptable, or would you prefer the backend as a separate package that registers itself?
- Lingua principale
- TypeScript
- Stelle
- 5.9k
- Fork
- 1.8k
- Merge medio
- 15m
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di actions/toolkit
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
@actions/io: `mv(file, dest)` replaces `dest` when it is a symlink to a directory instead of moving into itForse già presa @bardrop l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
@actions/exec: `exec(commandLine)` drops `""` arguments and trims trailing spaces of the last argumentForse già presa @bardrop l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
actions/toolkit#2565 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di actions/toolkit
Issue simili
-
db-d1-sqlite: upsert is aliased to updateOne, so payload.kv.set never inserts new keysForse già presa @pcbeingused333 l’ha presa oggi. ApertaBug db: d1-sqlite Payload OSS
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
payloadcms/payload#19766 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
device-management-toolkit/sample-web-ui#3711 ·
I maintainer di solito rispondono entro 1 giorno
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
elastic/kibana#306401 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
agentes-chat/agentes-chat#927 ·
I maintainer di solito rispondono entro 1 giorno
-
Closing a pinned tab jumps to the Tabs section instead of the next open pinned tabForse già presa @seenimohamed l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ardia-browser/ardia#2769 ·
I maintainer di solito rispondono entro 1 giorno