diff --git a/.github/workflows/golang.yaml b/.github/workflows/golang.yaml new file mode 100644 index 000000000..2025b74b9 --- /dev/null +++ b/.github/workflows/golang.yaml @@ -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 + 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: + 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 }} 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: