Skip to content

feat(internal/tool/composer): use entrypoint configuration instead of package names - #7156

Merged
sofisl merged 26 commits into
googleapis:mainfrom
sofisl:feat/composer-entrypoint
Aug 8, 2026
Merged

sofisl merged 26 commits into
googleapis:mainfrom
sofisl:feat/composer-entrypoint

Conversation

@sofisl

@sofisl sofisl commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This change replaces the hardcoded gapic-generator-php package name checks in composer tool installation with a declarative entrypoint configuration field. If a tool defines an entrypoint (e.g. src/Main.php), a bash wrapper script is generated for it in the bin directory. If the entrypoint is omitted, no wrapper is generated.
This refactoring prepares the composer installation logic to generically support PHP tools that require different entrypoints, or tools that act strictly as dependencies and do not require executable wrappers.

Merge Order & PR Relationship

This PR is the foundational step of a three-part refactoring effort and should be merged first:

  1. Merge this PR first: It introduces the generic Entrypoint logic and removes the hardcoded checks that previously blocked non-generator tools from being installed.
  2. Merge PR feat(internal/librarian/php): add google-cloud-php/dev as a tool to install #7122 second: With this PR merged, PR feat(internal/librarian/php): add google-cloud-php/dev as a tool to install #7122 can cleanly install google-cloud-php/dev. Because google-cloud-php/dev will not specify an entrypoint, Librarian will safely run composer install on it without attempting (and failing) to generate an executable wrapper for it.
  3. Merge PR fix(internal/librarian/php): remove --side_loaded_root_dir option in install #7141 third: Now that wrapper generation is decoupled from the gapic-generator-php package name, PR fix(internal/librarian/php): remove --side_loaded_root_dir option in install #7141 can safely remove the hardcoded --side_loaded_root_dir flag from the wrapper script template. This will make the PHP wrapper logic fully generic and reusable for any future tool.

sofisl added 21 commits July 30, 2026 18:20
This change modifies Librarian to automatically run composer install
during the php tool installation phase if a composer.json is found in
the current working directory. This ensures that PHP-specific tools
like dev/google-cloud component:new have their dependencies installed
before being executed.

Fixes googleapis#6978
This change modifies Librarian to use the internal command.RunStreaming helper instead of os/exec.CommandContext to reduce boilerplate. It also adds comments to clarify the different composer install commands.
This change modifies Librarian to encapsulate the composer installation logic into composer.InstallProject, making it consistent with other package installations.
The composer tool installation step now strictly requires a composer.json
file to exist in the target path. This change updates the php tools tests
and the github action to create a dummy composer.json file where necessary.
When creating a dummy composer.json in the github action for PHP tests,
composer install defaults to using the vendor/ directory for php packages.
This causes issues since subsequent Go commands detect the vendor/ directory
and fail because their vendor/modules.txt and vendor directory were overwritten
or confused by composer.
Setting vendor-dir in the composer.json configuration prevents this collision.

Fixes googleapis#7122
…d of package names

This removes hardcoded branching logic for Composer tools (specifically `gapic-generator-php` and `google-cloud-php/dev`) by replacing it with a declarative `Entrypoint` configuration field. If an entrypoint is set, a wrapper is generated; otherwise, it is skipped. This simplifies installation behavior.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces an Entrypoint field to the ComposerTool configuration, enabling generic Composer tools to generate executable wrappers rather than hardcoding the wrapper logic specifically for gapic-generator-php. It also adds validation to ensure the entrypoint is a clean relative path and updates the corresponding tests. The reviewer suggested inlining the test cases slice directly into the for range loop header for the table-driven tests in composer_test.go to align with the project's style guide.

Comment thread internal/tool/composer/composer_test.go Resolved
@sofisl
sofisl force-pushed the feat/composer-entrypoint branch 3 times, most recently from 34e6b6e to c1a50a1 Compare July 31, 2026 23:11
@sofisl
sofisl force-pushed the feat/composer-entrypoint branch from c1a50a1 to dd6abac Compare July 31, 2026 23:15
@sofisl
sofisl marked this pull request as ready for review August 4, 2026 19:40
@sofisl
sofisl requested a review from a team as a code owner August 4, 2026 19:40
@JoeWang1127

Copy link
Copy Markdown
Contributor

FYI: maybe conflict with #7159.

Comment thread internal/tool/composer/composer_test.go Resolved
Comment thread internal/tool/composer/composer_test.go Resolved
Comment thread internal/tool/composer/composer_test.go Resolved
sofisl added 4 commits August 8, 2026 00:21
Refactors test error handling in composer_test.go to use t.Fatal/t.Error
instead of verbose t.Fatalf/t.Errorf messages when simply bubbling up an unexpected error,
aligning with the howwewritego.md guidelines.
Refactors composer_test.go to use fs.ErrNotExist per howwewritego.md
guidelines and review feedback.
Refactors composer_test.go to use 'test' instead of 'tt' in table-driven tests
per code review feedback and howwewritego.md guidelines.
@sofisl
sofisl merged commit e33192f into googleapis:main Aug 8, 2026
40 checks passed
JoeWang1127 pushed a commit that referenced this pull request Aug 10, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.34.0](v0.33.0...v0.34.0)
(2026-08-08)


