Skip to content

Commit fea58ce

Browse files
benkeenBen Keen
andauthored
Bridge cache fix and adding cache key to terminal logs (#5341)
Co-authored-by: Ben Keen <benkeen@microsoft.com>
1 parent 80d2436 commit fea58ce

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Fix to allow Bridge Cache plugin be installed but not used when build cache disabled; add cache key to terminal logs",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

rush-plugins/rush-bridge-cache-plugin/src/BridgeCachePlugin.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,17 @@ export class BridgeCachePlugin implements IRushPlugin {
8383
): Promise<void> => {
8484
const { buildCacheConfiguration } = context;
8585
const { terminal } = logger;
86+
87+
if (cacheAction === undefined) {
88+
return;
89+
}
90+
8691
if (!buildCacheConfiguration?.buildCacheEnabled) {
8792
throw new Error(
8893
`The build cache must be enabled to use the "${this._actionParameterName}" parameter.`
8994
);
9095
}
9196

92-
if (cacheAction === undefined) {
93-
return;
94-
}
95-
9697
const filteredOperations: Set<IOperationExecutionResult> = new Set();
9798
for (const operationExecutionResult of recordByOperation.values()) {
9899
if (!operationExecutionResult.operation.isNoOp) {
@@ -122,6 +123,7 @@ export class BridgeCachePlugin implements IRushPlugin {
122123
terminal.writeLine(
123124
`Operation "${operation.name}": Outputs have been restored from the build cache."`
124125
);
126+
terminal.writeLine(`Cache key: ${projectBuildCache.cacheId}`);
125127
} else {
126128
terminal.writeWarningLine(
127129
`Operation "${operation.name}": Outputs could not be restored from the build cache.`
@@ -155,6 +157,7 @@ export class BridgeCachePlugin implements IRushPlugin {
155157
terminal.writeLine(
156158
`Operation "${operation.name}": Existing outputs have been successfully written to the build cache."`
157159
);
160+
terminal.writeLine(`Cache key: ${projectBuildCache.cacheId}`);
158161
} else {
159162
terminal.writeErrorLine(
160163
`Operation "${operation.name}": An error occurred while writing existing outputs to the build cache.`
@@ -179,6 +182,7 @@ export class BridgeCachePlugin implements IRushPlugin {
179182
const cacheActionParameter: CommandLineParameter | undefined = context.customParameters.get(
180183
this._actionParameterName
181184
);
185+
182186
if (cacheActionParameter) {
183187
if (cacheActionParameter.kind !== CommandLineParameterKind.Choice) {
184188
throw new Error(

0 commit comments

Comments
 (0)