Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion doc/config-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
| `gem` | list of [GemTool](#gemtool-configuration) (optional) | Defines tools to install via gem. |
| `maven` | list of [MavenTool](#maventool-configuration) (optional) | Defines tools to install via Maven. |
Expand All @@ -52,6 +53,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. |
| `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 |
Expand Down Expand Up @@ -95,7 +106,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
Expand Down
25 changes: 23 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down Expand Up @@ -125,6 +128,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"`

// 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"`
}

// GemTool defines a tool to install via gem.
type GemTool struct {
// Name is the gem name.
Expand Down Expand Up @@ -199,8 +220,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"`
Expand Down
2 changes: 1 addition & 1 deletion internal/librarian/nodejs/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/librarian/tidy.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,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 &&
Expand Down Expand Up @@ -266,6 +267,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 strings.Compare(a.Name, b.Name)
})
slices.SortFunc(cfg.Tools.PNPM, func(a, b *config.PNPMTool) int {
return strings.Compare(a.Name, b.Name)
})
Expand Down
11 changes: 11 additions & 0 deletions tool/cmd/migrate/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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",
SHA256: "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.
Expand Down
11 changes: 11 additions & 0 deletions tool/cmd/migrate/php_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
SHA256: "29635b02c6e505fe31cba2f88ae999f00d2710fe1d65cb7cad521a82e7c5a518",
Build: []string{"composer install"},
},
},
},
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
Expand Down
Loading