Skip to content

Commit 33c14f1

Browse files
ldionneEricWF
andauthored
[libc++] Add output groups to run-buildbot (llvm#111739)
This improves the CI output by providing collapsable sections for sub-parts of our build. This was originally opened as llvm#75233. Co-authored-by: eric <[email protected]>
1 parent 923fef9 commit 33c14f1

File tree

1 file changed

+73
-34
lines changed

1 file changed

+73
-34
lines changed

libcxx/utils/ci/run-buildbot

Lines changed: 73 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# ===----------------------------------------------------------------------===##
99

10-
set -ex
10+
set -e
1111
set -o pipefail
1212
unset LANG
1313
unset LC_ALL
@@ -96,12 +96,37 @@ if [ -z "${CMAKE}" ]; then
9696
fi
9797
fi
9898

99+
function step() {
100+
endstep
101+
set +x
102+
if [[ ! -z ${GITHUB_ACTIONS+x} ]]; then
103+
echo "::group::$1"
104+
export IN_GROUP=1
105+
else
106+
echo "--- $1"
107+
fi
108+
set -x
109+
}
110+
111+
function endstep() {
112+
set +x
113+
if [[ ! -z ${GITHUB_ACTIONS+x} ]] && [[ ! -z ${IN_GROUP+x} ]]; then
114+
echo "::endgroup::"
115+
unset IN_GROUP
116+
fi
117+
set -x
118+
}
119+
120+
function error() {
121+
echo "::error::$1"
122+
}
123+
99124
function clean() {
100125
rm -rf "${BUILD_DIR}"
101126
}
102127

103128
function generate-cmake-base() {
104-
echo "--- Generating CMake"
129+
step "Generating CMake"
105130
${CMAKE} \
106131
-S "${MONOREPO_ROOT}/runtimes" \
107132
-B "${BUILD_DIR}" \
@@ -138,29 +163,32 @@ function generate-cmake-android() {
138163
}
139164

140165
function check-runtimes() {
141-
echo "+++ Running the libc++ tests"
166+
step "Building libc++ test dependencies"
167+
${NINJA} -vC "${BUILD_DIR}" cxx-test-depends
168+
169+
step "Running the libc++ tests"
142170
${NINJA} -vC "${BUILD_DIR}" check-cxx
143171

144-
echo "+++ Running the libc++abi tests"
172+
step "Running the libc++abi tests"
145173
${NINJA} -vC "${BUILD_DIR}" check-cxxabi
146174

147-
echo "+++ Running the libunwind tests"
175+
step "Running the libunwind tests"
148176
${NINJA} -vC "${BUILD_DIR}" check-unwind
149177
}
150178

151179
# TODO: The goal is to test this against all configurations. We should also move
152180
# this to the Lit test suite instead of being a separate CMake target.
153181
function check-abi-list() {
154-
echo "+++ Running the libc++ ABI list test"
182+
step "Running the libc++ ABI list test"
155183
${NINJA} -vC "${BUILD_DIR}" check-cxx-abilist || (
156-
echo "+++ Generating the libc++ ABI list after failed check"
184+
error "Generating the libc++ ABI list after failed check"
157185
${NINJA} -vC "${BUILD_DIR}" generate-cxx-abilist
158186
false
159187
)
160188
}
161189

162190
function check-cxx-benchmarks() {
163-
echo "--- Running the benchmarks"
191+
step "Running the benchmarks"
164192
${NINJA} -vC "${BUILD_DIR}" check-cxx-benchmarks
165193
}
166194

@@ -170,12 +198,13 @@ function test-armv7m-picolibc() {
170198
# To make it easier to get this builder up and running, build picolibc
171199
# from scratch. Anecdotally, the build-picolibc script takes about 16 seconds.
172200
# This could be optimised by building picolibc into the Docker container.
201+
step "Building picolibc from source"
173202
${MONOREPO_ROOT}/libcxx/utils/ci/build-picolibc.sh \
174203
--build-dir "${BUILD_DIR}" \
175204
--install-dir "${INSTALL_DIR}" \
176205
--target armv7m-none-eabi
177206

178-
echo "--- Generating CMake"
207+
step "Generating CMake for compiler-rt"
179208
flags="--sysroot=${INSTALL_DIR}"
180209
${CMAKE} \
181210
-S "${MONOREPO_ROOT}/compiler-rt" \
@@ -187,6 +216,8 @@ function test-armv7m-picolibc() {
187216
-DCMAKE_CXX_FLAGS="${flags}" \
188217
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
189218
"${@}"
219+
220+
step "Generating CMake for libc++"
190221
generate-cmake \
191222
-DLIBCXX_TEST_CONFIG="armv7m-picolibc-libc++.cfg.in" \
192223
-DLIBCXXABI_TEST_CONFIG="armv7m-picolibc-libc++abi.cfg.in" \
@@ -195,6 +226,7 @@ function test-armv7m-picolibc() {
195226
-DCMAKE_CXX_FLAGS="${flags}" \
196227
"${@}"
197228

229+
step "Installing compiler-rt"
198230
${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
199231

200232
# Prior to clang 19, armv7m-none-eabi normalised to armv7m-none-unknown-eabi.
@@ -208,9 +240,9 @@ function test-armv7m-picolibc() {
208240
}
209241

210242
# Print the version of a few tools to aid diagnostics in some cases
243+
step "Diagnose tools in use"
211244
${CMAKE} --version
212245
${NINJA} --version
213-
214246
if [ ! -z "${CXX}" ]; then ${CXX} --version; fi
215247

216248
case "${BUILDER}" in
@@ -220,10 +252,9 @@ check-generated-output)
220252
clean
221253
generate-cmake
222254

223-
set +x # Printing all the commands below just creates extremely confusing output
224-
225255
# Reject patches that forgot to re-run the generator scripts.
226-
echo "+++ Making sure the generator scripts were run"
256+
step "Making sure the generator scripts were run"
257+
set +x # Printing all the commands below just creates extremely confusing output
227258
${NINJA} -vC "${BUILD_DIR}" libcxx-generate-files
228259
git diff | tee ${BUILD_DIR}/generated_output.patch
229260
git ls-files -o --exclude-standard | tee ${BUILD_DIR}/generated_output.status
@@ -235,9 +266,8 @@ check-generated-output)
235266
false
236267
fi
237268

238-
# Reject patches that introduce non-ASCII characters or hard tabs.
239-
# Depends on LC_COLLATE set at the top of this script.
240-
set -x
269+
# This depends on LC_COLLATE set at the top of this script.
270+
step "Reject patches that introduce non-ASCII characters or hard tabs."
241271
! grep -rn '[^ -~]' libcxx/include libcxx/src libcxx/test \
242272
--exclude '*.dat' \
243273
--exclude '*unicode*.cpp' \
@@ -345,7 +375,7 @@ generic-ubsan)
345375
bootstrapping-build)
346376
clean
347377

348-
echo "--- Generating CMake"
378+
step "Generating CMake"
349379
${CMAKE} \
350380
-S "${MONOREPO_ROOT}/llvm" \
351381
-B "${BUILD_DIR}" \
@@ -362,14 +392,14 @@ bootstrapping-build)
362392
-DLLVM_ENABLE_ASSERTIONS=ON \
363393
-DLLVM_LIT_ARGS="-sv --xunit-xml-output test-results.xml --timeout=1500 --time-tests"
364394

365-
echo "+++ Running the LLDB libc++ data formatter tests"
395+
step "Running the LLDB libc++ data formatter tests"
366396
${NINJA} -vC "${BUILD_DIR}" lldb-api-test-deps
367397
${BUILD_DIR}/bin/llvm-lit -sv --param dotest-args='--category libc++' "${MONOREPO_ROOT}/lldb/test/API"
368398

369-
echo "--- Running the libc++ and libc++abi tests"
399+
step "Running the libc++ and libc++abi tests"
370400
${NINJA} -vC "${BUILD_DIR}" check-runtimes
371401

372-
echo "+++ Installing libc++ and libc++abi to a fake location"
402+
step "Installing libc++ and libc++abi to a fake location"
373403
${NINJA} -vC "${BUILD_DIR}" install-runtimes
374404

375405
ccache -s
@@ -502,6 +532,7 @@ generic-optimized-speed)
502532
apple-configuration)
503533
clean
504534

