Skip to content

feat(injector): add package-filter join point with glob patterns and module filtering#675

Merged
RomainMuller merged 7 commits into
mainfrom
kakkoyun/add_package_filter
Sep 19, 2025
Merged

feat(injector): add package-filter join point with glob patterns and module filtering#675
RomainMuller merged 7 commits into
mainfrom
kakkoyun/add_package_filter

Conversation

@kakkoyun

@kakkoyun kakkoyun commented Aug 8, 2025

Copy link
Copy Markdown
Member

Add new "package-filter" join point that supports:

  • Glob pattern matching with all patterns supported by path.Match
  • Globstar (**) support for recursive matching across path segments
  • Special "*" pattern for universal matching
  • Module filtering with "root" for current module only
  • Specific module targeting (e.g., "github.com/myorg/mymodule")
  • Relative path matching within modules for precise filtering

Globstar Examples:

  • github.com/myorg/** - matches any package under myorg at any depth
  • **/internal/* - matches internal packages anywhere in dependency tree
  • github.com/myorg/**/api/** - complex nested pattern matching

Signed-off-by: Kemal Akkoyun [email protected]

@kakkoyun
kakkoyun requested a review from a team as a code owner August 8, 2025 13:24
@github-actions github-actions Bot added the conventional-commit/feat Feature work label Aug 8, 2025
Comment thread internal/injector/aspect/join/package_test.go Outdated
Comment thread internal/goenv/goenv.go Outdated
Comment thread internal/injector/aspect/join/package.go
Comment thread internal/injector/aspect/join/package.go Outdated
Comment thread internal/injector/aspect/join/package.go Outdated
Comment thread internal/injector/aspect/join/package_test.go Outdated
@kakkoyun
kakkoyun marked this pull request as draft August 8, 2025 14:12
Comment thread internal/injector/aspect/join/package_test.go
@kakkoyun
kakkoyun force-pushed the kakkoyun/add_package_filter branch from 9fa684d to 82c2037 Compare September 1, 2025 11:43
@kakkoyun
kakkoyun marked this pull request as ready for review September 1, 2025 14:02
@kakkoyun
kakkoyun requested a review from eliottness September 2, 2025 13:04
@kakkoyun
kakkoyun force-pushed the kakkoyun/add_package_filter branch from 36d164c to 2b1296f Compare September 11, 2025 11:12
@kakkoyun
kakkoyun marked this pull request as draft September 11, 2025 15:26
…module filtering

Add new "package-filter" join point that supports:
- Glob pattern matching with all patterns supported by https://pkg.go.dev/path/filepath#Match
- Special "*" pattern for universal matching
- Module filtering with "root" for current module only
- Specific module targeting (e.g., "github.com/myorg/mymodule")
- Relative path matching within modules for precise filtering

Signed-off-by: Kemal Akkoyun <[email protected]>
- Simplify packageFilter to use boolean root flag instead of separate module field
- Update tests and test data to use new boolean parameter
- Add test case for question mark not matching across path separators
- Replace shell-based module detection with golang.org/x/tools/go/packages API
- Consolidate documentation in public PackageFilter function
@kakkoyun
kakkoyun force-pushed the kakkoyun/add_package_filter branch from e37b244 to 8a8d393 Compare September 12, 2025 13:47
@kakkoyun
kakkoyun marked this pull request as ready for review September 12, 2025 15:26
@eliottness
eliottness removed their request for review September 16, 2025 08:54
Comment thread internal/goenv/goenv.go Outdated
Comment thread internal/goenv/goenv.go Outdated
Comment thread internal/goenv/goenv.go Outdated
Comment thread internal/injector/aspect/join/package_test.go
Comment thread internal/injector/aspect/join/package_test.go
Comment thread internal/injector/aspect/join/package_test.go
Comment thread internal/injector/aspect/join/package_test.go
- join-point:
all-of:
- package-filter:
root: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little uncertain about what the intention of this primitive is -- like what is the concrete use-case this seeks to address? If that's touching on the main package -- there is already a join point that does this (package: main).

I don't know that Go has a concept of a "root" module, it has a concept of a "module root path", but this is not the same thing...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little uncertain about what the intention of this primitive is -- like what is the concrete use-case this seeks to address? If that's touching on the main package -- there is already a join point that does this (package: main).

It's not just the main package. We try to aim the user code and exclude any 3rd party dependencies or standard library.

I don't know that Go has a concept of a "root" module, it has a concept of a "module root path", but this is not the same thing...

I'd be happy to accept better wording if you have any suggestions to define above use case.

Comment thread internal/injector/aspect/join/package.go
@kakkoyun
kakkoyun force-pushed the kakkoyun/add_package_filter branch from 3fdf146 to 9ba33b0 Compare September 19, 2025 09:22
Signed-off-by: Kemal Akkoyun <[email protected]>
@kakkoyun
kakkoyun force-pushed the kakkoyun/add_package_filter branch from 9ba33b0 to 999e94f Compare September 19, 2025 10:25
@RomainMuller
RomainMuller added this pull request to the merge queue Sep 19, 2025
Merged via the queue into main with commit 8c104e0 Sep 19, 2025
57 checks passed
@RomainMuller
RomainMuller deleted the kakkoyun/add_package_filter branch September 19, 2025 13:46
@codecov

codecov Bot commented Sep 19, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.12195% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.70%. Comparing base (e061d12) to head (999e94f).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
internal/injector/aspect/join/package.go 76.92% 33 Missing and 6 partials ⚠️
internal/goenv/goenv.go 66.66% 8 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #675      +/-   ##
==========================================
- Coverage   65.72%   65.70%   -0.02%     
==========================================
  Files         113      114       +1     
  Lines        7926     8245     +319     
==========================================
+ Hits         5209     5417     +208     
- Misses       2192     2293     +101     
- Partials      525      535      +10     
Components Coverage Δ
Generators 80.24% <ø> (ø)
Instruments ∅ <ø> (∅)
Go Driver 75.96% <66.66%> (+0.15%) ⬆️
Toolexec Driver 67.94% <100.00%> (+0.41%) ⬆️
Aspects 72.38% <77.05%> (+0.46%) ⬆️
Injector 73.05% <77.05%> (+0.25%) ⬆️
Job Server 65.91% <ø> (ø)
Other 65.70% <60.64%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
internal/goenv/goenv.go 69.38% <66.66%> (-7.54%) ⬇️
internal/injector/aspect/join/package.go 77.35% <76.92%> (-1.72%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants