...

Text file src/github.com/google/s2a-go/tools/internal_ci/run_golang_tests.sh

Documentation: github.com/google/s2a-go/tools/internal_ci

     1# Copyright 2022 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#     https://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
    15#!/bin/bash
    16
    17# Fail on any error.
    18set -e
    19
    20# Display commands being run.
    21set -x
    22
    23readonly PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')"
    24
    25fail_with_debug_output() {
    26  ls -l
    27  df -h /
    28  exit 1
    29}
    30
    31run_tests() {
    32  time go build -buildvcs=false ./... || fail_with_debug_output
    33  time go test -buildvcs=false ./... || fail_with_debug_output
    34}
    35
    36main() {
    37  # Install a newer Golang version on GCP Ubuntu VMs.
    38  which go
    39  sudo rm -rf /usr/local/go
    40  case "${PLATFORM}" in
    41    'linux')
    42      sudo rm -rf /usr/local/go
    43      curl -O https://dl.google.com/go/go1.19.12.linux-amd64.tar.gz
    44      tar -xvf go1.19.12.linux-amd64.tar.gz
    45      sudo mv go /usr/local
    46      export GOROOT=/usr/local/go
    47      export PATH=$PATH:$GOROOT/bin
    48      ;;
    49    'darwin')
    50      sudo rm -rf /usr/local/go
    51      curl -O https://dl.google.com/go/go1.19.12.darwin-amd64.tar.gz
    52      tar -xvf go1.19.12.darwin-amd64.tar.gz
    53      sudo mv go /usr/local
    54      export GOROOT=/usr/local/go
    55      export PATH="${GOROOT}/bin:${PATH}"
    56      ;;
    57    *)
    58      echo "Using existing Go installation."
    59      ;;
    60  esac
    61  go version
    62
    63  run_tests
    64}
    65
    66main "$@"

View as plain text