535+
step "Installing libc++ with the Apple system configuration"
505536
arch="$(uname -m)"
506537
xcrun --sdk macosx \
507538
${MONOREPO_ROOT}/libcxx/utils/ci/apple-install-libcxx.sh \
@@ -512,6 +543,7 @@ apple-configuration)
512543
--architectures "${arch}" \
513544
--version "999.99"
514545

546+
step "Running tests against Apple-configured libc++"
515547
# TODO: It would be better to run the tests against the fake-installed version of libc++ instead
516548
xcrun --sdk macosx ninja -vC "${BUILD_DIR}/${arch}" check-cxx check-cxxabi check-cxx-abilist
517549
;;
@@ -524,6 +556,7 @@ apple-system-hardened)
524556
params+=";hardening_mode=fast"
525557

526558
# In the Apple system configuration, we build libc++ and libunwind separately.
559+
step "Installing libc++ and libc++abi in Apple-system configuration"
527560
${CMAKE} \
528561
-S "${MONOREPO_ROOT}/runtimes" \
529562
-B "${BUILD_DIR}/cxx" \
@@ -539,6 +572,7 @@ apple-system-hardened)
539572
-DLIBCXX_TEST_PARAMS="${params}" \
540573
-DLIBCXXABI_TEST_PARAMS="${params}"
541574

575+
step "Installing libunwind in Apple-system configuration"
542576
${CMAKE} \
543577
-S "${MONOREPO_ROOT}/runtimes" \
544578
-B "${BUILD_DIR}/unwind" \
@@ -551,13 +585,13 @@ apple-system-hardened)
551585
-DLIBUNWIND_TEST_PARAMS="${params}" \
552586
-DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
553587

554-
echo "+++ Running the libc++ tests"
588+
step "Running the libc++ tests"
555589
${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
556590

557-
echo "+++ Running the libc++abi tests"
591+
step "Running the libc++abi tests"
558592
${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
559593

560-
echo "+++ Running the libunwind tests"
594+
step "Running the libunwind tests"
561595
${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
562596
;;
563597
apple-system)
@@ -568,6 +602,7 @@ apple-system)
568602
params="target_triple=${arch}-apple-macosx${version}"
569603

570604
# In the Apple system configuration, we build libc++ and libunwind separately.
605+
step "Installing libc++ and libc++abi in Apple-system configuration"
571606
${CMAKE} \
572607
-S "${MONOREPO_ROOT}/runtimes" \
573608
-B "${BUILD_DIR}/cxx" \
@@ -583,6 +618,7 @@ apple-system)
583618
-DLIBCXX_TEST_PARAMS="${params}" \
584619
-DLIBCXXABI_TEST_PARAMS="${params}"
585620

621+
step "Installing libunwind in Apple-system configuration"
586622
${CMAKE} \
587623
-S "${MONOREPO_ROOT}/runtimes" \
588624
-B "${BUILD_DIR}/unwind" \
@@ -595,13 +631,13 @@ apple-system)
595631
-DLIBUNWIND_TEST_PARAMS="${params}" \
596632
-DCMAKE_INSTALL_NAME_DIR="/usr/lib/system"
597633

598-
echo "+++ Running the libc++ tests"
634+
step "Running the libc++ tests"
599635
${NINJA} -vC "${BUILD_DIR}/cxx" check-cxx
600636

601-
echo "+++ Running the libc++abi tests"
637+
step "Running the libc++abi tests"
602638
${NINJA} -vC "${BUILD_DIR}/cxx" check-cxxabi
603639

