From 193dcd55cfb75f9817da5a3f49e6e4dfce712c81 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:42:25 -0400 Subject: [PATCH 01/10] chore: add golang workflow --- .github/workflows/golang.yaml | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/golang.yaml diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml new file mode 100644 index 000000000..c34a5c932 --- /dev/null +++ b/.github/workflows/golang.yaml @@ -0,0 +1,61 @@ +# 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. +name: Golang +on: [push, pull_request, merge_group] +permissions: + contents: read + issues: write +jobs: + test: + runs-on: ubuntu-24.04 + # Presubmit jobs must complete within 5 minutes. See CONTRIBUTING.md. + timeout-minutes: 5 + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version-file: "go.mod" + - uses: ./.github/actions/install-protoc + - name: Install Go dependencies + run: | + go install google.golang.org/protobuf/cmd/protoc-gen-go@v${GO_PROTOC_PLUGIN_VERSION} + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${GO_PROTOC_GRPC_PLUGIN_VERSION} + go install github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic@v${GO_GAPIC_VERSION} + go install golang.org/x/tools/cmd/goimports@latest + with: + GO_PROTOC_PLUGIN_VERSION: 1.35.2 + GO_PROTOC_GRPC_PLUGIN_VERSION: 1.3.0 + GO_GAPIC_VERSION: 0.57.0 + - name: Run tests + run: | + go test -race -coverprofile=coverage.out -covermode=atomic internal/librarian/golang + - name: Upload coverage report + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + create-issue-on-failure: + runs-on: ubuntu-24.04 + needs: [test] + if: ${{ always() && contains(needs.*.result, 'failure') && github.event_name == 'push' && github.ref == 'refs/heads/main' }} + steps: + - name: Create an issue for push event to main + run: | + ISSUE_TITLE="all: tests failed at HEAD" + BODY="Tests failed at HEAD of the \`main\` branch. Please review Workflow Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} for detail." + ISSUE_LINK=$(gh issue create --title "$ISSUE_TITLE" --body "$BODY" --label ":rotating_light: critical" --assignee ${{ github.actor }} -R $GH_REPO) + ISSUE_NUM=${ISSUE_LINK##*/} + gh issue comment $ISSUE_NUM --body "@googleapis/cloud-sdk-librarian-team A critical issue has been created, please respond immediately." + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} From 872cd89df0e2b2d7ea6341fae32dc01630b31886 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:43:35 -0400 Subject: [PATCH 02/10] update copyright --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index c34a5c932..9918c6412 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -1,4 +1,4 @@ -# Copyright 2024 Google LLC +# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 7ef0506e668ef50d078903474612ec7c67a496d6 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:44:48 -0400 Subject: [PATCH 03/10] update workflow --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 9918c6412..cd7676813 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -33,7 +33,7 @@ jobs: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${GO_PROTOC_GRPC_PLUGIN_VERSION} go install github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic@v${GO_GAPIC_VERSION} go install golang.org/x/tools/cmd/goimports@latest - with: + env: GO_PROTOC_PLUGIN_VERSION: 1.35.2 GO_PROTOC_GRPC_PLUGIN_VERSION: 1.3.0 GO_GAPIC_VERSION: 0.57.0 From 14f3acda4b1038ef95f987d908c09025231123e9 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:46:33 -0400 Subject: [PATCH 04/10] update workflow --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index cd7676813..2a0c36005 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -39,7 +39,7 @@ jobs: GO_GAPIC_VERSION: 0.57.0 - name: Run tests run: | - go test -race -coverprofile=coverage.out -covermode=atomic internal/librarian/golang + go test -race -coverprofile=coverage.out -covermode=atomic ./internal/librarian/golang - name: Upload coverage report uses: codecov/codecov-action@v5 with: From 428fd02c3d89868dc348cc0b4105ee6a0dd02210 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:47:48 -0400 Subject: [PATCH 05/10] update workflow --- .github/workflows/golang.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 2a0c36005..2025b74b9 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -22,7 +22,7 @@ jobs: # Presubmit jobs must complete within 5 minutes. See CONTRIBUTING.md. timeout-minutes: 5 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - uses: actions/setup-go@v6 with: go-version-file: "go.mod" From e8d9b16be1c5d971f23280173c79ded61176cb6e Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:57:30 -0400 Subject: [PATCH 06/10] update workflow --- .github/workflows/librarian.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/librarian.yaml b/.github/workflows/librarian.yaml index 01b483c02..8553d3f36 100644 --- a/.github/workflows/librarian.yaml +++ b/.github/workflows/librarian.yaml @@ -65,7 +65,7 @@ jobs: - name: Run tests run: | go test -race -coverprofile=coverage.out -covermode=atomic \ - $(go list ./... | grep -v -E 'internal/librarian/(python|rust|dart)|internal/sidekick|internal/legacylibrarian') + $(go list ./... | grep -v -E 'internal/librarian/(dart|golang|python|rust)|internal/sidekick|internal/legacylibrarian') - name: Upload coverage report uses: codecov/codecov-action@v5 with: From 95fbe0e913c88e507749d729bf22e5839de79035 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:33:25 -0400 Subject: [PATCH 07/10] update workflow --- .github/workflows/golang.yaml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 2025b74b9..8253d6025 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -29,14 +29,7 @@ jobs: - uses: ./.github/actions/install-protoc - name: Install Go dependencies run: | - go install google.golang.org/protobuf/cmd/protoc-gen-go@v${GO_PROTOC_PLUGIN_VERSION} - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${GO_PROTOC_GRPC_PLUGIN_VERSION} - go install github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic@v${GO_GAPIC_VERSION} - go install golang.org/x/tools/cmd/goimports@latest - env: - GO_PROTOC_PLUGIN_VERSION: 1.35.2 - GO_PROTOC_GRPC_PLUGIN_VERSION: 1.3.0 - GO_GAPIC_VERSION: 0.57.0 + go mod tidy - name: Run tests run: | go test -race -coverprofile=coverage.out -covermode=atomic ./internal/librarian/golang From a3ce1665f5e9e9c5ce80e2788cccc6556897cd80 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:40:06 -0400 Subject: [PATCH 08/10] intentially fail --- internal/librarian/golang/generate.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/internal/librarian/golang/generate.go b/internal/librarian/golang/generate.go index b52a1477f..8b823ff3e 100644 --- a/internal/librarian/golang/generate.go +++ b/internal/librarian/golang/generate.go @@ -184,9 +184,6 @@ func buildGAPICImportPath(goAPI *config.GoAPI) string { // generated package into the library directory, fixing version paths, and removing any paths configured // for deletion. func moveGeneratedFiles(library *config.Library, outDir string) error { - if len(library.APIs) == 0 { - return nil - } src := filepath.Join(outDir, "cloud.google.com", "go") if _, err := os.Stat(src); err != nil { return fmt.Errorf("cannot access directory %q: %w", src, err) From e35a711441eab137a7a2152d034a6332ff3452a6 Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:45:52 -0400 Subject: [PATCH 09/10] restore --- .github/workflows/golang.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml index 8253d6025..2025b74b9 100644 --- a/.github/workflows/golang.yaml +++ b/.github/workflows/golang.yaml @@ -29,7 +29,14 @@ jobs: - uses: ./.github/actions/install-protoc - name: Install Go dependencies run: | - go mod tidy + go install google.golang.org/protobuf/cmd/protoc-gen-go@v${GO_PROTOC_PLUGIN_VERSION} + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v${GO_PROTOC_GRPC_PLUGIN_VERSION} + go install github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic@v${GO_GAPIC_VERSION} + go install golang.org/x/tools/cmd/goimports@latest + env: + GO_PROTOC_PLUGIN_VERSION: 1.35.2 + GO_PROTOC_GRPC_PLUGIN_VERSION: 1.3.0 + GO_GAPIC_VERSION: 0.57.0 - name: Run tests run: | go test -race -coverprofile=coverage.out -covermode=atomic ./internal/librarian/golang From 3ee45794844c660a055f6b8e54c7ada95fa51f1c Mon Sep 17 00:00:00 2001 From: Joe Wang <106995533+JoeWang1127@users.noreply.github.com> Date: Tue, 17 Mar 2026 13:19:20 -0400 Subject: [PATCH 10/10] restore --- internal/librarian/golang/generate.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/librarian/golang/generate.go b/internal/librarian/golang/generate.go index 8b823ff3e..b52a1477f 100644 --- a/internal/librarian/golang/generate.go +++ b/internal/librarian/golang/generate.go @@ -184,6 +184,9 @@ func buildGAPICImportPath(goAPI *config.GoAPI) string { // generated package into the library directory, fixing version paths, and removing any paths configured // for deletion. func moveGeneratedFiles(library *config.Library, outDir string) error { + if len(library.APIs) == 0 { + return nil + } src := filepath.Join(outDir, "cloud.google.com", "go") if _, err := os.Stat(src); err != nil { return fmt.Errorf("cannot access directory %q: %w", src, err)