Skip to content

Commit 7978dfc

Browse files
author
Hanzhang Zeng (Roger)
committed
Add retry pattern in Unittest and E2E pipelines
1 parent f4156b1 commit 7978dfc

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

.github/workflows/ci_e2e_workflow.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,31 @@ jobs:
3636
dotnet-version: '3.1.405'
3737
- name: Install dependencies and the worker
3838
run: |
39+
retry() {
40+
local -r -i max_attempts="$1"; shift
41+
local -r cmd="$@"
42+
local -i attempt_num=1
43+
until $cmd
44+
do
45+
if (( attempt_num == max_attempts ))
46+
then
47+
echo "Attempt $attempt_num failed and there are no more attempts left!"
48+
return 1
49+
else
50+
echo "Attempt $attempt_num failed! Trying again in $attempt_num seconds..."
51+
sleep 1
52+
fi
53+
done
54+
}
55+
3956
python -m pip install --upgrade pip
4057
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U -e .[dev]
4158
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U azure-functions --pre
42-
python setup.py build
43-
python setup.py webhost
44-
python setup.py extension
59+
60+
# Retry a couple times to avoid certificate issue
61+
retry 5 python setup.py build
62+
retry 5 python setup.py webhost
63+
retry 5 python setup.py extension
4564
- name: Running 3.6 Tests
4665
if: matrix.python-version == 3.6
4766
env:

.github/workflows/ut_ci_workflow.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,31 @@ jobs:
3333
dotnet-version: '3.1.405'
3434
- name: Install dependencies and the worker
3535
run: |
36+
retry() {
37+
local -r -i max_attempts="$1"; shift
38+
local -r cmd="$@"
39+
local -i attempt_num=1
40+
until $cmd
41+
do
42+
if (( attempt_num == max_attempts ))
43+
then
44+
echo "Attempt $attempt_num failed and there are no more attempts left!"
45+
return 1
46+
else
47+
echo "Attempt $attempt_num failed! Trying again in $attempt_num seconds..."
48+
sleep 1
49+
fi
50+
done
51+
}
52+
3653
python -m pip install --upgrade pip
3754
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U -e .[dev]
3855
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple -U azure-functions --pre
39-
python setup.py build
40-
python setup.py webhost
41-
python setup.py extension
56+
57+
# Retry a couple times to avoid certificate issue
58+
retry 5 python setup.py build
59+
retry 5 python setup.py webhost
60+
retry 5 python setup.py extension
4261
- name: Test with pytest
4362
run: |
4463
pytest --instafail --cov=./azure_functions_worker --cov-report xml --cov-branch tests/unittests

0 commit comments

Comments
 (0)