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 0de2971 commit dd49fd2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 42 deletions.
23 changes: 18 additions & 5 deletions scripts/turbo/README.md
Original file line number Diff line number Diff line change
@@ -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 <Optional Turborepo Args>
```
35 changes: 4 additions & 31 deletions scripts/turbo/index.js
Original file line number Diff line number Diff line change
@@ -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%",
]);
Expand All @@ -49,8 +22,8 @@ const runTurbo = async (task, args, apiSecret, apiEndpoint) => {
};

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);

Expand Down
6 changes: 0 additions & 6 deletions scripts/turbo/package.json

This file was deleted.

0 comments on commit dd49fd2

Please sign in to comment.