Skip to content

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
Copy link

github-actions bot commented Oct 3, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants