Skip to content

Commit fa8bc74

Browse files
authored
[release test] edit shell script styling in run_release_test.sh (#58670)
use double brackets as much as possible Signed-off-by: Lonnie Liu <lonnie@anyscale.com>
1 parent c446399 commit fa8bc74

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

release/run_release_test.sh

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,21 @@
33

44
set -e
55

6-
if [ -n "$DEBUG" ]; then
7-
set -x
8-
fi
9-
106
cd "${0%/*}" || exit 1
117

128
reason() {
139
# Keep in sync with e2e.py ExitCode enum
14-
if [ "$1" -eq 0 ]; then
10+
if [[ "$1" -eq 0 ]]; then
1511
REASON="success"
16-
elif [ "$1" -ge 1 ] && [ "$1" -lt 10 ]; then
12+
elif [[ "$1" -ge 1 && "$1" -lt 10 ]]; then
1713
REASON="runtime error"
18-
elif [ "$1" -ge 10 ] && [ "$1" -lt 20 ]; then
14+
elif [[ "$1" -ge 10 && "$1" -lt 20 ]]; then
1915
REASON="infra error"
20-
elif [ "$1" -ge 30 ] && [ "$1" -lt 40 ]; then
16+
elif [[ "$1" -ge 30 && "$1" -lt 40 ]]; then
2117
REASON="infra timeout"
22-
elif [ "$1" -eq 42 ]; then
18+
elif [[ "$1" -eq 42 ]]; then
2319
REASON="command timeout"
24-
elif [ "$1" -ge 40 ] && [ "$1" -lt 50 ]; then
20+
elif [[ "$1" -ge 40 && "$1" -lt 50 ]]; then
2521
REASON="command error"
2622
fi
2723
echo "${REASON}"
@@ -35,7 +31,7 @@ BUILDKITE_TIME_LIMIT_FOR_RETRY=10800 # 3 hours
3531

3632
export RAY_TEST_REPO RAY_TEST_BRANCH RELEASE_RESULTS_DIR BUILDKITE_MAX_RETRIES BUILDKITE_RETRY_CODE BUILDKITE_TIME_LIMIT_FOR_RETRY
3733

38-
if [ -n "${RAY_COMMIT_OF_WHEEL-}" ]; then
34+
if [[ -n "${RAY_COMMIT_OF_WHEEL-}" ]]; then
3935
git config --global --add safe.directory /workdir
4036
HEAD_COMMIT=$(git rev-parse HEAD)
4137
echo "The test repo has head commit of ${HEAD_COMMIT}"
@@ -48,7 +44,7 @@ if [ -n "${RAY_COMMIT_OF_WHEEL-}" ]; then
4844
fi
4945
fi
5046

51-
if [ -z "${NO_INSTALL}" ]; then
47+
if [[ -z "${NO_INSTALL}" ]]; then
5248
# Strip the hashes from the constraint file
5349
# TODO(aslonnie): use bazel run..
5450
grep '==' ./requirements_buildkite.txt > /tmp/requirements_buildkite_nohash.txt
@@ -60,20 +56,20 @@ fi
6056
RETRY_NUM=0
6157
MAX_RETRIES=${MAX_RETRIES-1}
6258

63-
if [ "${BUILDKITE_RETRY_COUNT-0}" -ge 1 ]; then
59+
if [[ "${BUILDKITE_RETRY_COUNT-0}" -ge 1 ]]; then
6460
echo "This is a manually triggered retry from the Buildkite web UI, so we set the number of infra retries to 1."
6561
MAX_RETRIES=1
6662
fi
6763

6864
ALL_EXIT_CODES=()
69-
while [ "$RETRY_NUM" -lt "$MAX_RETRIES" ]; do
65+
while [[ "$RETRY_NUM" -lt "$MAX_RETRIES" ]]; do
7066
RETRY_NUM=$((RETRY_NUM + 1))
7167

72-
if [ "$RETRY_NUM" -gt 1 ]; then
68+
if [[ "$RETRY_NUM" -gt 1 ]]; then
7369
# Sleep for random time between 30 and 90 minutes
7470
SLEEP_TIME=$((1800 + RANDOM % 5400))
7571

76-
if [ -n "${OVERRIDE_SLEEP_TIME}" ]; then
72+
if [[ -n "${OVERRIDE_SLEEP_TIME}" ]]; then
7773
SLEEP_TIME=${OVERRIDE_SLEEP_TIME}
7874
fi
7975

@@ -83,7 +79,7 @@ while [ "$RETRY_NUM" -lt "$MAX_RETRIES" ]; do
8379
sleep "${SLEEP_TIME}"
8480
fi
8581

86-
if [ -z "${NO_ARTIFACTS}" ]; then
82+
if [[ -z "${NO_ARTIFACTS}" ]]; then
8783
rm -rf "${RELEASE_RESULTS_DIR:?}"/* || true
8884
fi
8985

@@ -131,7 +127,7 @@ while [ "$RETRY_NUM" -lt "$MAX_RETRIES" ]; do
131127

132128
done
133129

134-
if [ -z "${NO_ARTIFACTS}" ]; then
130+
if [[ -z "${NO_ARTIFACTS}" ]]; then
135131
rm -rf /tmp/ray_release_test_artifacts/* || true
136132
cp -rf "${RELEASE_RESULTS_DIR}"/* /tmp/ray_release_test_artifacts/ || true
137133
fi
@@ -152,9 +148,9 @@ echo "----------------------------------------"
152148
REASON=$(reason "${EXIT_CODE}")
153149
echo "Final release test exit code is ${EXIT_CODE} (${REASON}). Took ${RUNTIME}s"
154150

155-
if [ "$EXIT_CODE" -eq 0 ]; then
151+
if [[ "$EXIT_CODE" -eq 0 ]]; then
156152
echo "RELEASE MANAGER: This test seems to have passed."
157-
elif [ "$EXIT_CODE" -ge 30 ] && [ "$EXIT_CODE" -lt 40 ]; then
153+
elif [[ "$EXIT_CODE" -ge 30 && "$EXIT_CODE" -lt 40 ]]; then
158154
echo "RELEASE MANAGER: This is likely an infra error that can be solved by RESTARTING this test."
159155
else
160156
echo "RELEASE MANAGER: This could be an error in the test. Please REVIEW THE LOGS and ping the test owner."

0 commit comments

Comments
 (0)