Skip to content

Commit 680d425

Browse files
committed
Set 90 minutes timeout to sbt builds and try to restart, keep 2h long timeout while build
1 parent 8d187bd commit 680d425

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

.github/actions/build-project/action.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ runs:
182182
183183
exit_code=${PIPESTATUS[0]}
184184
if [ $exit_code -eq 124 ]; then
185-
echo "::warning title=Build timeout after 2 hours"
186185
echo "Build timeout after 2 hours" >> build-logs.txt
187186
echo "timeout" > build-status.txt
188187
fi

project-builder/sbt/build.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ function runSbt() {
7878
setScalaVersionCmd="++$scalaVersion!"
7979
fi
8080
tq='"""'
81-
sbt ${sbtSettings[@]} \
81+
# Timeout 90 minutes
82+
timeout 5400 \
83+
sbt ${sbtSettings[@]} \
8284
"setCrossScalaVersions $scalaVersion" \
8385
"$setScalaVersionCmd -v" \
8486
"mapScalacOptions \"$appendScalacOptions\" \"$removeScalacOptions\"" \
@@ -88,20 +90,28 @@ function runSbt() {
8890
"$customCommands" \
8991
"moduleMappings" \
9092
"runBuild ${scalaVersion} ${tq}${projectConfig}${tq} $targetsString" 2>&1 | tee $logFile
93+
94+
exit_code=${PIPESTATUS[0]}
95+
if [ $exit_code -eq 124 ]; then
96+
echo "Build timeout" >> build-logs.txt
97+
echo "timeout" > $statusFile
98+
fi
99+
return $exit_code
91100
}
92101

93102
buildTimeouts=0
94103

95104
function checkLogsForRetry() {
96105
# Retry only when given modes were not tried yet
97106
shouldRetry=false
98-
# Timeout
99-
if [ "$buildTimeouts" -eq 0 ]; then
100-
if grep -q "timeout" "$statusFile"; then
101-
buildTimeouts=$((buildTimeouts + 1))
107+
if grep -q "timeout" "$statusFile"; then
108+
buildTimeouts=$((buildTimeouts + 1))
109+
if [ "$buildTimeouts" -le 1 ]; then
110+
echo "Build timeouts: $buildTimeouts, would retry"
102111
shouldRetry=true
103112
return 0
104113
fi
114+
echo "Build timeouts: $buildTimeouts, would not try to restart"
105115
fi
106116

107117
# Failed to download artifacts
@@ -143,7 +153,7 @@ function retryBuild() {
143153
while [[ $retry -lt $maxRetries ]]; do
144154
checkLogsForRetry
145155
if [[ "$shouldRetry" == "true" ]]; then
146-
retry+=1
156+
retry=$((retry + 1))
147157
echo "Retrying build, retry $retry/$maxRetries, force Scala version:$forceScalaVersion, enable migration:$enableMigrationMode"
148158
runSbt && exit 0
149159
else

0 commit comments

Comments
 (0)