Skip to content

Commit

Permalink
chore(build): set cache read/write based on build type (#6852)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Jan 29, 2025
1 parent 9ad490a commit ba2cc5d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions scripts/turbo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 {
Expand Down

0 comments on commit ba2cc5d

Please # to comment.