| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | #===----------------------------------------------------------------------===## |
| 3 | # |
| 4 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | # See https://llvm.org/LICENSE.txt for license information. |
| 6 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | # |
| 8 | #===----------------------------------------------------------------------===## |
| 9 | |
| 10 | # This script performs some setup and contains some utilities used for in the |
| 11 | # monolithic-linux.sh and monolithic-windows.sh scripts. |
| 12 | |
| 13 | set -ex |
| 14 | set -o pipefail |
| 15 | |
| 16 | MONOREPO_ROOT="${MONOREPO_ROOT:="$(gitscip-shell system . . git. rev-parse --show-toplevel)"}" |
| 17 | BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}" |
| 18 | |
| 19 | rmscip-shell system . . rm. -rf "${BUILD_DIR}" |
| 20 | |
| 21 | sccache --zero-stats |
| 22 | |
| 23 | function at-exitscip-shell shell llvm-toolchain-22 1:22.1.7-1 at-exit(). { |
| 24 | retcode=$? |
| 25 | |
| 26 | mkdirscip-shell system . . mkdir. -p artifacts |
| 27 | sccache --show-stats |
| 28 | sccache --show-stats >> artifacts/sccache_stats.txt |
| 29 | cpscip-shell system . . cp. "${MONOREPO_ROOT}"/*.ninja_log artifacts/ || : |
| 30 | cpscip-shell system . . cp. "${MONOREPO_ROOT}"/*.log artifacts/ || : |
| 31 | cpscip-shell system . . cp. "${BUILD_DIR}"/test-results.*.xml artifacts/ || : |
| 32 | |
| 33 | # If building fails there will be no results files. |
| 34 | shopt -s nullglob |
| 35 | |
| 36 | if [[ -n "$GITHUB_ACTIONS" ]]; then |
| 37 | python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \ |
| 38 | $retcode "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log \ |
| 39 | >> $GITHUB_STEP_SUMMARY |
| 40 | if [[ -n "$GITHUB_PR_NUMBER" ]]; then |
| 41 | (pythscip-shell system . . git.on "${MONOREPO_ROOT}"/.ci/premerge_advisor_explain.py \ |
| 42 | $(git rev-parse HEAD~1) $retcode "${GITHUB_TOKEN}" \ |
| 43 | $GITHUB_PR_NUMBER "${BUILD_DIR}"/test-results.*.xml \ |
| 44 | "${MONOREPO_ROOT}"/ninja*.log) |
| 45 | advisor_retcode=$? |
| 46 | else |
| 47 | advisor_retcode=$retcode |
| 48 | fi |
| 49 | fi |
| 50 | |
| 51 | if [[ "$retcode" != "0" ]]; then |
| 52 | if [[ -n "$GITHUB_ACTIONS" ]]; then |
| 53 | pythoscip-shell system . . git.n "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \ |
| 54 | $(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \ |
| 55 | "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log |
| 56 | else |
| 57 | pythoscip-shell system . . git.n "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \ |
| 58 | $(git rev-parse HEAD) $BUILDBOT_BUILDNUMBER \ |
| 59 | "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log |
| 60 | fi |
| 61 | fi |
| 62 | |
| 63 | if [[ -n "$GITHUB_ACTIONS" ]]; then |
| 64 | exit $advisor_retcode |
| 65 | fi |
| 66 | } |
| 67 | trap at-exit EXIT |
| 68 | |
| 69 | function start-groupscip-shell shell llvm-toolchain-22 1:22.1.7-1 start-group(). { |
| 70 | groupname=$1 |
| 71 | if [[ -n "$GITHUB_ACTIONS" ]]; then |
| 72 | echoscip-shell system . . echo. "::endgroup" |
| 73 | echoscip-shell system . . echo. "::group::$groupname" |
| 74 | elif [[ -n "$POSTCOMMIT_CI" ]]; then |
| 75 | echoscip-shell system . . echo. "@@@$STEP@@@" |
| 76 | else |
| 77 | echoscip-shell system . . echo. "Starting $groupname" |
| 78 | fi |
| 79 | } |
| 80 | |
| 81 | export PIP_BREAK_SYSTEM_PACKAGES=1 |
| 82 | pipscip-shell system . . pip. install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt |
| 83 | |
| 84 | # The ARM64 builders run on AWS and don't have access to the GCS cache. |
| 85 | if [[ -n "$GITHUB_ACTIONS" ]] && [[ "$RUNNER_ARCH" != "ARM64" ]]; then |
| 86 | python .ci/cache_lit_timing_files.py download |
| 87 | fi |