File tree 4 files changed +103
-4
lines changed
.github/actions/retry-command
4 files changed +103
-4
lines changed 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
16
16
./admin-utilities.rst
17
17
./test-utilities.rst
18
18
./other-utilities.rst
19
- ./reusable-workflows .rst
19
+ ./reusable-github-utils .rst
20
20
21
21
Other useful resources:
22
22
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
+ ----------------
3
61
4
62
Replicate Commits to Version Branch
5
- -----------------------------------
63
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6
64
7
65
This re-usable workflow replicates commits from the ``master `` branch to a
8
66
version 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):
88
88
options .binary_location = CHROME_BIN
89
89
options .add_argument ('--window-size=1366,768' )
90
90
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' )
91
95
# When running Selenium tests with the "--parallel" flag,
92
96
# each TestCase class requires its own browser instance.
93
97
# If the same "remote-debugging-port" is used for all
You can’t perform that action at this time.
0 commit comments