### Features

* **dart:** add a setup skill
([#7193](#7193))
([d322aa0](d322aa0))
* **dart:** implement bump
([#6989](#6989))
([5505997](5505997))
* **internal/librarian/php:** derive component name with config override
in generate
([#7197](#7197))
([557e664](557e664)),
refs [#7025](#7025)
* **internal/librarian/php:** derive lowercase hyphenated php library
names from api path
([#7215](#7215))
([4669112](4669112))
* **internal/librarian/php:** initialize new component before generation
([#7225](#7225))
([b6c50b4](b6c50b4))
* **internal/librarian/ruby:** support deleting output paths after
generation
([#7223](#7223))
([609ffb7](609ffb7)),
refs [#6633](#6633)
* **internal/librarian/rust:** support external type conversions
([#7212](#7212))
([5b72c52](5b72c52)),
refs [#7144](#7144)
* **internal/proto:** add package to gather proto files
([#7218](#7218))
([9646f09](9646f09)),
refs [#7217](#7217)
* **internal/sidekick/rust:** initialize bidi streaming RPCs eagerly
([#7221](#7221))
([cbfa368](cbfa368)),
refs [#6835](#6835)
* **internal/sidekick/rust:** support type-erased streaming handles
([#7229](#7229))
([17f5a3d](17f5a3d)),
refs [#6835](#6835)
* **internal/sidekick/rust:** use builder pattern for bidi methods
([#7203](#7203))
([bc90045](bc90045)),
refs [#6835](#6835)
* **internal/tool/composer:** use entrypoint configuration instead of
package names
([#7156](#7156))
([e33192f](e33192f))
* **sidekick/rust:** bigquery query creation metadata
([#7167](#7167))
([d70f2a2](d70f2a2))
* **swift:** conversions support map fields
([#7222](#7222))
([341f1e5](341f1e5))
* **swift:** protobuf conversions support oneofs
([#7205](#7205))
([40c48df](40c48df))
* **swift:** support skipped_ids in configuration
([#7206](#7206))
([95d3464](95d3464))


### Bug Fixes

* **internal/librarian/php:** remove version suffix from init namespace
([#7227](#7227))
([7fb3b46](7fb3b46))
* **internal/librarian/ruby:** pass gem namespace option to generator
([#7210](#7210))
([817146f](817146f))
* **internal/librarian/ruby:** pass service override option to generator
([#7208](#7208))
([e9886bf](e9886bf)),
refs [#6633](#6633)
* **internal/librarian/ruby:** search proto recursively in API path
([#7220](#7220))
([3d4a4a1](3d4a4a1)),
refs [#7219](#7219)
[#7217](#7217)
* **internal/librarian/rust:** preserve parent messages of used types
([#7170](#7170))
([e51520c](e51520c)),
refs [#7143](#7143)
* **internal/serviceconfig:** update config for compute
([#7200](#7200))
([a08e565](a08e565))
* **internal/sidekick/rust:** use from for repeated enum conversions in
convert-prost
([#7211](#7211))
([ee4fb71](ee4fb71))


### Performance Improvements

* **java:** batch format all libraries using argument file
([#7186](#7186))
([5a7775a](5a7775a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
sofisl added a commit that referenced this pull request Aug 10, 2026
…install (#7141)

This PR completes the refactoring effort to make the PHP Composer tool
installation logic fully generic.
Now that wrapper script generation is decoupled from the
`gapic-generator-php` package name (completed in PR #7156), we can
safely remove the hardcoded `--side_loaded_root_dir "$GOOGLEAPIS_DIR"`
flag from the bash wrapper script template. Because the wrapper simply
forwards all arguments (`"$@"`), this change makes the PHP wrapper logic
completely generic and cleanly reusable for any future Composer tool
that specifies an `entrypoint`.

In order to remove the option, we've plumbed the absolute path of the
necessary arguments for the generator.

Fixes #7000

---------

Signed-off-by: sofisl <[email protected]>
Signed-off-by: Brian Quinlan <[email protected]>
Signed-off-by: yangyzs <[email protected]>
Co-authored-by: Nolan Eastin <[email protected]>
Co-authored-by: Suzy Mueller <[email protected]>
Co-authored-by: Joe Wang <[email protected]>
Co-authored-by: Carlos O'Ryan <[email protected]>
Co-authored-by: Santiago Quiroga <[email protected]>
Co-authored-by: Min Zhu <[email protected]>
Co-authored-by: Noah Dietz <[email protected]>
Co-authored-by: Alvaro Viebrantz <[email protected]>
Co-authored-by: Heba Alazzeh <[email protected]>
Co-authored-by: Brian Quinlan <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Nate Bosch <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: yangyzs <[email protected]>
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.

2 participants