From ba2cc5d707d52e52a77667fe4352e7ddf4505e5d Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 28 Jan 2025 19:55:07 -0500 Subject: [PATCH] chore(build): set cache read/write based on build type (#6852) --- scripts/turbo/index.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/turbo/index.js b/scripts/turbo/index.js index a7d539c5be64..8d488adc7ccf 100644 --- a/scripts/turbo/index.js +++ b/scripts/turbo/index.js @@ -4,7 +4,22 @@ const path = require("path"); const runTurbo = async (task, args, { apiSecret, apiEndpoint, apiSignatureKey } = {}) => { const command = ["turbo", "run", task, "--concurrency=100%", "--output-logs=hash-only"]; + + const cacheReadWriteKey = process.env.AWS_JSV3_TURBO_CACHE_BUILD_TYPE ?? "dev"; + + const cacheReadWrite = { + // Release is remote write-only. + // Every release has unique artifacts and should not read from the cache. + RELEASE: "--cache=local:,remote:w", + // preview is remote read/write + PREVIEW: "--cache=local:,remote:rw", + // dev is local read/write and remote read-only + dev: "--cache=local:rw,remote:r", + }; + + command.push(cacheReadWrite[cacheReadWriteKey]); command.push(...args); + const turboRoot = path.join(__dirname, "..", ".."); const turboEnv = { @@ -18,9 +33,6 @@ const runTurbo = async (task, args, { apiSecret, apiEndpoint, apiSignatureKey } TURBO_TOKEN: apiSecret, TURBO_TEAM: "aws-sdk-js", }), - ...(!process.env.CODEBUILD_BUILD_ARN && { - TURBO_REMOTE_CACHE_READ_ONLY: "1", - }), }; try {