-
Notifications
You must be signed in to change notification settings - Fork 50
feat: add automation go script for triggering all configured repositories #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1008faf
build: scaffold for running fanout command
chingor13 1d6cf2f
can trigger GCB
chingor13 fc92001
scaffold some tests
chingor13 4722126
docs: fix doc
chingor13 d9edf3a
define higher level client
chingor13 036236d
fix segfault
chingor13 2256dcd
test: fix tests
chingor13 ad96f82
test: add tests
chingor13 df7a0e1
parse CLI flags
chingor13 3eebae0
parse CLI flags
chingor13 832df29
test for CLI parsing
chingor13 acec260
include fanout gcb worker
chingor13 5184857
Merge branch 'main' into fanout
chingor13 a4a3f83
move configs back to infra folder
chingor13 c235f00
address review comments
chingor13 3860927
run against current clone in GCB
chingor13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright 2024 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // Librarian manages Google API client libraries by automating onboarding, | ||
| // regeneration, and release. It runs language‑agnostic workflows while | ||
| // delegating language‑specific tasks—such as code generation, building, and | ||
| // testing—to Docker images. | ||
| package main | ||
|
|
||
| import ( | ||
| "log" | ||
| "os" | ||
|
|
||
| "github.com/googleapis/librarian/internal/automation" | ||
| ) | ||
|
|
||
| func main() { | ||
| if err := automation.Run(os.Args[1:]); err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| } | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Copyright 2025 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # This runs the `librarian generate` command with a provided repository, | ||
| # secret name, and optional library ID | ||
| steps: | ||
| - name: gcr.io/cloud-builders/git | ||
| id: clone-language-repo | ||
| waitFor: ['-'] | ||
| args: | ||
| - 'clone' | ||
| - '--depth=1' | ||
| - https://github.com/googleapis/$_REPOSITORY | ||
| - name: gcr.io/cloud-builders/git | ||
| id: clone-googleapis | ||
| waitFor: ['-'] | ||
| args: | ||
| - 'clone' | ||
| - '--single-branch' | ||
| - '--branch=master' | ||
| - https://github.com/googleapis/googleapis | ||
| - name: 'us-central1-docker.pkg.dev/cloud-sdk-production-pipeline/images-prod/librarian@sha256:dac8d6d46eefecde4241c88348315e6162ccd0d39e84db2b98e4da7393f65c29' | ||
| id: generate | ||
| waitFor: ['clone-language-repo', 'clone-googleapis'] | ||
| args: | ||
| - 'generate' | ||
| - '-repo' | ||
| - '/workspace/$_REPOSITORY' | ||
| - '-library' | ||
| - $_LIBRARY_ID | ||
| - '-api-source' | ||
| - '/workspace/googleapis' | ||
| secretEnv: ['LIBRARIAN_GITHUB_TOKEN'] | ||
| tags: ['generate-$_REPOSITORY'] | ||
| availableSecrets: | ||
| secretManager: | ||
| - versionName: projects/$PROJECT_ID/secrets/$_GITHUB_TOKEN_SECRET_NAME/versions/latest | ||
| env: 'LIBRARIAN_GITHUB_TOKEN' | ||
| options: | ||
| logging: CLOUD_LOGGING_ONLY |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Copyright 2025 Google LLC | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // https://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package automation | ||
|
|
||
| import ( | ||
| "context" | ||
| "flag" | ||
| "log/slog" | ||
| ) | ||
|
|
||
| // Run parses the command line arguments and triggers the specified command. | ||
| func Run(args []string) error { | ||
| ctx := context.Background() | ||
| options, err := parseFlags(args) | ||
| if err != nil { | ||
| slog.Error("Error parsing command", slog.Any("err", err)) | ||
| return err | ||
| } | ||
|
|
||
| err = RunCommand(ctx, options.Command, options.ProjectId) | ||
| if err != nil { | ||
| slog.Error("Error running command", slog.Any("err", err)) | ||
| return err | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| type runOptions struct { | ||
| Command string | ||
| ProjectId string | ||
| } | ||
|
|
||
| func parseFlags(args []string) (*runOptions, error) { | ||
| flagSet := flag.NewFlagSet("dispatcher", flag.ContinueOnError) | ||
| projectId := flagSet.String("project", "cloud-sdk-librarian-prod", "GCP project ID") | ||
| command := flagSet.String("command", "generate", "The librarian command to run") | ||
| err := flagSet.Parse(args) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &runOptions{ | ||
| ProjectId: *projectId, | ||
| Command: *command, | ||
| }, nil | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.