diff --git a/package.json b/package.json index 38a8253c0383..7200cc112e19 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build:all": "yarn build:crypto-dependencies && node ./scripts/turbo build", "build:ci": "node ./scripts/turbo build -F=[origin/main...HEAD]...", "build:clients:generic": "node ./scripts/turbo build -F=@aws-sdk/aws-echo-service...", - "build:clients:since:release": "yarn build:packages && node ./scripts/turbo build $(lerna changed | grep -e '@aws-sdk/[client|lib]-*' | sed 's/^/ -F= /' | tr '\n' ' ')", + "build:clients:since:release": "yarn build:packages && node ./scripts/turbo build $(lerna changed | grep -e '@aws-sdk/[client|lib]-*' | sed 's/^/ -F=/' | tr '\n' ' ')", "build:crypto-dependencies": "node ./scripts/turbo build -F=@aws-sdk/types... -F=@aws-sdk/util-locate-window...", "build:e2e": "yarn build:crypto-dependencies && node ./scripts/turbo build -F=@aws-sdk/client-cloudformation... -F=@aws-sdk/karma-credential-loader... -F=@aws-sdk/client-s3-control... -F=@aws-sdk/client-sts...", "build:packages": "node ./scripts/turbo build -F=!@aws-sdk/client-*... -F=!@aws-sdk/aws-*... -F=!@aws-sdk/lib-*...", diff --git a/scripts/turbo/README.md b/scripts/turbo/README.md index 89f35ccd3a08..d112d5b23c42 100644 --- a/scripts/turbo/README.md +++ b/scripts/turbo/README.md @@ -1,9 +1,22 @@ -# This is a script for accessing the remote cache for Turbo build. +# Turbo Build Script -## Set the following environment variables to access the remote cache for turbo build +This script is designed to handle the execution of Turborepo builds, using the remote cache when env variables are present. -``` -AWS_JS3_TURBO_CACHE_API_SECRET +## Prerequisites + +Before running this script, ensure that you have installed dependencies with `yarn`. + +## Environment Variables + +To access the remote cache for Turborepo builds, you need to set the following environment variables: -AWS_JS3_TURBO_CACHE_API_ENDPOINT +- `AWS_JSV3_TURBO_CACHE_API_SECRET`: The API secret for authenticating with the remote cache. +- `AWS_JSV3_TURBO_CACHE_API_ENDPOINT`: The API endpoint for the remote cache. + +## Usage + +To run the Turborepo build, execute the following command: + +``` +node ./scripts/turbo build ``` diff --git a/scripts/turbo/index.js b/scripts/turbo/index.js index 69050bc84180..4f94ea262d93 100644 --- a/scripts/turbo/index.js +++ b/scripts/turbo/index.js @@ -1,40 +1,13 @@ -const fs = require("fs"); +// Build script to handle Turborepo build execution const { spawnProcess } = require("../utils/spawn-process"); const path = require("path"); -// Fetch Secrets In CI Environments -const fetchSecret = async (secretName) => { - const account = process.env.TURBO_CACHE_AWS_ACCOUNT_ID; - if (!account) { - return null; - } - try { - if (!fs.existsSync(path.join(__dirname, "node_modules/"))) { - await installDeps(); - } - const { SecretsManagerClient, GetSecretValueCommand } = require("@aws-sdk/client-secrets-manager"); - const partialArn = `arn:aws:secretsmanager:us-west-2:${account}:secret:${secretName}`; - const secretsManager = new SecretsManagerClient({ region: "us-west-2" }); - const command = new GetSecretValueCommand({ SecretId: partialArn }); - - const response = await secretsManager.send(command); - return response.SecretString; - } catch (error) { - console.error("Error fetching turbo remote cache secret:", error); - return null; - } -}; - -const installDeps = async () => { - return spawnProcess("npm", ["install"], { stdio: "inherit", cwd: __dirname }); -}; - const runTurbo = async (task, args, apiSecret, apiEndpoint) => { let command = ["turbo", "run", task]; if (apiSecret && apiEndpoint) { command = command.concat([ `--api=${apiEndpoint}`, - `--team=aws-sdk-js`, + "--team=aws-sdk-js", `--token=${apiSecret}`, "--concurrency=100%", ]); @@ -42,15 +15,15 @@ const runTurbo = async (task, args, apiSecret, apiEndpoint) => { command = command.concat(args); const turboRoot = path.join(__dirname, "..", ".."); try { - return spawnProcess("npx", command, { stdio: "inherit", cwd: turboRoot }); + return await spawnProcess("npx", command, { stdio: "inherit", cwd: turboRoot }); } catch (error) { console.error("Error running turbo:", error); } }; const main = async () => { - const apiSecret = process.env.AWS_JS3_TURBO_CACHE_API_SECRET || (await fetchSecret("TURBO_CACHE_API_SECRET")); - const apiEndpoint = process.env.AWS_JS3_TURBO_CACHE_API_ENDPOINT || (await fetchSecret("TURBO_CACHE_API_ENDPOINT")); + const apiSecret = process.env.AWS_JSV3_TURBO_CACHE_API_SECRET; + const apiEndpoint = process.env.AWS_JSV3_TURBO_CACHE_API_ENDPOINT; const args = process.argv.slice(2); diff --git a/scripts/turbo/package.json b/scripts/turbo/package.json deleted file mode 100644 index e8ecc91f5cc8..000000000000 --- a/scripts/turbo/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "@aws-sdk/client-secrets-manager": "^3.623.0" - } -}