Skip to content

Commit 6b01cf3

Browse files
ci: Add logs to calling xcodebuild (#6506)
Include timestamps to ci-utils.sh to know when the echo methods are called and log message just before calling xcodebuild to identify if this command is handing in CI, because we frequently see running tests timing out in CI.
1 parent 827b50c commit 6b01cf3

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

scripts/ci-utils.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# Utility functions for CI logging and grouping.
44
# This file is intended to be sourced from other scripts.
5+
#
6+
# GitHub Actions workflow commands (::notice::, ::warning::, ::error::, ::group::, ::endgroup::)
7+
# follow the specification at: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands
58

69
# Detect if we are running on GitHub Actions
710
if [ "${GITHUB_ACTIONS:-}" = "true" ]; then
@@ -10,27 +13,32 @@ else
1013
IS_GITHUB_ACTIONS=false
1114
fi
1215

16+
# Get current timestamp in format HH:MM:SS
17+
get_timestamp() {
18+
date +"%T"
19+
}
20+
1321
log_notice() {
1422
if $IS_GITHUB_ACTIONS; then
15-
echo "::notice::${1}"
23+
echo "::notice::[$(get_timestamp)] ${1}"
1624
else
17-
echo "[notice] ${1}"
25+
echo "[notice] [$(get_timestamp)] ${1}"
1826
fi
1927
}
2028

2129
log_warning() {
2230
if $IS_GITHUB_ACTIONS; then
23-
echo "::warning::${1}"
31+
echo "::warning::[$(get_timestamp)] ${1}"
2432
else
25-
echo "[warning] ${1}"
33+
echo "[warning] [$(get_timestamp)] ${1}"
2634
fi
2735
}
2836

2937
log_error() {
3038
if $IS_GITHUB_ACTIONS; then
31-
echo "::error::${1}"
39+
echo "::error::[$(get_timestamp)] ${1}"
3240
else
33-
echo "[error] ${1}"
41+
echo "[error] [$(get_timestamp)] ${1}"
3442
fi
3543
}
3644

@@ -39,7 +47,7 @@ begin_group() {
3947
if $IS_GITHUB_ACTIONS; then
4048
echo "::group::${title}"
4149
else
42-
echo
50+
echo
4351
echo "== ${title} =="
4452
fi
4553
}

scripts/sentry-xcodebuild.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22
set -euxo pipefail
33

4+
# Disable SC1091 because it won't work with pre-commit
5+
# shellcheck source=./scripts/ci-utils.sh disable=SC1091
6+
source "$(cd "$(dirname "$0")" && pwd)/ci-utils.sh"
7+
48
# This is a helper script for GitHub Actions Matrix.
59
# If we would specify the destinations in the GitHub Actions
610
# Matrix, the name of the job would include the destination, which would
@@ -140,9 +144,9 @@ case $COMMAND in
140144
;;
141145
esac
142146

143-
144-
145147
if [ $RUN_BUILD == true ]; then
148+
log_notice "Running xcodebuild build"
149+
146150
set -o pipefail && NSUnbufferedIO=YES xcodebuild \
147151
-workspace Sentry.xcworkspace \
148152
-scheme "$TEST_SCHEME" \
@@ -161,6 +165,8 @@ fi
161165

162166
if [ $RUN_BUILD_FOR_TESTING == true ]; then
163167
# When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan
168+
log_notice "Running xcodebuild build-for-testing"
169+
164170
set -o pipefail && NSUnbufferedIO=YES xcodebuild \
165171
-workspace Sentry.xcworkspace \
166172
-scheme "$TEST_SCHEME" \
@@ -174,7 +180,8 @@ fi
174180

175181
if [ $RUN_TEST_WITHOUT_BUILDING == true ]; then
176182
# When no test plan is provided, we skip the -testPlan argument so xcodebuild uses the default test plan
177-
183+
log_notice "Running xcodebuild test-without-building"
184+
178185
set -o pipefail && NSUnbufferedIO=YES xcodebuild \
179186
-workspace Sentry.xcworkspace \
180187
-scheme "$TEST_SCHEME" \
@@ -186,3 +193,5 @@ if [ $RUN_TEST_WITHOUT_BUILDING == true ]; then
186193
tee raw-test-output.log |
187194
xcbeautify --report junit
188195
fi
196+
197+
log_notice "Finished xcodebuild"

0 commit comments

Comments
 (0)