Skip to content

Commit 7ac230e

Browse files
glasntiennae
andauthored
fix: ensure all retry.sh failures fail exit 1 (#4037)
* fix: ensure all retry.sh failures fail exit 1 * auto format * Format Document * revert Format Document (does not match gts) * manual gts lint --------- Co-authored-by: Jennifer Davis <[email protected]>
1 parent 3423636 commit 7ac230e

File tree

4 files changed

+30
-35
lines changed

4 files changed

+30
-35
lines changed

run/markdown-preview/editor/test/retry.sh

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,32 @@
3333
# If first cmd executes successfully then execute second cmd
3434
runIfSuccessful() {
3535
echo "running: $1"
36-
$($1 > /dev/null)
36+
$($1 >/dev/null)
3737
if [ $? -eq 0 ]; then
3838
echo "running: $2"
39-
$($2 > /dev/null)
39+
$($2 >/dev/null)
4040
fi
4141
}
4242

4343
# Define max retries
44-
max_attempts=3;
45-
attempt_num=1;
44+
max_attempts=3
45+
attempt_num=1
4646

4747
arg1="$1"
4848
arg2="$2"
4949

50-
if [ $# -eq 1 ]
51-
then
50+
if [ $# -eq 1 ]; then
5251
cmd="$arg1"
5352
else
5453
cmd="runIfSuccessful \"$arg1\" \"$arg2\""
5554
fi
5655

57-
until eval $cmd
58-
do
59-
if ((attempt_num==max_attempts))
60-
then
61-
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
62-
exit
63-
else
64-
echo "Attempt $attempt_num / $max_attempts failed!"
65-
sleep $((attempt_num++))
66-
fi
56+
until eval $cmd; do
57+
if ((attempt_num == max_attempts)); then
58+
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
59+
exit 1
60+
else
61+
echo "Attempt $attempt_num / $max_attempts failed!"
62+
sleep $((attempt_num++))
63+
fi
6764
done

run/markdown-preview/editor/test/system.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ describe('End-to-End Tests', () => {
4040
`gcloud builds submit --project ${GOOGLE_CLOUD_PROJECT} ` +
4141
'--config ../renderer/test/e2e_test_setup.yaml ' +
4242
`--substitutions _SERVICE=renderer-${SERVICE_NAME},_REGION=${REGION}`;
43+
4344
if (SAMPLE_VERSION) buildRendererCmd += `,_VERSION=${SAMPLE_VERSION}`;
44-
if (SERVICE_ACCOUNT) buildRendererCmd += `,_SERVICE_ACCOUNT=${SERVICE_ACCOUNT}`;
45+
if (SERVICE_ACCOUNT) {
46+
buildRendererCmd += `,_SERVICE_ACCOUNT=${SERVICE_ACCOUNT}`;
47+
}
4548

4649
console.log('Starting Cloud Build for Renderer service...');
4750
execSync(buildRendererCmd, {cwd: '../renderer'});

run/markdown-preview/renderer/test/retry.sh

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,32 @@
3333
# If first cmd executes successfully then execute second cmd
3434
runIfSuccessful() {
3535
echo "running: $1"
36-
$($1 > /dev/null)
36+
$($1 >/dev/null)
3737
if [ $? -eq 0 ]; then
3838
echo "running: $2"
39-
$($2 > /dev/null)
39+
$($2 >/dev/null)
4040
fi
4141
}
4242

4343
# Define max retries
44-
max_attempts=3;
45-
attempt_num=1;
44+
max_attempts=3
45+
attempt_num=1
4646

4747
arg1="$1"
4848
arg2="$2"
4949

50-
if [ $# -eq 1 ]
51-
then
50+
if [ $# -eq 1 ]; then
5251
cmd="$arg1"
5352
else
5453
cmd="runIfSuccessful \"$arg1\" \"$arg2\""
5554
fi
5655

57-
until eval $cmd
58-
do
59-
if ((attempt_num==max_attempts))
60-
then
61-
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
62-
exit
63-
else
64-
echo "Attempt $attempt_num / $max_attempts failed!"
65-
sleep $((attempt_num++))
66-
fi
56+
until eval $cmd; do
57+
if ((attempt_num == max_attempts)); then
58+
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
59+
exit 1
60+
else
61+
echo "Attempt $attempt_num / $max_attempts failed!"
62+
sleep $((attempt_num++))
63+
fi
6764
done

run/markdown-preview/renderer/test/system.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ describe('End-to-End Tests', () => {
3333
const {SERVICE_ACCOUNT} = process.env;
3434
const REGION = 'us-central1';
3535

36-
3736
let BASE_URL;
3837
before(async () => {
3938
// Deploy service using Cloud Build
@@ -55,7 +54,6 @@ describe('End-to-End Tests', () => {
5554
);
5655
BASE_URL = url.toString('utf-8').trim();
5756
if (!BASE_URL) throw Error('Cloud Run service URL not found');
58-
5957
});
6058

6159
after(() => {

0 commit comments

Comments
 (0)