1#!/bin/bash 2# Copyright 2019 Google LLC 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 16# This script finds and moves sponge logs so that they can be found by placer 17# and are not flagged as flaky by sponge. 18 19set -eo pipefail 20 21## Get the directory of the build script 22scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) 23## cd to the parent directory, i.e. the root of the git repo 24cd ${scriptDir}/.. 25 26if [ -z "${KOKORO_JOB_NAME}" ]; then 27 job="${JOB_NAME}" 28else 29 job=$(basename ${KOKORO_JOB_NAME}) 30fi 31 32echo "coercing sponge logs..." 33for xml in `find . -name *-sponge_log.xml` 34do 35 class=$(basename ${xml} | cut -d- -f2) 36 dir=$(dirname ${xml})/${job}/${class} 37 text=$(dirname ${xml})/${class}-sponge_log.txt 38 mkdir -p ${dir} 39 mv ${xml} ${dir}/sponge_log.xml 40 mv ${text} ${dir}/sponge_log.txt 41done