...

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

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

     1#!/bin/bash
     2
     3# Copyright 2018 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 any error
     8set -eo pipefail
     9
    10export GOOGLE_APPLICATION_CREDENTIALS="${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-service-account"
    11export GOOGLE_CLOUD_PROJECT="dulcet-port-762"
    12export GCLOUD_TESTS_IMPERSONATE_READER_KEY="${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-impersonate-reader-service-account"
    13export GCLOUD_TESTS_IMPERSONATE_READER_EMAIL="impersonate-reader@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"
    14export GCLOUD_TESTS_IMPERSONATE_WRITER_EMAIL="impersonate-writer@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com"
    15export GCLOUD_TESTS_GOLANG_PROJECT_NUMBER=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-project-number)
    16export GCLOUD_TESTS_GOLANG_SERVICE_ACCOUNT_CLIENT_ID=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-client-id)
    17export GCLOUD_TESTS_GOLANG_AWS_ACCOUNT_ID=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aws-acc-id)
    18export GCLOUD_TESTS_GOLANG_AWS_ROLE_NAME=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aws-role-name)
    19export GCLOUD_TESTS_GOLANG_AWS_ROLE_ID="arn:aws:iam::$GCLOUD_TESTS_GOLANG_AWS_ACCOUNT_ID:role/$GCLOUD_TESTS_GOLANG_AWS_ROLE_NAME"
    20export GCLOUD_TESTS_GOLANG_AUDIENCE_OIDC=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aud-oidc)
    21export GCLOUD_TESTS_GOLANG_AUDIENCE_AWS=$(cat ${KOKORO_GFILE_DIR}/secret_manager/go-cloud-integration-byoid-aud-aws)
    22export GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES="1"
    23export GOOGLE_API_GO_EXPERIMENTAL_ENABLE_NEW_AUTH_LIB="true"
    24
    25# Display commands being run
    26set -x
    27
    28# cd to project dir on Kokoro instance
    29cd github/google-api-go-client
    30
    31go version
    32
    33# Set $GOPATH
    34export GOPATH="$HOME/go"
    35export GOCLOUD_HOME=$GOPATH/src/google.golang.org/api/
    36export PATH="$GOPATH/bin:$PATH"
    37export GO111MODULE=on
    38mkdir -p $GOCLOUD_HOME
    39
    40# Move code into $GOPATH and get dependencies
    41git clone . $GOCLOUD_HOME
    42cd $GOCLOUD_HOME
    43
    44try3() { eval "$*" || eval "$*" || eval "$*"; }
    45
    46# All packages, including +build tools, are fetched.
    47try3 go mod download
    48./internal/kokoro/vet.sh
    49
    50# Testing the generator itself depends on a generation step
    51cd google-api-go-generator
    52go generate
    53cd ..
    54
    55set +e # Run all tests, don't stop after the first failure.
    56exit_code=0
    57
    58# Run tests and tee output to log file, to be pushed to GCS as artifact.
    59if [[ $KOKORO_JOB_NAME == *"continuous"* ]]; then
    60    go test -race -v ./... 2>&1 | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt
    61    # Takes the kokoro output log (raw stdout) and creates a machine-parseable
    62    # xUnit XML file.
    63    cat $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt |
    64        go-junit-report -set-exit-code >sponge_log.xml
    65    exit_code=$(($exit_code + $?))
    66else
    67    go test -race -v -short ./... 2>&1 | tee $KOKORO_ARTIFACTS_DIR/$KOKORO_GERRIT_CHANGE_NUMBER.txt
    68    exit_code=$(($exit_code + $?))
    69fi
    70
    71if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
    72    chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
    73    $KOKORO_GFILE_DIR/linux_amd64/flakybot -logs_dir=$GOCLOUD_HOME \
    74        -repo=googleapis/google-api-go-client \
    75        -commit_hash=$KOKORO_GITHUB_COMMIT_URL_google_api_go_client
    76fi
    77
    78exit $exit_code

View as plain text