...

Text file src/google.golang.org/api/internal/kokoro/vet.sh

Documentation: google.golang.org/api/internal/kokoro

     1#!/bin/bash
     2
     3# Copyright 2019 Google LLC.
     4# Use of this source code is governed by a BSD-style
     5# license that can be found in the LICENSE file.
     6
     7# Fail on error, and display commands being run.
     8set -ex
     9
    10if [[ $KOKORO_JOB_NAME != *"latest-version"* ]]; then
    11  exit 0
    12fi
    13
    14# Fail if a dependency was added without the necessary go.mod/go.sum change
    15# being part of the commit.
    16go mod tidy
    17git diff go.mod | tee /dev/stderr | (! read)
    18git diff go.sum | tee /dev/stderr | (! read)
    19
    20# Easier to debug CI.
    21pwd
    22
    23gofmt -s -d -l . 2>&1 | tee /dev/stderr | (! read)
    24goimports -l . 2>&1 | tee /dev/stderr | (! read)
    25
    26# Runs the linter. Regrettably the linter is very simple and does not provide the ability to exclude rules or files,
    27# so we rely on inverse grepping to do this for us.
    28golint ./... 2>&1 | (
    29  grep -v "gen.go" |
    30    grep -v "disco.go" |
    31    grep -v "exported const DefaultDelayThreshold should have comment" |
    32    grep -v "exported const DefaultBundleCountThreshold should have comment" |
    33    grep -v "exported const DefaultBundleByteThreshold should have comment" |
    34    grep -v "exported const DefaultBufferedByteLimit should have comment" |
    35    grep -v "error var Done should have name of the form ErrFoo" |
    36    grep -v "exported method APIKey.RoundTrip should have comment or be unexported" |
    37    grep -v "exported method MarshalStyle.JSONReader should have comment or be unexported" |
    38    grep -v "UnmarshalJSON should have comment or be unexported" |
    39    grep -v "MarshalJSON should have comment or be unexported" |
    40    grep -v ".Apply should have comment or be unexported" |
    41    grep -vE "\.pb\.go:" || true
    42) | tee /dev/stderr | (! read)
    43
    44staticcheck -go 1.9 ./... 2>&1 | (
    45  grep -v "SA1019" |
    46    grep -v "S1007" |
    47    grep -v "error var Done should have name of the form ErrFoo" |
    48    grep -v "examples" |
    49    grep -v "gen.go" || true
    50) | tee /dev/stderr | (! read)

View as plain text