Skip to content

[CI] Add ListPackages and support nested package directories in dev tools#18543

Merged
mrodm merged 13 commits intoelastic:mainfrom
mrodm:allow-multiple-directories-dev-scripts
Apr 21, 2026
Merged

[CI] Add ListPackages and support nested package directories in dev tools#18543
mrodm merged 13 commits intoelastic:mainfrom
mrodm:allow-multiple-directories-dev-scripts

Conversation

@mrodm
Copy link
Copy Markdown
Collaborator

@mrodm mrodm commented Apr 21, 2026

Proposed commit message

Centralize package discovery logic in dev/citools and extend the codeowners and packagenames dev scripts to support packages stored in nested directory structures (e.g. packages/category/package-name/).

Important

Still pending to update the Buildkite scripts to allow testing packages located in nested directories.

WHAT:

  • dev/citools/packages.go (new): adds ListPackages(dir string) which
    walks a directory tree, identifies valid packages by their
    manifest.yml, and returns their sorted paths. A package is considered
    valid when its manifest contains a non-empty format_version, name,
    type, and version, with type being one of integration, input,
    or content. Discovery stops descending once a package root is found,
    so packages are never double-counted.
  • dev/citools/packagemanifest.go: exports ReadPackageManifest
    (previously private), extends packageManifest with FormatVersion,
    Type, and Version fields, and adds an IsValid() method.
  • dev/codeowners: refactors validatePackages to delegate discovery to
    citools.ListPackages, and introduces findOwnerForFile which walks
    up the directory tree to resolve ownership for packages nested more
    than one level deep. Fixes an infinite loop that occurred when an
    absolute path was passed to the owner lookup.
  • dev/packagenames: removes the local duplicate manifest.go and
    walkPackagePaths implementation, replacing both with calls to
    citools.ListPackages and citools.ReadPackageManifest.
  • magefile.go: adds a ListPackages mage target for inspection and
    debugging.

WHY:
The repository is adopting a two-level package layout (packages/<technology>/<package>) alongside the existing flat layout (packages/<package>). The previous implementations in codeowners and packagenames assumed a single, flat level and each maintained its own copy of manifest-reading logic. This change provides a single, tooling works correctly with either layout.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to
    guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Author's Checklist

  • dev/citools, dev/codeowners, and dev/packagenames unit tests pass locally.
  • The debug commit b077ed3 ("Test a subset of the packages - to be removed") is dropped before merge.

How to test this PR locally

# Run the citools and codeowners unit tests
go test ./dev/citools/... ./dev/codeowners/... ./dev/packagenames/...
mage -v check

# Inspect package discovery via the new mage target
mage ListPackages

For failures:

  • Nested package with no owner:
mkdir -p packages/other
cp -r packages/elastic_package_registry packages/other/
mage -v check
## This should fail with no owners
# Running dependency: github.com/elastic/integrations/dev/codeowners.Check
# Error: error validating packages in directory 'packages': error checking manifest 'packages/other/elastic_package_registry': there is no owner for "packages/other/elastic_package_registry" in ".github/CODEOWNERS"
  • Duplicated nested package
    • Following the same scenario as above
    • Update .github/CODEOWNERS to include the new entry
      --- .github/CODEOWNERS
      +++ .github/CODEOWNERS
      @@ -218,6 +218,7 @@
       /packages/elastic_agent @elastic/elastic-agent
       /packages/elastic_connectors @elastic/search-extract-and-transform
       /packages/elastic_package_registry @elastic/ecosystem
      +/packages/other/elastic_package_registry @elastic/ecosystem
       /packages/elastic_security @elastic/security-service-integrations
       /packages/elasticsearch @elastic/stack-monitoring
       /packages/aws_elb_otel @elastic/obs-infraobs-integrations
mage -v check
## This should fail with (duplicated package)
# Running dependency: github.com/elastic/integrations/dev/codeowners.Check
# Running dependency: github.com/elastic/integrations/dev/packagenames.Check
# Error: error validating package names in directory 'packages': found duplicate package names:
duplicate package name "elastic_package_registry" found in: packages/elastic_package_registry, packages/other/elastic_package_registry