604-
echo "+++ Running the libunwind tests"
640+
step "Running the libunwind tests"
605641
${NINJA} -vC "${BUILD_DIR}/unwind" check-unwind
606642
;;
607643
benchmarks)
@@ -664,13 +700,13 @@ clang-cl-dll)
664700
# anyway), thus just disable the experimental library. Remove this
665701
# setting when cmake and the test driver does the right thing automatically.
666702
generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False"
667-
echo "+++ Running the libc++ tests"
703+
step "Running the libc++ tests"
668704
${NINJA} -vC "${BUILD_DIR}" check-cxx
669705
;;
670706
clang-cl-static)
671707
clean
672708
generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF
673-
echo "+++ Running the libc++ tests"
709+
step "Running the libc++ tests"
674710
${NINJA} -vC "${BUILD_DIR}" check-cxx
675711
;;
676712
clang-cl-no-vcruntime)
@@ -681,14 +717,14 @@ clang-cl-no-vcruntime)
681717
# exceptions enabled.
682718
generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
683719
-DLIBCXX_TEST_CONFIG="llvm-libc++-shared-no-vcruntime-clangcl.cfg.in"
684-
echo "+++ Running the libc++ tests"
720+
step "Running the libc++ tests"
685721
${NINJA} -vC "${BUILD_DIR}" check-cxx
686722
;;
687723
clang-cl-debug)
688724
clean
689725
generate-cmake-libcxx-win -DLIBCXX_TEST_PARAMS="enable_experimental=False" \
690726
-DCMAKE_BUILD_TYPE=Debug
691-
echo "+++ Running the libc++ tests"
727+
step "Running the libc++ tests"
692728
${NINJA} -vC "${BUILD_DIR}" check-cxx
693729
;;
694730
clang-cl-static-crt)
@@ -697,7 +733,7 @@ clang-cl-static-crt)
697733
# the static CRT, as opposed to "MultiThreadedDLL" which is the default).
698734
generate-cmake-libcxx-win -DLIBCXX_ENABLE_SHARED=OFF \
699735
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
700-
echo "+++ Running the libc++ tests"
736+
step "Running the libc++ tests"
701737
${NINJA} -vC "${BUILD_DIR}" check-cxx
702738
;;
703739
mingw-dll)
@@ -743,6 +779,7 @@ mingw-incomplete-sysroot)
743779
-C "${MONOREPO_ROOT}/libcxx/cmake/caches/MinGW.cmake"
744780
# Only test that building succeeds; there's not much extra value in running
745781
# the tests here, as it would be equivalent to the mingw-dll config above.
782+
step "Building the runtimes"
746783
${NINJA} -vC "${BUILD_DIR}"
747784
;;
748785
aix)
@@ -760,7 +797,7 @@ android-ndk-*)
760797
ANDROID_EMU_IMG="${BUILDER#android-ndk-}"
761798
. "${MONOREPO_ROOT}/libcxx/utils/ci/vendor/android/emulator-functions.sh"
762799
if ! validate_emu_img "${ANDROID_EMU_IMG}"; then
763-
echo "error: android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG})" >&2
800+
error "android-ndk suffix must be a valid emulator image (${ANDROID_EMU_IMG})" >&2
764801
exit 1
765802
fi
766803
ARCH=$(arch_of_emu_img ${ANDROID_EMU_IMG})
@@ -792,9 +829,9 @@ android-ndk-*)
792829
# directories.
793830
adb shell mkdir -p /data/local/tmp/adb_run
794831
adb push "${BUILD_DIR}/lib/libc++_shared.so" /data/local/tmp/libc++/libc++_shared.so
795-
echo "+++ Running the libc++ tests"
832+
step "Running the libc++ tests"
796833
${NINJA} -vC "${BUILD_DIR}" check-cxx
797-
echo "+++ Running the libc++abi tests"
834+
step "Running the libc++abi tests"
798835
${NINJA} -vC "${BUILD_DIR}" check-cxxabi
799836
;;
800837
#################################################################
@@ -810,3 +847,5 @@ android-ndk-*)
810847
exit 1
811848
;;
812849
esac
850+
851+
endstep # Make sure we close any still-open output group

0 commit comments

Comments
 (0)