github.com/ecodeclub/eorm@v0.0.2-0.20231001112437-dae71da914d0/.github/pre-push (about)

     1  #!/bin/sh
     2  # Copyright 2021 ecodeclub
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  # http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  # git test pre-push hook
    16  #
    17  # To use, store as .git/hooks/pre-push inside your repository and make sure
    18  # it has execute permissions.
    19  #
    20  # This script does not handle file names that contain spaces.
    21  
    22  # Pre-push configuration
    23  remote=$1
    24  url=$2
    25  echo >&2 "Try pushing $2 to $1"
    26  
    27  TEST="go test ./... -race -cover -failfast"
    28  LINTER="golangci-lint run"
    29  
    30  # Run test and return if failed
    31  printf "Running go test..."
    32  $TEST
    33  RESULT=$?
    34  if [ $RESULT -ne 0 ]; then
    35    echo >&2 "$TEST"
    36    echo >&2 "Check code to pass test."
    37    exit 1
    38  fi
    39  
    40  # Run linter and return if failed
    41  printf "Running go linter..."
    42  $LINTER
    43  RESULT=$?
    44  if [ $RESULT -ne 0 ]; then
    45    echo >&2 "$LINTER"
    46    echo >&2 "Check code to pass linter."
    47    exit 1
    48  fi
    49  
    50  exit 0