...

Text file src/cloud.google.com/go/cloudsqlconn/.github/workflows/lint.yaml

Documentation: cloud.google.com/go/cloudsqlconn/.github/workflows

     1# Copyright 2021 Google LLC
     2#
     3# Licensed under the Apache License, Version 2.0 (the "License");
     4# you may not use this file except in compliance with the License.
     5# You may obtain a copy of the License at
     6#
     7#      http://www.apache.org/licenses/LICENSE-2.0
     8#
     9# Unless required by applicable law or agreed to in writing, software
    10# distributed under the License is distributed on an "AS IS" BASIS,
    11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12# See the License for the specific language governing permissions and
    13# limitations under the License.
    14
    15name: lint
    16on:
    17  pull_request:
    18  pull_request_target:
    19    types: [labeled]
    20
    21# Declare default permissions as read only.
    22permissions: read-all
    23
    24jobs:
    25  build:
    26    if: "${{ github.event.action != 'labeled' || github.event.label.name == 'tests: run' }}"
    27    name: Run lint
    28    runs-on: ubuntu-latest
    29    permissions:
    30      issues: write
    31      pull-requests: write
    32    steps:
    33      - name: Remove PR Label
    34        if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}"
    35        uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
    36        with:
    37          github-token: ${{ secrets.GITHUB_TOKEN }}
    38          script: |
    39            try {
    40              await github.rest.issues.removeLabel({
    41                name: 'tests: run',
    42                owner: context.repo.owner,
    43                repo: context.repo.repo,
    44                issue_number: context.payload.pull_request.number
    45              });
    46            } catch (e) {
    47              console.log('Failed to remove label. Another job may have already removed it!');
    48            }
    49      - name: Setup Go
    50        uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
    51        with:
    52          go-version: "1.22"
    53      - name: Checkout code
    54        uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
    55        with:
    56          ref: ${{ github.event.pull_request.head.sha }}
    57          repository: ${{ github.event.pull_request.head.repo.full_name }}
    58      - name: go mod tidy
    59        run: |
    60          go mod tidy && git diff --exit-code
    61      - name: golangci-lint
    62        uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1
    63        with:
    64          version: latest
    65          args: --timeout 3m

View as plain text