Skip to content

Commit 91f0b91

Browse files
authored
Retry WolframScript activation (#677)
## Changes * Try WolframScript activation up to 3 times before failing. ## Comments * WolframScript activation [keeps failing](https://app.circleci.com/pipelines/github/maxitg/SetReplace/2125/workflows/a937820e-d49c-4bfe-b3fe-21fe60fb4aec/jobs/5523) intermittently because it "could not connect to https://www.wolframcloud.com/". We cannot avoid doing it, however, we can decrease the probability of failure by retrying a few times. ## Examples * Passing wrong `WOLFRAM_ID` and `WOLFRAM_PASSWORD`: ```console $ export WOLFRAM_ID="test@test.test" $ export WOLFRAM_PASSWORD="123" $ ./scripts/activateWolframScript.sh Attempt 1... Incorrect username or password Activation failed on attempt 1. Retrying... Attempt 2... Incorrect username or password Activation failed on attempt 2. Retrying... Attempt 3... Incorrect username or password Activation failed on attempt 3. Retrying... Activation failed after 3 attempts. $ echo $? 1 ``` * [CI job](https://app.circleci.com/pipelines/github/maxitg/SetReplace/2138/workflows/dd8dffc9-0bcd-4e77-bf8f-be73c98e6018/jobs/5588/parallel-runs/0/steps/0-103) for this PR: ```console $ #!/bin/bash -eo pipefail $ ./scripts/activateWolframScript.sh Attempt 1... Success. Saving connection data. Wolfram Engine activated. See https://www.wolfram.com/wolframscript/ for more information. Activation succeeded on attempt 1. ```
1 parent e4eabb5 commit 91f0b91

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ jobs:
2121
2222
- run:
2323
name: Activate Wolfram Engine
24-
command: |
25-
wolframscript -authenticate maxitg@icloud.com "${WOLFRAM_PASSWORD}"
26-
wolframscript -activate
24+
command: ./scripts/activateWolframScript.sh
2725

2826
- run:
2927
name: Build

scripts/activateWolframScript.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# Activation is flaky, try up to 3 times.
4+
n=0
5+
until [[ ${n} -ge 3 ]]; do
6+
((n++))
7+
echo "Attempt ${n}..."
8+
9+
# Run the activation
10+
if wolframscript -authenticate "${WOLFRAM_ID}" "${WOLFRAM_PASSWORD}" && wolframscript -activate; then
11+
echo "Activation succeeded on attempt ${n}."
12+
break
13+
fi
14+
15+
echo "Activation failed on attempt ${n}. Retrying..."
16+
sleep 5
17+
done
18+
19+
# If after the loop it's still not activated, fail the build
20+
if [[ ${n} -eq 3 ]]; then
21+
echo "Activation failed after 3 attempts."
22+
exit 1
23+
fi

0 commit comments

Comments
 (0)