Repository navigation
feat(internal/tool/composer): use entrypoint configuration instead of package names - #7156
Merged
Merged
Conversation
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.
…th in composer tools
…set to google-cloud-php
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.
Contributor
There was a problem hiding this comment.
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.
sofisl
force-pushed
the
feat/composer-entrypoint
branch
3 times, most recently
from
July 31, 2026 23:11
34e6b6e to
c1a50a1
Compare
sofisl
force-pushed
the
feat/composer-entrypoint
branch
from
July 31, 2026 23:15
c1a50a1 to
dd6abac
Compare
sofisl
marked this pull request as ready for review
August 4, 2026 19:40
Contributor
|
FYI: maybe conflict with #7159. |
JoeWang1127
approved these changes
Aug 4, 2026
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.
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change replaces the hardcoded
gapic-generator-phppackage name checks in composer tool installation with a declarativeentrypointconfiguration field. If a tool defines anentrypoint(e.g.src/Main.php), a bash wrapper script is generated for it in the bin directory. If theentrypointis 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:
Entrypointlogic and removes the hardcoded checks that previously blocked non-generator tools from being installed.google-cloud-php/dev. Becausegoogle-cloud-php/devwill not specify anentrypoint, Librarian will safely runcomposer installon it without attempting (and failing) to generate an executable wrapper for it.gapic-generator-phppackage name, PR fix(internal/librarian/php): remove --side_loaded_root_dir option in install #7141 can safely remove the hardcoded--side_loaded_root_dirflag from the wrapper script template. This will make the PHP wrapper logic fully generic and reusable for any future tool.