Skip to content
Closed
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
61 changes: 61 additions & 0 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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.
# 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@v6
- 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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to install dependencies using go mod tidy since these dependencies are listed in go.mod but it didn't work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use go tool install https://tip.golang.org/doc/go1.24#tools

Also I'm not sure I understand why you need this. The tests run in .github/workflows/librarian.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I'm not sure I understand why you need this. The tests run in .github/workflows/librarian.yaml

I tested that not all unit tests are run in that workflow because some unit tests require toolings installed, e.g., gapic-generator-go.

The golang tests in this workflow runs for 12s while in librarian.yaml it only needs 2s.

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
- name: Upload coverage report
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
create-issue-on-failure:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to create a .github/workflows/postsubmit.yaml file, so that we can share the same template across languages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #4631 as a follow up.

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 }}
2 changes: 1 addition & 1 deletion .github/workflows/librarian.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading