File tree Expand file tree Collapse file tree
.github/actions/retry-command Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : " Retry Command"
2+
3+ description : " Retries a shell command if it fails"
4+
5+ inputs :
6+ command :
7+ description : " The shell command to run"
8+ required : true
9+ max_attempts :
10+ description : " Number of retry attempts"
11+ required : false
12+ default : " 3"
13+ delay_seconds :
14+ description : " Delay between retries in seconds"
15+ required : false
16+ default : " 5"
17+
18+ runs :
19+ using : " composite"
20+ steps :
21+ - name : Retry Command
22+ shell : bash
23+ run : |
24+ attempts=0
25+ until [ $attempts -ge ${{ inputs.max_attempts }} ]
26+ do
27+ echo "Attempt $((attempts+1)) of ${{ inputs.max_attempts }}..."
28+ eval "${{ inputs.command }}" && break
29+ attempts=$((attempts+1))
30+ if [ $attempts -lt ${{ inputs.max_attempts }} ]; then
31+ echo "Command failed. Waiting ${{ inputs.delay_seconds }}s before retry..."
32+ sleep ${{ inputs.delay_seconds }}
33+ else
34+ echo "Command failed after $attempts attempts."
35+ exit 1
36+ fi
37+ done
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ Developer Docs
1616 ./admin-utilities.rst
1717 ./test-utilities.rst
1818 ./other-utilities.rst
19- ./reusable-workflows .rst
19+ ./reusable-github-utils .rst
2020
2121Other useful resources:
2222
Original file line number Diff line number Diff line change 1- Re-usable GitHub Workflows
2- ==========================
1+ Re-usable GitHub Actions and Workflows
2+ ======================================
3+
4+ GitHub Actions
5+ --------------
6+
7+ Retry Command
8+ ~~~~~~~~~~~~~
9+
10+ This GitHub Action retries a shell command if it fails. It is useful for
11+ handling flaky tests in CI/CD pipelines.
12+
13+ **Inputs **
14+
15+ - ``command `` (required): The shell command to run.
16+ - ``max_attempts `` (optional): The number of retry attempts. Defaults to
17+ ``3 ``.
18+ - ``delay_seconds `` (optional): The delay between retries in seconds.
19+ Defaults to ``5 ``.
20+
21+ **Usage Example **
22+
23+ You can use this action in your workflow as follows:
24+
25+ .. code-block :: yaml
26+
27+ name : Retry Example
28+
29+ on :
30+ push :
31+ branches :
32+ - main
33+
34+ jobs :
35+ retry-command-example :
36+ runs-on : ubuntu-latest
37+ steps :
38+ - name : Checkout code
39+ uses : actions/checkout@v3
40+
41+ - name : Test
42+ uses : openwisp/openwisp-utils/.github/actions/retry-command@master
43+ with :
44+ delay_seconds : 30
45+ max_attempts : 5
46+ command : ./runtests.py --parallel
47+ env :
48+ SELENIUM_HEADLESS : 1
49+
50+ This example retries the ``./runtests.py --parallel `` command up to 5
51+ times with a 30 second delay between attempts.
52+
53+ .. note ::
54+
55+ If the command continues to fail after the specified number of
56+ attempts, the action will exit with a non-zero status, causing the
57+ workflow to fail.
58+
59+ GitHub Workflows
60+ ----------------
361
462Replicate Commits to Version Branch
5- -----------------------------------
63+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
664
765This re-usable workflow replicates commits from the ``master `` branch to a
866version branch. The version branch name is derived from the version of the
Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ def get_chrome_webdriver(cls):
8888 options .binary_location = CHROME_BIN
8989 options .add_argument ('--window-size=1366,768' )
9090 options .add_argument ('--ignore-certificate-errors' )
91+ options .add_argument ('--no-sandbox' )
92+ options .add_argument ('--disable-gpu' )
93+ options .add_argument ('--disable-dev-shm-usage' )
94+ options .add_argument ('--disable-features=VizDisplayCompositor' )
9195 # When running Selenium tests with the "--parallel" flag,
9296 # each TestCase class requires its own browser instance.
9397 # If the same "remote-debugging-port" is used for all
Original file line number Diff line number Diff line change 3737 'black~=23.12.1' ,
3838 'flake8~=7.1.0' ,
3939 'isort~=5.13.2' ,
40- 'coverage~ =7.6.1' ,
40+ 'coverage> =7.6.1,<7.9.0 ' ,
4141 'tblib~=3.0.0' ,
4242 'docstrfmt~=1.8.0' ,
4343 ],
4646 'django-filter~=23.2' , # django-filter uses CalVer
4747 'drf-yasg~=1.21.7' ,
4848 ],
49+ 'channels' : [
50+ 'channels[daphne]~=4.2.0' ,
51+ 'channels_redis~=4.2.1' ,
52+ ],
53+ 'channels-test' : [
54+ 'pytest-asyncio~=0.24.0' ,
55+ 'pytest-django~=4.10.0' ,
56+ ],
4957 'celery' : ['celery~=5.4.0' ],
5058 'selenium' : ['selenium>=4.10,<4.30' ],
5159 },
You can’t perform that action at this time.
0 commit comments