xref: /aosp_15_r20/external/google-cloud-java/.kokoro/coerce_logs.sh (revision 55e87721aa1bc457b326496a7ca40f3ea1a63287)
1*55e87721SMatt Gilbride#!/bin/bash
2*55e87721SMatt Gilbride# Copyright 2019 Google LLC
3*55e87721SMatt Gilbride#
4*55e87721SMatt Gilbride# Licensed under the Apache License, Version 2.0 (the "License");
5*55e87721SMatt Gilbride# you may not use this file except in compliance with the License.
6*55e87721SMatt Gilbride# You may obtain a copy of the License at
7*55e87721SMatt Gilbride#
8*55e87721SMatt Gilbride#      http://www.apache.org/licenses/LICENSE-2.0
9*55e87721SMatt Gilbride#
10*55e87721SMatt Gilbride# Unless required by applicable law or agreed to in writing, software
11*55e87721SMatt Gilbride# distributed under the License is distributed on an "AS IS" BASIS,
12*55e87721SMatt Gilbride# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*55e87721SMatt Gilbride# See the License for the specific language governing permissions and
14*55e87721SMatt Gilbride# limitations under the License.
15*55e87721SMatt Gilbride
16*55e87721SMatt Gilbride# This script finds and moves sponge logs so that they can be found by placer
17*55e87721SMatt Gilbride# and are not flagged as flaky by sponge.
18*55e87721SMatt Gilbride
19*55e87721SMatt Gilbrideset -eo pipefail
20*55e87721SMatt Gilbride
21*55e87721SMatt Gilbride## Get the directory of the build script
22*55e87721SMatt GilbridescriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
23*55e87721SMatt Gilbride## cd to the parent directory, i.e. the root of the git repo
24*55e87721SMatt Gilbridecd ${scriptDir}/..
25*55e87721SMatt Gilbride
26*55e87721SMatt Gilbrideif [ -z "${KOKORO_JOB_NAME}" ]; then
27*55e87721SMatt Gilbride  job="${JOB_NAME}"
28*55e87721SMatt Gilbrideelse
29*55e87721SMatt Gilbride  job=$(basename ${KOKORO_JOB_NAME})
30*55e87721SMatt Gilbridefi
31*55e87721SMatt Gilbride
32*55e87721SMatt Gilbrideecho "coercing sponge logs..."
33*55e87721SMatt Gilbridefor xml in `find . -name *-sponge_log.xml`
34*55e87721SMatt Gilbridedo
35*55e87721SMatt Gilbride  class=$(basename ${xml} | cut -d- -f2)
36*55e87721SMatt Gilbride  dir=$(dirname ${xml})/${job}/${class}
37*55e87721SMatt Gilbride  text=$(dirname ${xml})/${class}-sponge_log.txt
38*55e87721SMatt Gilbride  mkdir -p ${dir}
39*55e87721SMatt Gilbride  mv ${xml} ${dir}/sponge_log.xml
40*55e87721SMatt Gilbride  mv ${text} ${dir}/sponge_log.txt
41*55e87721SMatt Gilbridedone