# Running dependency: github.com/elastic/integrations/dev/codeowners.Check
# Error: error validating packages in directory 'packages': error checking manifest 'packages/other/elastic_package_registry': there is no owner for "packages/other/elastic_package_registry" in ".github/CODEOWNERS"

Related issues


PR generated with the assistance of Claude (claude-sonnet-4-6).

jsoriano and others added 10 commits April 21, 2026 10:21
- Add ListPackages function to dev/citools/packages.go that walks a
  directory and returns sorted paths of all valid packages found.
- Extend packageManifest struct with FormatVersion, Type and Version
  fields, and add IsValid() method mirroring dev/packagenames logic.
- Refactor dev/packagenames to delegate package discovery to
  citools.ListPackages, removing the now-redundant walkPackagePaths.

Generated with Claude (claude-sonnet-4-6)
- Rename readPackageManifest to ReadPackageManifest so it can be used
  from other packages.
- Remove dev/packagenames/manifest.go and its local packageManifest
  type, replacing all usages with citools.ReadPackageManifest.
- Update all internal callers (kibana.go, logsdb.go, subscription.go,
  packages.go) to use the renamed function.

Generated with Claude (claude-sonnet-4-6)
- Replace the inline WalkDir loop in validatePackages with a call to
  citools.ListPackages, removing duplicated package-discovery logic.
- Update testdata manifests (devexp, package_1) with the required
  format_version, name, type and version fields so they are recognised
  as valid packages by citools.ListPackages/IsValid.

Generated with Claude (claude-sonnet-4-6)
- Add nested_packages testdata with packages at two directory levels:
  one at the top level and two under a category/ subdirectory, one of
  which has data streams.
- Add five new TestValidatePackages cases covering: all packages with
  explicit owners, a missing owner for a nested package, category-level
  ownership inherited by nested packages, valid per-stream ownership in
  a nested package, and missing stream owner in a nested package.

Generated with Claude (claude-sonnet-4-6)
- Export manifestFileName as ManifestFileName in dev/citools/packages.go
  so it can be reused across packages.
- Remove the duplicate manifestFileName constant from dev/packagenames
  and replace its usage with citools.ManifestFileName.
- Replace the hardcoded "manifest.yml" string in dev/codeowners with
  citools.ManifestFileName.

Generated with Claude (claude-sonnet-4-6)
Add a termination check for ownerDir == "/" to prevent an infinite loop
when filepath.Dir reaches the filesystem root on non-Windows systems,
where filepath.Dir("/") returns "/" instead of ".".

Generated with the assistance of Claude Sonnet 4.6
Add a ListPackages target that calls citools.ListPackages to print all
package paths found under the packages directory, one per line.

Generated with Claude (claude-sonnet-4-6)
@mrodm mrodm self-assigned this Apr 21, 2026
Comment thread .buildkite/scripts/common.sh Outdated
mrodm and others added 2 commits April 21, 2026 11:02
Drop the hardcoded validTypes slice (integration, input, content) and
the slices.Contains check from packageManifest.IsValid(). Validity now
only requires that format_version, name, type, and version are all
non-empty. This allows new package types to be supported in the future
without requiring changes to this validation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@elastic-vault-github-plugin-prod
Copy link
Copy Markdown

elastic-vault-github-plugin-prod Bot commented Apr 21, 2026

🚀 Benchmarks report

Package citrix_adc 👍(4) 💚(1) 💔(1)

Expand to view
Data stream Previous EPS New EPS Diff (%) Result
vpn 6666.67 4329 -2337.67 (-35.07%) 💔

To see the full report comment with /test benchmark fullreport

@mrodm mrodm marked this pull request as ready for review April 21, 2026 10:23
@mrodm mrodm requested a review from a team as a code owner April 21, 2026 10:23
Copy link
Copy Markdown
Contributor

@teresaromero teresaromero left a comment

Choose a reason for hiding this comment

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

👍🏻

@mrodm
Copy link
Copy Markdown
Collaborator Author

mrodm commented Apr 21, 2026

Merging since CI failures are unrelated to this change.

@mrodm mrodm merged commit d6a117b into elastic:main Apr 21, 2026
9 of 10 checks passed
@mrodm mrodm deleted the allow-multiple-directories-dev-scripts branch April 21, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants