From 74cbd5f1e09a55f058e8c88da7855e7711fb1f69 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Thu, 9 Jul 2026 22:47:16 +0000 Subject: [PATCH 1/6] feat(php): support composer tools and populate via migration --- internal/config/config.go | 21 +++++++++++++++++++++ internal/librarian/tidy.go | 5 +++++ tool/cmd/migrate/php.go | 11 +++++++++++ tool/cmd/migrate/php_test.go | 11 +++++++++++ 4 files changed, 48 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index 3038dcc9cdf..52b95f74498 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -97,6 +97,9 @@ type Tools struct { // Cargo defines tools to install via cargo. Cargo []*CargoTool `yaml:"cargo,omitempty"` + // Composer defines tools to install via Composer. + Composer []*ComposerTool `yaml:"composer,omitempty"` + // Go defines tools to install via go. Go []*GoTool `yaml:"go,omitempty"` @@ -122,6 +125,24 @@ type CargoTool struct { Version string `yaml:"version"` } +// ComposerTool defines a tool to install via Composer. +type ComposerTool struct { + // Name is the composer package name. + Name string `yaml:"name"` + + // Version is the version to install. + Version string `yaml:"version"` + + // Package is the URL or path of the package to install. + Package string `yaml:"package,omitempty"` + + // Checksum is the SHA256 checksum of the package. + Checksum string `yaml:"checksum,omitempty"` + + // Build defines the commands to run to build the tool after installation. + Build []string `yaml:"build,omitempty"` +} + // GoTool defines a tool to install via go. type GoTool struct { // Name is the go module name. diff --git a/internal/librarian/tidy.go b/internal/librarian/tidy.go index 43cf10b6e26..344f35fd497 100644 --- a/internal/librarian/tidy.go +++ b/internal/librarian/tidy.go @@ -15,6 +15,7 @@ package librarian import ( + "cmp" "context" "errors" "fmt" @@ -227,6 +228,7 @@ func tidyLanguageConfig(lib *config.Library, cfg *config.Config) (*config.Librar // isToolsEmpty returns true if the tools configuration is empty. func isToolsEmpty(tools *config.Tools) bool { return len(tools.Cargo) == 0 && + len(tools.Composer) == 0 && len(tools.Go) == 0 && len(tools.Maven) == 0 && len(tools.Pip) == 0 && @@ -266,6 +268,9 @@ func formatConfig(cfg *config.Config) *config.Config { slices.SortFunc(cfg.Tools.Cargo, func(a, b *config.CargoTool) int { return strings.Compare(a.Name, b.Name) }) + slices.SortFunc(cfg.Tools.Composer, func(a, b *config.ComposerTool) int { + return cmp.Compare(a.Name, b.Name) + }) slices.SortFunc(cfg.Tools.PNPM, func(a, b *config.PNPMTool) int { return strings.Compare(a.Name, b.Name) }) diff --git a/tool/cmd/migrate/php.go b/tool/cmd/migrate/php.go index 4143439d939..e02de6fae72 100644 --- a/tool/cmd/migrate/php.go +++ b/tool/cmd/migrate/php.go @@ -41,6 +41,17 @@ func runPHPMigration(ctx context.Context, repoPath string) error { Googleapis: src, }, Libraries: libs, + Tools: &config.Tools{ + Composer: []*config.ComposerTool{ + { + Name: "google/gapic-generator-php", + Version: "v1.21.2", + Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", + Checksum: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", + Build: []string{"composer install"}, + }, + }, + }, } // The directory name in Googleapis is present for migration code to look // up API details. It shouldn't be persisted. diff --git a/tool/cmd/migrate/php_test.go b/tool/cmd/migrate/php_test.go index c28428ccaf3..179f7599149 100644 --- a/tool/cmd/migrate/php_test.go +++ b/tool/cmd/migrate/php_test.go @@ -86,6 +86,17 @@ func TestRunPHPMigration(t *testing.T) { Version: "2.3.0", }, }, + Tools: &config.Tools{ + Composer: []*config.ComposerTool{ + { + Name: "google/gapic-generator-php", + Version: "v1.21.2", + Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", + Checksum: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", + Build: []string{"composer install"}, + }, + }, + }, } if diff := cmp.Diff(want, got); diff != "" { t.Errorf("mismatch (-want +got):\n%s", diff) From 84a18875ddfda0b8156154bf8f764610ad569481 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Thu, 9 Jul 2026 17:20:18 -0700 Subject: [PATCH 2/6] Replace cmp.Compare with strings.Compare for sorting Signed-off-by: sofisl <55454395+sofisl@users.noreply.github.com> --- internal/librarian/tidy.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/librarian/tidy.go b/internal/librarian/tidy.go index 344f35fd497..8fc73fe8130 100644 --- a/internal/librarian/tidy.go +++ b/internal/librarian/tidy.go @@ -15,7 +15,6 @@ package librarian import ( - "cmp" "context" "errors" "fmt" @@ -269,7 +268,7 @@ func formatConfig(cfg *config.Config) *config.Config { return strings.Compare(a.Name, b.Name) }) slices.SortFunc(cfg.Tools.Composer, func(a, b *config.ComposerTool) int { - return cmp.Compare(a.Name, b.Name) + return strings.Compare(a.Name, b.Name) }) slices.SortFunc(cfg.Tools.PNPM, func(a, b *config.PNPMTool) int { return strings.Compare(a.Name, b.Name) From c783b499b323382bfe4b920983e2050fe4870106 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 10 Jul 2026 00:33:24 +0000 Subject: [PATCH 3/6] docs: regenerate config schema docs --- doc/config-schema.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/config-schema.md b/doc/config-schema.md index cd4fb1522c9..c4513b92f9a 100644 --- a/doc/config-schema.md +++ b/doc/config-schema.md @@ -38,6 +38,7 @@ This document describes the schema for the librarian.yaml. | Field | Type | Description | | :--- | :--- | :--- | | `cargo` | list of [CargoTool](#cargotool-configuration) (optional) | Defines tools to install via cargo. | +| `composer` | list of [ComposerTool](#composertool-configuration) (optional) | Defines tools to install via Composer. | | `go` | list of [GoTool](#gotool-configuration) (optional) | Defines tools to install via go. | | `maven` | list of [MavenTool](#maventool-configuration) (optional) | Defines tools to install via Maven. | | `pip` | list of [PipTool](#piptool-configuration) (optional) | Defines tools to install via pip. | @@ -51,6 +52,16 @@ This document describes the schema for the librarian.yaml. | `name` | string | Is the cargo package name. | | `version` | string | Is the version to install. | +## ComposerTool Configuration + +| Field | Type | Description | +| :--- | :--- | :--- | +| `name` | string | Is the composer package name. | +| `version` | string | Is the version to install. | +| `package` | string | Is the URL or path of the package to install. | +| `checksum` | string | Is the SHA256 checksum of the package. | +| `build` | list of string | Defines the commands to run to build the tool after installation. | + ## GoTool Configuration | Field | Type | Description | From 39c5ef84392bf5008c36605852c5236b3b3fd4d5 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 10 Jul 2026 18:55:29 +0000 Subject: [PATCH 4/6] fix: replace Checksum with SHA256 in ComposerTool and PNPMTool --- doc/config-schema.md | 4 ++-- internal/config/config.go | 8 ++++---- internal/librarian/nodejs/install.go | 2 +- tool/cmd/migrate/php.go | 2 +- tool/cmd/migrate/php_test.go | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/config-schema.md b/doc/config-schema.md index c4513b92f9a..9616e2ea9de 100644 --- a/doc/config-schema.md +++ b/doc/config-schema.md @@ -59,7 +59,7 @@ This document describes the schema for the librarian.yaml. | `name` | string | Is the composer package name. | | `version` | string | Is the version to install. | | `package` | string | Is the URL or path of the package to install. | -| `checksum` | string | Is the SHA256 checksum of the package. | +| `sha256` | string | Is the SHA256 checksum of the package. | | `build` | list of string | Defines the commands to run to build the tool after installation. | ## GoTool Configuration @@ -98,7 +98,7 @@ This document describes the schema for the librarian.yaml. | `name` | string | Is the pnpm package name. | | `version` | string | Is the version to install. | | `package` | string | Is the URL or path of the package to install. | -| `checksum` | string | Is the SHA256 checksum of the package. | +| `sha256` | string | Is the SHA256 checksum of the package. | | `build` | list of string | Defines the commands to run to build the tool after installation. | ## Protoc Configuration diff --git a/internal/config/config.go b/internal/config/config.go index 52b95f74498..232e674f5df 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -136,8 +136,8 @@ type ComposerTool struct { // Package is the URL or path of the package to install. Package string `yaml:"package,omitempty"` - // Checksum is the SHA256 checksum of the package. - Checksum string `yaml:"checksum,omitempty"` + // SHA256 is the SHA256 checksum of the package. + SHA256 string `yaml:"sha256,omitempty"` // Build defines the commands to run to build the tool after installation. Build []string `yaml:"build,omitempty"` @@ -208,8 +208,8 @@ type PNPMTool struct { // Package is the URL or path of the package to install. Package string `yaml:"package,omitempty"` - // Checksum is the SHA256 checksum of the package. - Checksum string `yaml:"checksum,omitempty"` + // SHA256 is the SHA256 checksum of the package. + SHA256 string `yaml:"sha256,omitempty"` // Build defines the commands to run to build the tool after installation. Build []string `yaml:"build,omitempty"` diff --git a/internal/librarian/nodejs/install.go b/internal/librarian/nodejs/install.go index 3400867b761..77c6d73bd58 100644 --- a/internal/librarian/nodejs/install.go +++ b/internal/librarian/nodejs/install.go @@ -164,7 +164,7 @@ func installPNPMToolFromSource(ctx context.Context, env []string, tool *config.P if err != nil { return err } - dir, err := fetch.Repo(ctx, repo, tool.Version, tool.Checksum) + dir, err := fetch.Repo(ctx, repo, tool.Version, tool.SHA256) if err != nil { return fmt.Errorf("fetching %s: %w", tool.Name, err) } diff --git a/tool/cmd/migrate/php.go b/tool/cmd/migrate/php.go index e02de6fae72..28bcf602efc 100644 --- a/tool/cmd/migrate/php.go +++ b/tool/cmd/migrate/php.go @@ -47,7 +47,7 @@ func runPHPMigration(ctx context.Context, repoPath string) error { Name: "google/gapic-generator-php", Version: "v1.21.2", Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", - Checksum: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", + SHA256: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", Build: []string{"composer install"}, }, }, diff --git a/tool/cmd/migrate/php_test.go b/tool/cmd/migrate/php_test.go index 179f7599149..da360f09e9f 100644 --- a/tool/cmd/migrate/php_test.go +++ b/tool/cmd/migrate/php_test.go @@ -92,7 +92,7 @@ func TestRunPHPMigration(t *testing.T) { Name: "google/gapic-generator-php", Version: "v1.21.2", Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", - Checksum: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", + SHA256: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", Build: []string{"composer install"}, }, }, From 06fb723948fc158a261900d5828cfc27c1ff7478 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 10 Jul 2026 19:03:47 +0000 Subject: [PATCH 5/6] fix: resolve syntax error with GemTool placement --- doc/config-schema.md | 1 + internal/config/config.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/config-schema.md b/doc/config-schema.md index 6f058863c55..c7f24f5f804 100644 --- a/doc/config-schema.md +++ b/doc/config-schema.md @@ -62,6 +62,7 @@ This document describes the schema for the librarian.yaml. | `package` | string | Is the URL or path of the package to install. | | `sha256` | string | Is the SHA256 checksum of the package. | | `build` | list of string | Defines the commands to run to build the tool after installation. | + ## GemTool Configuration | Field | Type | Description | diff --git a/internal/config/config.go b/internal/config/config.go index 87c01165435..e544ad7d160 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -131,9 +131,6 @@ type CargoTool struct { // ComposerTool defines a tool to install via Composer. type ComposerTool struct { // Name is the composer package name. -// GemTool defines a tool to install via gem. -type GemTool struct { - // Name is the gem name. Name string `yaml:"name"` // Version is the version to install. @@ -149,6 +146,15 @@ type GemTool struct { Build []string `yaml:"build,omitempty"` } +// GemTool defines a tool to install via gem. +type GemTool struct { + // Name is the gem name. + Name string `yaml:"name"` + + // Version is the version to install. + Version string `yaml:"version"` +} + // GoTool defines a tool to install via go. type GoTool struct { // Name is the go module name. From b806ceee71322eeaa128ccd98529678d1b36ac47 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 10 Jul 2026 20:46:03 +0000 Subject: [PATCH 6/6] chore(migrate): fix php and php_test struct formatting --- tool/cmd/migrate/php.go | 10 +++++----- tool/cmd/migrate/php_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tool/cmd/migrate/php.go b/tool/cmd/migrate/php.go index 22d9f5114d4..a3e259b592c 100644 --- a/tool/cmd/migrate/php.go +++ b/tool/cmd/migrate/php.go @@ -46,11 +46,11 @@ func runPHPMigration(ctx context.Context, repoPath string) error { Tools: &config.Tools{ Composer: []*config.ComposerTool{ { - Name: "google/gapic-generator-php", - Version: "v1.21.2", - Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", - SHA256: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", - Build: []string{"composer install"}, + Name: "google/gapic-generator-php", + Version: "v1.21.2", + Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", + SHA256: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", + Build: []string{"composer install"}, }, }, }, diff --git a/tool/cmd/migrate/php_test.go b/tool/cmd/migrate/php_test.go index 9c945f1ed87..c8037f9193c 100644 --- a/tool/cmd/migrate/php_test.go +++ b/tool/cmd/migrate/php_test.go @@ -89,11 +89,11 @@ func TestRunPHPMigration(t *testing.T) { Tools: &config.Tools{ Composer: []*config.ComposerTool{ { - Name: "google/gapic-generator-php", - Version: "v1.21.2", - Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", - SHA256: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", - Build: []string{"composer install"}, + Name: "google/gapic-generator-php", + Version: "v1.21.2", + Package: "https://github.com/googleapis/gapic-generator-php/archive/refs/tags/v1.21.2.tar.gz", + SHA256: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518", + Build: []string{"composer install"}, }, }, },