Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"type": "none",
"packageName": "@microsoft/rush"
}
],
"packageName": "@microsoft/rush",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Add a new \"omitAppleDoubleFilesFromBuildCache\" experiment. When enabled, the Rush build cache will omit macOS AppleDouble metadata files (._*) from cache archives when a companion file exists in the same directory. This prevents platform-specific metadata files from polluting the shared build cache. The filtering only applies when running on macOS.",
"comment": "Add a new \"omitAppleDoubleFilesFromBuildCache\" experiment. When enabled, the Rush build cache will omit macOS AppleDouble metadata files (._*) from cache archives when a companion file exists in the same directory. This prevents platform-specific metadata files from polluting the shared build cache. The exclusion only applies when running on macOS.",
"type": "none"
}
],
Expand Down
2 changes: 1 addition & 1 deletion common/reviews/api/rush-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ export interface _INpmOptionsJson extends IPackageManagerOptionsJsonBase {
// @internal (undocumented)
export interface _IOperationBuildCacheOptions {
buildCacheConfiguration: BuildCacheConfiguration;
filterAppleDoubleFiles: boolean;
excludeAppleDoubleFiles: boolean;
terminal: ITerminal;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export class PhasedScriptAction extends BaseScriptAction<IPhasedCommandConfig> i
buildCacheConfiguration,
cobuildConfiguration,
terminal,
filterAppleDoubleFiles:
excludeAppleDoubleFiles:
!!this.rushConfiguration.experimentsConfiguration.configuration
.omitAppleDoubleFilesFromBuildCache
}).apply(this.hooks);
Expand Down
18 changes: 9 additions & 9 deletions libraries/rush-lib/src/logic/buildCache/OperationBuildCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface IOperationBuildCacheOptions {
* If true, omit AppleDouble (`._*`) files from cache archives when running on macOS
* and a companion file exists in the same directory.
*/
filterAppleDoubleFiles: boolean;
excludeAppleDoubleFiles: boolean;
}

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ export class OperationBuildCache {
private readonly _cacheWriteEnabled: boolean;
private readonly _projectOutputFolderNames: ReadonlyArray<string>;
private readonly _cacheId: string | undefined;
private readonly _filterAppleDoubleFiles: boolean;
private readonly _excludeAppleDoubleFiles: boolean;

private constructor(cacheId: string | undefined, options: IProjectBuildCacheOptions) {
const {
Expand All @@ -86,7 +86,7 @@ export class OperationBuildCache {
},
project,
projectOutputFolderNames,
filterAppleDoubleFiles
excludeAppleDoubleFiles
} = options;
this._project = project;
this._localBuildCacheProvider = localCacheProvider;
Expand All @@ -95,7 +95,7 @@ export class OperationBuildCache {
this._cacheWriteEnabled = cacheWriteEnabled;
this._projectOutputFolderNames = projectOutputFolderNames || [];
this._cacheId = cacheId;
this._filterAppleDoubleFiles = filterAppleDoubleFiles && process.platform === 'darwin';
this._excludeAppleDoubleFiles = excludeAppleDoubleFiles && process.platform === 'darwin';
}

private static _tryGetTarUtility(terminal: ITerminal): Promise<TarExecutable | undefined> {
Expand All @@ -119,7 +119,7 @@ export class OperationBuildCache {
executionResult: IOperationExecutionResult,
options: IOperationBuildCacheOptions
): OperationBuildCache {
const { buildCacheConfiguration, terminal, filterAppleDoubleFiles } = options;
const { buildCacheConfiguration, terminal, excludeAppleDoubleFiles } = options;
const outputFolders: string[] = [...(executionResult.operation.settings?.outputFolderNames ?? [])];
if (executionResult.metadataFolderPath) {
outputFolders.push(executionResult.metadataFolderPath);
Expand All @@ -132,7 +132,7 @@ export class OperationBuildCache {
phaseName: executionResult.operation.associatedPhase.name,
projectOutputFolderNames: outputFolders,
operationStateHash: executionResult.getStateHash(),
filterAppleDoubleFiles
excludeAppleDoubleFiles
};
const cacheId: string | undefined = OperationBuildCache._getCacheId(buildCacheOptions);
return new OperationBuildCache(cacheId, buildCacheOptions);
Expand Down Expand Up @@ -352,14 +352,14 @@ export class OperationBuildCache {
const filteredOutputFolderNames: string[] = [];

let hasSymbolicLinks: boolean = false;
const filterAppleDoubleFiles: boolean = this._filterAppleDoubleFiles;
const excludeAppleDoubleFiles: boolean = this._excludeAppleDoubleFiles;

// Adds child directories to the queue, files to the path list, and bails on symlinks
function processChildren(relativePath: string, diskPath: string, children: FolderItem[]): void {
// When filtering AppleDouble files, build a set of sibling names so we can check
// When excluding AppleDouble files, build a set of sibling names so we can check
// whether a companion file exists for each ._X file.
let childNameSet: Set<string> | undefined;
if (filterAppleDoubleFiles) {
if (excludeAppleDoubleFiles) {
childNameSet = new Set<string>(children.map(({ name }) => name));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface ITestOptions {
enabled: boolean;
writeAllowed: boolean;
trackedProjectFiles: string[] | undefined;
filterAppleDoubleFiles: boolean;
excludeAppleDoubleFiles: boolean;
}

function createFolderItem(name: string, type: 'file' | 'directory' | 'symlink'): FolderItem {
Expand Down Expand Up @@ -59,7 +59,7 @@ describe(OperationBuildCache.name, () => {
operationStateHash: '1926f30e8ed24cb47be89aea39e7efd70fcda075',
terminal,
phaseName: 'build',
filterAppleDoubleFiles: !!options.filterAppleDoubleFiles
excludeAppleDoubleFiles: !!options.excludeAppleDoubleFiles
});

return subject;
Expand All @@ -74,7 +74,7 @@ describe(OperationBuildCache.name, () => {
});
});

describe('AppleDouble file filtering', () => {
describe('AppleDouble file exclusion', () => {
const originalPlatform: NodeJS.Platform = process.platform;

afterEach(() => {
Expand All @@ -85,7 +85,7 @@ describe(OperationBuildCache.name, () => {
it('omits AppleDouble files with companions when enabled on macOS', async () => {
Object.defineProperty(process, 'platform', { value: 'darwin' });

const subject: OperationBuildCache = prepareSubject({ filterAppleDoubleFiles: true });
const subject: OperationBuildCache = prepareSubject({ excludeAppleDoubleFiles: true });

jest
.spyOn(FileSystem, 'readFolderItemsAsync')
Expand All @@ -111,7 +111,7 @@ describe(OperationBuildCache.name, () => {
it('keeps AppleDouble files without companion files', async () => {
Object.defineProperty(process, 'platform', { value: 'darwin' });

const subject: OperationBuildCache = prepareSubject({ filterAppleDoubleFiles: true });
const subject: OperationBuildCache = prepareSubject({ excludeAppleDoubleFiles: true });

jest
.spyOn(FileSystem, 'readFolderItemsAsync')
Expand All @@ -127,10 +127,10 @@ describe(OperationBuildCache.name, () => {
expect(result!.outputFilePaths).toEqual(['dist/._orphan.txt', 'dist/other.js']);
});

it('does not filter AppleDouble files when the experiment is disabled', async () => {
it('does not exclude AppleDouble files when the experiment is disabled', async () => {
Object.defineProperty(process, 'platform', { value: 'darwin' });

const subject: OperationBuildCache = prepareSubject({ filterAppleDoubleFiles: false });
const subject: OperationBuildCache = prepareSubject({ excludeAppleDoubleFiles: false });

jest
.spyOn(FileSystem, 'readFolderItemsAsync')
Expand All @@ -146,10 +146,10 @@ describe(OperationBuildCache.name, () => {
expect(result!.outputFilePaths).toEqual(['dist/._foo.txt', 'dist/foo.txt']);
});

it('does not filter AppleDouble files on non-macOS platforms', async () => {
it('does not exclude AppleDouble files on non-macOS platforms', async () => {
Object.defineProperty(process, 'platform', { value: 'win32' });

const subject: OperationBuildCache = prepareSubject({ filterAppleDoubleFiles: true });
const subject: OperationBuildCache = prepareSubject({ excludeAppleDoubleFiles: true });

jest
.spyOn(FileSystem, 'readFolderItemsAsync')
Expand All @@ -165,10 +165,10 @@ describe(OperationBuildCache.name, () => {
expect(result!.outputFilePaths).toEqual(['dist/._foo.txt', 'dist/foo.txt']);
});

it('does not filter files named exactly "._"', async () => {
it('does not exclude files named exactly "._"', async () => {
Object.defineProperty(process, 'platform', { value: 'darwin' });

const subject: OperationBuildCache = prepareSubject({ filterAppleDoubleFiles: true });
const subject: OperationBuildCache = prepareSubject({ excludeAppleDoubleFiles: true });

jest
.spyOn(FileSystem, 'readFolderItemsAsync')
Expand All @@ -184,10 +184,10 @@ describe(OperationBuildCache.name, () => {
expect(result!.outputFilePaths).toEqual(['dist/._', 'dist/other.txt']);
});

it('filters AppleDouble files in nested directories', async () => {
it('excludes AppleDouble files in nested directories', async () => {
Object.defineProperty(process, 'platform', { value: 'darwin' });

const subject: OperationBuildCache = prepareSubject({ filterAppleDoubleFiles: true });
const subject: OperationBuildCache = prepareSubject({ excludeAppleDoubleFiles: true });

// First call returns the top-level dist/ contents with a subdirectory
// Second call returns the subdirectory contents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ export interface ICacheableOperationPluginOptions {
buildCacheConfiguration: BuildCacheConfiguration;
cobuildConfiguration: CobuildConfiguration | undefined;
terminal: ITerminal;
filterAppleDoubleFiles: boolean;
excludeAppleDoubleFiles: boolean;
}

interface ITryGetOperationBuildCacheOptionsBase<TRecord> {
buildCacheContext: IOperationBuildCacheContext;
buildCacheConfiguration: BuildCacheConfiguration | undefined;
terminal: ITerminal;
filterAppleDoubleFiles: boolean;
excludeAppleDoubleFiles: boolean;
record: TRecord;
}

Expand All @@ -108,7 +108,7 @@ export class CacheableOperationPlugin implements IPhasedCommandPlugin {
allowWarningsInSuccessfulBuild,
buildCacheConfiguration,
cobuildConfiguration,
filterAppleDoubleFiles
excludeAppleDoubleFiles
} = this._options;

hooks.beforeExecuteOperations.tap(
Expand Down Expand Up @@ -272,7 +272,7 @@ export class CacheableOperationPlugin implements IPhasedCommandPlugin {
buildCacheConfiguration,
terminal: buildCacheTerminal,
record,
filterAppleDoubleFiles
excludeAppleDoubleFiles
});

// Try to acquire the cobuild lock
Expand All @@ -291,7 +291,7 @@ export class CacheableOperationPlugin implements IPhasedCommandPlugin {
buildCacheContext,
record,
terminal: buildCacheTerminal,
filterAppleDoubleFiles
excludeAppleDoubleFiles
});
if (operationBuildCache) {
buildCacheTerminal.writeVerboseLine(
Expand Down Expand Up @@ -585,7 +585,7 @@ export class CacheableOperationPlugin implements IPhasedCommandPlugin {
private _tryGetOperationBuildCache(
options: ITryGetOperationBuildCacheOptions
): OperationBuildCache | undefined {
const { buildCacheConfiguration, buildCacheContext, terminal, record, filterAppleDoubleFiles } = options;
const { buildCacheConfiguration, buildCacheContext, terminal, record, excludeAppleDoubleFiles } = options;
if (!buildCacheContext.operationBuildCache) {
const { cacheDisabledReason } = buildCacheContext;
if (cacheDisabledReason && !record.operation.settings?.allowCobuildWithoutCache) {
Expand All @@ -601,7 +601,7 @@ export class CacheableOperationPlugin implements IPhasedCommandPlugin {
buildCacheContext.operationBuildCache = OperationBuildCache.forOperation(record, {
buildCacheConfiguration,
terminal,
filterAppleDoubleFiles
excludeAppleDoubleFiles
});
}

Expand All @@ -618,7 +618,7 @@ export class CacheableOperationPlugin implements IPhasedCommandPlugin {
cobuildConfiguration,
record,
terminal,
filterAppleDoubleFiles
excludeAppleDoubleFiles
} = options;

if (!buildCacheConfiguration?.buildCacheEnabled) {
Expand Down Expand Up @@ -649,7 +649,7 @@ export class CacheableOperationPlugin implements IPhasedCommandPlugin {
terminal,
operationStateHash,
phaseName: associatedPhase.name,
filterAppleDoubleFiles
excludeAppleDoubleFiles
});

buildCacheContext.operationBuildCache = operationBuildCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class BridgeCachePlugin implements IRushPlugin {
{
buildCacheConfiguration,
terminal,
filterAppleDoubleFiles: !!omitAppleDoubleFilesFromBuildCache
excludeAppleDoubleFiles: !!omitAppleDoubleFilesFromBuildCache
}
);

Expand Down