Skip to content

Commit d54aa36

Browse files
[CI] Refactor monolithic-* scripts to use common utils.sh
This patch refactors big chunks of the common functionality shared between monolithic-linux.sh and monolithic-windows.sh to a separate script, utils.sh, that is then sourced in both of the files. This makes it a bit easier to maintain the scripts. Platform differences should not be a large deal for the setup here as we are using bash as the shell on both Linux and Windows. Reviewers: lnihlen, gburgessiv, Keenuts, DavidSpickett, dschuff, cmtice, Endilll Reviewed By: DavidSpickett, cmtice Pull Request: #152199
1 parent 281e6d2 commit d54aa36

File tree

3 files changed

+54
-75
lines changed

3 files changed

+54
-75
lines changed

.ci/monolithic-linux.sh

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,15 @@
1313
# run only the relevant tests.
1414
#
1515

16-
set -ex
17-
set -o pipefail
16+
source .ci/utils.sh
1817

19-
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
20-
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
2118
INSTALL_DIR="${BUILD_DIR}/install"
22-
rm -rf "${BUILD_DIR}"
23-
24-
sccache --zero-stats
2519

2620
mkdir -p artifacts/reproducers
2721

28-
# Make sure any clang reproducers will end up as artifacts.
22+
# Make sure any clang reproducers will end up as artifacts
2923
export CLANG_CRASH_DIAGNOSTICS_DIR=`realpath artifacts/reproducers`
3024

31-
function at-exit {
32-
retcode=$?
33-
34-
sccache --show-stats > artifacts/sccache_stats.txt
35-
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
36-
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
37-
38-
# If building fails there will be no results files.
39-
shopt -s nullglob
40-
41-
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
42-
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
43-
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
44-
fi
45-
}
46-
trap at-exit EXIT
47-
48-
function start-group {
49-
groupname=$1
50-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
51-
echo "::endgroup"
52-
echo "::group::$groupname"
53-
elif [[ "$POSTCOMMIT_CI" != "" ]]; then
54-
echo "@@@$STEP@@@"
55-
else
56-
echo "Starting $groupname"
57-
fi
58-
}
59-
6025
projects="${1}"
6126
targets="${2}"
6227
runtimes="${3}"

.ci/monolithic-windows.sh

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,7 @@
1313
# run only the relevant tests.
1414
#
1515

16-
set -ex
17-
set -o pipefail
18-
19-
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
20-
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
21-
22-
rm -rf "${BUILD_DIR}"
23-
24-
sccache --zero-stats
25-
function at-exit {
26-
retcode=$?
27-
28-
mkdir -p artifacts
29-
sccache --show-stats >> artifacts/sccache_stats.txt
30-
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
31-
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 [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
37-
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
38-
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
39-
fi
40-
}
41-
trap at-exit EXIT
42-
43-
function start-group {
44-
groupname=$1
45-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
46-
echo "::endgroup"
47-
echo "::group::$groupname"
48-
elif [[ "$POSTCOMMIT_CI" != "" ]]; then
49-
echo "@@@$STEP@@@"
50-
else
51-
echo "Starting $groupname"
52-
fi
53-
}
16+
source .ci/utils.sh
5417

5518
projects="${1}"
5619
targets="${2}"

.ci/utils.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/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:="$(git rev-parse --show-toplevel)"}"
17+
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
18+
19+
rm -rf "${BUILD_DIR}"
20+
21+
sccache --zero-stats
22+
23+
function at-exit {
24+
retcode=$?
25+
26+
mkdir -p artifacts
27+
sccache --show-stats >> artifacts/sccache_stats.txt
28+
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
29+
cp "${BUILD_DIR}"/test-results.*.xml artifacts/ || :
30+
31+
# If building fails there will be no results files.
32+
shopt -s nullglob
33+
34+
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
35+
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
36+
$retcode "${BUILD_DIR}"/test-results.*.xml >> $GITHUB_STEP_SUMMARY
37+
fi
38+
}
39+
trap at-exit EXIT
40+
41+
function start-group {
42+
groupname=$1
43+
if [[ "$GITHUB_ACTIONS" != "" ]]; then
44+
echo "::endgroup"
45+
echo "::group::$groupname"
46+
elif [[ "$POSTCOMMIT_CI" != "" ]]; then
47+
echo "@@@$STEP@@@"
48+
else
49+
echo "Starting $groupname"
50+
fi
51+
}

0 commit comments

Comments
 (0)