3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2026-01-19 02:39:01 +00:00

better defaults

This commit is contained in:
Cyril Rohr 2024-02-15 16:00:07 +00:00
parent 8f9e839eda
commit ede15a2f5d
No known key found for this signature in database
GPG key ID: 4F06363B8C22B3B9
13 changed files with 86 additions and 254 deletions

View file

@ -31,6 +31,13 @@ const region =
process.env.AWS_REGION ||
process.env.AWS_DEFAULT_REGION;
const uploadQueueSize = Number(process.env.UPLOAD_QUEUE_SIZE || "4");
const uploadPartSize =
Number(process.env.UPLOAD_PART_SIZE || "32") * 1024 * 1024;
const downloadQueueSize = Number(process.env.DOWNLOAD_QUEUE_SIZE || "8");
const downloadPartSize =
Number(process.env.DOWNLOAD_PART_SIZE || "16") * 1024 * 1024;
export function getCacheVersion(
paths: string[],
compressionMethod?: CompressionMethod,
@ -140,12 +147,12 @@ export async function downloadCache(
const url = await getSignedUrl(s3Client, command, {
expiresIn: 3600
});
const downloadOptions = getDownloadOptions({
await downloadCacheHttpClientConcurrent(url, archivePath, {
...options,
downloadConcurrency: 14,
concurrentBlobDownloads: true
downloadConcurrency: downloadQueueSize,
concurrentBlobDownloads: true,
partSize: downloadPartSize
});
await downloadCacheHttpClientConcurrent(url, archivePath, downloadOptions);
}
export async function saveCache(
@ -176,12 +183,10 @@ export async function saveCache(
Key: s3Key,
Body: createReadStream(archivePath)
},
// Part size in bytes
partSize: 32 * 1024 * 1024,
partSize: uploadPartSize,
// Max concurrency
queueSize: 14
queueSize: uploadQueueSize
});
// Commit Cache
@ -192,9 +197,10 @@ export async function saveCache(
)} MB (${cacheSize} B)`
);
const totalParts = Math.ceil(cacheSize / uploadPartSize);
core.info(`Uploading cache from ${archivePath} to ${bucketName}/${s3Key}`);
multipartUpload.on("httpUploadProgress", progress => {
core.info(`Uploaded ${progress.part}/${progress.total}.`);
core.info(`Uploaded part ${progress.part}/${totalParts}.`);
});
await multipartUpload.done();