Skip to content

Commit

Permalink
chore(turbo): updated Turbo version
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaiah Hall committed Aug 5, 2024
1 parent 6f4fc4a commit 0de2971
Show file tree
Hide file tree
Showing 4 changed files with 1,805 additions and 1,828 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"bootstrap": "yarn",
"bootstrap:ci": "yarn install --frozen-lockfile",
"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:crypto-dependencies": "node ./scripts/turbo build -f=@aws-sdk/types... -f=@aws-sdk/util-utf8... -f=@aws-sdk/util-locate-window... -f=@aws-sdk/hash-node...",
"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-*...",
"build:protocols": "yarn build:crypto-dependencies && node ./scripts/turbo build -f=@aws-sdk/aws-protocoltests-*...",
"build:server-protocols": "yarn build:crypto-dependencies && node ./scripts/turbo build -f=@aws-sdk/*-server...",
"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: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-*...",
"build:protocols": "yarn build:crypto-dependencies && node ./scripts/turbo build -F=@aws-sdk/aws-protocoltests-*...",
"build:server-protocols": "yarn build:crypto-dependencies && node ./scripts/turbo build -F=@aws-sdk/*-server...",
"build:types:downlevel": "node --es-module-specifier-resolution=node ./scripts/downlevel-dts",
"clean": "yarn clear-build-cache && yarn clear-build-info && lerna clean",
"clear-build-docs": "rimraf ./clients/*/docs/ ./dist/docs/clients/*/docs/ ./clientDocs",
Expand Down
47 changes: 32 additions & 15 deletions scripts/turbo/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,51 @@
const { SecretsManagerClient, GetSecretValueCommand } = require("@aws-sdk/client-secrets-manager");
const fs = require("fs");
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;
}
const partialArn = `arn:aws:secretsmanager:us-west-2:${account}:secret:${secretName}`;
const secretsManager = new SecretsManagerClient({ region: "us-west-2" });
const command = new GetSecretValueCommand({ partialArn });
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;
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) => {
const command = ["turbo", "run", task];
let command = ["turbo", "run", task];
if (apiSecret && apiEndpoint) {
command = command.concat([
`--api="${apiEndpoint}"`,
`--team="aws-sdk-js"`,
`--api=${apiEndpoint}`,
`--team=aws-sdk-js`,
`--token=${apiSecret}`,
"--concurrency=100%",
]);
}
command = command.concat(args);
console.info("Running:", "npx turbo run ", task);
await spawnProcess("npx", command, { stdio: "inherit" });
return;
const turboRoot = path.join(__dirname, "..", "..");
try {
return spawnProcess("npx", command, { stdio: "inherit", cwd: turboRoot });
} catch (error) {
console.error("Error running turbo:", error);
}
};

const main = async () => {
Expand All @@ -38,10 +55,10 @@ const main = async () => {
const args = process.argv.slice(2);

if (!apiSecret || !apiEndpoint) {
runTurbo(args[0], args.slice[1]);
await runTurbo(args[0], args.slice(1));
} else {
await runTurbo(args[0], args.slice(1), apiSecret, apiEndpoint);
}

runTurbo(args[0], args.slice[1], apiSecret, apiEndpoint);
};

main();
6 changes: 6 additions & 0 deletions scripts/turbo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"@aws-sdk/client-secrets-manager": "^3.623.0"
}
}
Loading

0 comments on commit 0de2971

Please sign in to comment.