• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2023 The gRPC Authors
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
16set -e
17
18EXIT_CODE_FILE="$1"
19SCRIPT_LOG_FILE="$2"
20ARTIFACTS_ARCHIVE="$3"
21shift 3
22
23BUILD_ARTIFACT_EXITCODE="$(cat ${EXIT_CODE_FILE})"
24
25echo "Build artifact/package task for '${ARTIFACTS_ARCHIVE}' has finished with exitcode ${BUILD_ARTIFACT_EXITCODE}."
26
27echo "BUILD LOG"
28echo "--------------"
29cat "${SCRIPT_LOG_FILE}"
30echo "--------------"
31echo
32
33# Try extracting the archive with artifacts (and list the files)
34mkdir -p input_artifacts
35pushd input_artifacts >/dev/null
36echo "Artifacts that were built by the build artifact/package task:"
37echo "--------------"
38# TODO(jtattermusch): strip top level artifacts/ directory from the archive?
39tar -xopvf ../${ARTIFACTS_ARCHIVE}
40echo "--------------"
41popd >/dev/null
42
43# Add artifact archive to the "undeclared test outputs" directory
44# to make it readily available in the resultstore UI.
45# See bazel docs for TEST_UNDECLARED_OUTPUTS_DIR.
46mkdir -p "${TEST_UNDECLARED_OUTPUTS_DIR}"
47cp "${ARTIFACTS_ARCHIVE}" "${TEST_UNDECLARED_OUTPUTS_DIR}" || true
48
49if [ "${BUILD_ARTIFACT_EXITCODE}" -eq "0" ]
50then
51  echo "SUCCESS: Build artifact/package task for '${ARTIFACTS_ARCHIVE}' ran successfully."
52else
53  echo "FAIL: Build artifact/package task for '${ARTIFACTS_ARCHIVE}' failed with exitcode ${BUILD_ARTIFACT_EXITCODE}."
54  exit 1
55fi
56