Skip to content

chore(build): set cache read/write based on build type #6852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading