-
Notifications
You must be signed in to change notification settings - Fork 562
refactor(build-tools): unify glob and pattern matching libs #25996
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
base: main
Are you sure you want to change the base?
refactor(build-tools): unify glob and pattern matching libs #25996
Conversation
This change adds tests to reduce risk when implementing the glob library consolidation described in plans/dependency-reduction.md. Changes: - Extract globWithGitignore function from LeafTask for testability - Add comprehensive tests for globFn wrapper (nodir, dot, ignore, cwd, absolute options) - Add tests for globWithGitignore gitignore behavior - Add test data files for gitignore pattern testing The globWithGitignore function encapsulates the globby usage with gitignore support, making it easier to migrate to tinyglobby in the future. When migrating, only this function needs to change, and the tests will verify the behavior is preserved.
- Fix globPatterns.test.ts: Update glob pattern from *.js to *.mjs to match actual test file - Fix globPatterns.test.ts: Add beforeEach/afterEach hooks to dynamically create/cleanup gitignored test files - Fix canonicalizeChangesets.test.ts: Serialize git operations to avoid index.lock race conditions All 703 tests now passing.
- Replace glob and globby with tinyglobby in @fluidframework/build-tools - Replace globby with tinyglobby and add ignore for gitignore support in @fluid-tools/build-infrastructure - Replace globby with tinyglobby and minimatch with picomatch in @fluid-tools/build-cli - Update package.json dependencies for all affected packages - Add @types/picomatch dev dependency - All existing tests pass (only pre-existing environment-specific failures) Co-authored-by: tylerbutler <[email protected]>
- Rename import to createIgnore to avoid conflict with ignore option - Update comment about trailing slash removal to be more specific Co-authored-by: tylerbutler <[email protected]>
…ault - Add per-path caching for gitignore patterns in taskUtils.ts and workspaceCompat.ts - Add unit tests for getRunPolicyCheckDefault to verify picomatch integration Co-authored-by: tylerbutler <[email protected]>
Co-authored-by: tylerbutler <[email protected]>
Co-authored-by: tylerbutler <[email protected]>
# Conflicts: # build-tools/packages/build-tools/src/fluidBuild/tasks/taskUtils.ts # build-tools/packages/build-tools/src/test/data/glob/.gitignore # build-tools/packages/build-tools/src/test/globPatterns.test.ts # build-tools/pnpm-lock.yaml
build-tools/packages/build-infrastructure/src/workspaceCompat.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors glob and pattern matching libraries across the build-tools packages to consolidate on modern, lightweight alternatives. The changes replace glob, globby, and minimatch with tinyglobby and picomatch, while adding the ignore package for gitignore filtering functionality that was previously handled by globby.
Key changes:
- Migrate from
glob/globbytotinyglobbyfor file globbing operations - Replace
minimatchwithpicomatchfor pattern matching - Implement custom gitignore filtering using the
ignorepackage - Add pipeline configuration for test order randomization
- Include comprehensive tests for picomatch branch matching behavior
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| build-tools/pnpm-lock.yaml | Updates lockfile to reflect new dependencies (tinyglobby, picomatch, ignore) and removal of old ones (glob, globby, minimatch) |
| build-tools/packages/build-tools/package.json | Removes glob/globby dependencies, adds tinyglobby and ignore |
| build-tools/packages/build-tools/src/fluidBuild/tasks/taskUtils.ts | Refactors globFn and globWithGitignore to use tinyglobby; implements custom gitignore filtering with the ignore package; adds test randomization support |
| build-tools/packages/build-infrastructure/package.json | Replaces globby with tinyglobby and ignore |
| build-tools/packages/build-infrastructure/src/workspaceCompat.ts | Migrates from globby to tinyglobby with custom synchronous gitignore filtering |
| build-tools/packages/build-cli/package.json | Removes globby and minimatch, adds tinyglobby and picomatch with type definitions |
| build-tools/packages/build-cli/src/repoConfig.ts | Replaces minimatch with picomatch for branch pattern matching |
| build-tools/packages/build-cli/src/library/changesets.ts | Updates import from globby to tinyglobby for changeset file discovery |
| build-tools/packages/build-cli/src/commands/publish/tarballs.ts | Migrates from globby to tinyglobby for tarball file discovery |
| build-tools/packages/build-cli/src/test/library/repoConfig.test.ts | Adds comprehensive test coverage for picomatch-based branch pattern matching |
| tools/pipelines/build-client.yml | Adds FLUID_BUILD_TEST_RANDOM_ORDER environment variable to enable test order randomization for fluid-build |
Files not reviewed (1)
- build-tools/pnpm-lock.yaml: Language not supported
build-tools/packages/build-infrastructure/src/workspaceCompat.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-tools/src/fluidBuild/tasks/taskUtils.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-tools/src/fluidBuild/tasks/taskUtils.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-infrastructure/src/workspaceCompat.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-tools/src/fluidBuild/tasks/taskUtils.ts
Outdated
Show resolved
Hide resolved
build-tools/packages/build-infrastructure/src/workspaceCompat.ts
Outdated
Show resolved
Hide resolved
…structure Move gitignore filtering utilities to a shared module in build-infrastructure: - Create gitignore.ts with toPosixPath, filterByGitignore, filterByGitignoreSync, globWithGitignore, and clearGitignoreRuleSetsCache functions - Update workspaceCompat.ts to use the shared module - Add CJS build support via tsconfig.cjs.json and build:commonjs script - Add comments to build-tools explaining the duplication is needed because build-tools is CommonJS and cannot import from ESM-only build-infrastructure
…uild-tools - Change type alias to interface for GitignoreRuleSet (consistent-type-definitions) - Replace while(true) with for(;;) to avoid no-constant-condition errors - Reorder ternary to avoid negated condition (unicorn/no-negated-condition) - Replace @module with @packageDocumentation for valid TSDoc tag
Unifies glob and pattern matching libraries across build-tools:
glob,globby, andminimatchwithtinyglobbyandpicomatchignorepackage for gitignore filtering (tinyglobby doesn't support it directly)