Skip to content
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

chore: allow turbo remote cache write only on AWS Codebuild #6481

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Sep 16, 2024

Issue

Description

Allows Turborepo remote cache write only on AWS Codebuild.

This will ensure that any developments outside of CodeBuild environments, like developer workspaces, do not pollute the remote cache.

Testing

repository

Verified that updated local cache from developer workspace is not uploaded to remote cache.

$ make turbo-clean

$ yarn build:all
...
 Tasks:    473 successful, 473 total
Cached:    473 cached, 473 total
  Time:    25.822s >>> FULL TURBO

Done in 26.41s.

$ sed -i '$s/}/,  "foo":"bar"\n}/' clients/client-acm/package.json

$ git diff
diff --git a/clients/client-acm/package.json b/clients/client-acm/package.json
index 9651073052a..adec6dee759 100644
--- a/clients/client-acm/package.json
+++ b/clients/client-acm/package.json
@@ -99,4 +99,5 @@
     "url": "https://github.com/aws/aws-sdk-js-v3.git",
     "directory": "clients/client-acm"
   }
+,  "foo":"bar"
 }

$ yarn build:all
...
@aws-sdk/client-acm:build: cache miss, executing 9bea6a701716bcc5
 WARNING  Remote cache is read-only, skipping upload
...
 Tasks:    473 successful, 473 total
Cached:    472 cached, 473 total
  Time:    24.255s

It uses local cache on re-run

$ yarn build:all
...
 Tasks:    473 successful, 473 total
Cached:    473 cached, 473 total
  Time:    23.961s >>> FULL TURBO

Simulated by setting CODEBUILD_BUILD_ARN that Remote Cache will be populated

$ make turbo-clean

$ CODEBUILD_BUILD_ARN="blah" yarn build:all
...
@aws-sdk/client-acm:build: cache miss, executing 9bea6a701716bcc5
...
 Tasks:    473 successful, 473 total
Cached:    472 cached, 473 total
  Time:    24.657s 
...

$ make turbo-clean

$ yarn build:all
...
@aws-sdk/client-acm:build: cache hit, suppressing logs 9bea6a701716bcc5
...
 Tasks:    473 successful, 473 total
Cached:    473 cached, 473 total
  Time:    24.608s >>> FULL TURBO

node REPL

$ node
Welcome to Node.js v18.20.2.
Type ".help" for more information.
> obj = {...(!process.env.CODEBUILD_BUILD_ARN && { TURBO_REMOTE_CACHE_READ_ONLY: "1" })}
{ TURBO_REMOTE_CACHE_READ_ONLY: '1' }

$ CODEBUILD_BUILD_ARN="blah" node
Welcome to Node.js v18.20.2.
Type ".help" for more information.
> obj = {...(!process.env.CODEBUILD_BUILD_ARN && { TURBO_REMOTE_CACHE_READ_ONLY: "1" })}
{}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr requested a review from a team as a code owner September 16, 2024 20:42
@trivikr
Copy link
Member Author

trivikr commented Sep 16, 2024

Environment variables in build environments: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html

@trivikr trivikr merged commit 9b2dac1 into aws:main Sep 16, 2024
4 checks passed
@trivikr trivikr deleted the turbo-remote-cache-read-only branch September 16, 2024 21:50
RanVaknin pushed a commit to RanVaknin/aws-sdk-js-v3 that referenced this pull request Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants