[rush-lib] Build Cache: Scoped packages are not uploaded to S3
Summary
When the build cache is configured with the "amazon-s3" cache provider, it fails to upload scoped packages to S3 since the @ sign breaks the S3 object name.
Repro steps
-
Create a scoped package in your monorepo, i.e.
@scope/package-name -
Configure
rush-project.json
{
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json",
"incrementalBuildIgnoredGlobs": ["temp/**"],
"operationSettings": [
{
"operationName": "build",
"outputFolderNames": ["dist", "lib"]
}
]
}
- Enable build caching in
common/config/rush/build-cache.json
"buildCacheEnabled": true,
"cacheProvider": "amazon-s3",
- Configure a cache entry name pattern
"cacheEntryNamePattern": "[phaseName:normalize]/[projectName:normalize]/[hash]",
- Export your AWS credentials
export RUSH_BUILD_CACHE_WRITE_ALLOWED=1
export RUSH_BUILD_CACHE_CREDENTIAL="aws_access_key_id:aws_secret_access_key"
- Run a task that is configured to cache
rush build --to @scope/package-name
Expected Result
[phaseName:normalize]/[projectName:normalize]/[hash] should create an S3 object, i.e. build/@scope+package-name/{hash}
Actual result
Error getting cache entry from S3: Error: Amazon S3 responded with status code 403 (Forbidden)
Details
The object creation on S3 fails due to the @ sign in the S3 object name.
We can fix this by stripping the @ sign from the default and normalized project name returned by libraries/rush-lib/src/logic/buildCache/CacheEntryId.ts.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
| Package name: | @microsoft/rush-lib |
| Package version? | 5.71.0 |
| Operating system? | Mac |
| Would you consider contributing a PR? | Yes |
Node.js version (node -v)? |
16.15.1 |