Skip to content

Commit d33fefe

Browse files
chore(ci): add retry delays to build tests & upgrade actions/cache (#6291)
* chore: add delay between install retries, swap RN to use install script * chore: upgrade actions/cache to v4.2.0
1 parent 3b2f3b5 commit d33fefe

File tree

8 files changed

+37
-30
lines changed

8 files changed

+37
-30
lines changed

.github/actions/install-with-retries/install-with-retries.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ if [ "$SKIP_CYPRESS_BINARY" = "true" ]; then
1717
export CYPRESS_INSTALL_BINARY=0
1818
fi
1919

20-
for i in {1..3}; do
20+
for i in {1..4}; do
2121
echo "===================="
22-
echo "Attempt $i out of 3:"
22+
echo "Attempt $i out of 4:"
2323
echo "===================="
2424

2525
if [ "$NO_LOCKFILE" = "true" ]; then
@@ -32,10 +32,14 @@ for i in {1..3}; do
3232
# Check return value and exit early if successful
3333
return_value=$?
3434
[ $return_value -eq 0 ] && break
35-
echo "[ERROR]: yarn install failed with exit code $return_value, waiting to retry..."
3635

37-
# Sleep 5 seconds before retrying
38-
sleep 5
36+
# Don't add delay at end of last attempt if last attempt fails
37+
if [ "$i" -le 3 ]; then
38+
# NPM publish can be flaky causing failed installs
39+
# Add exponential backoff between retries: [4/16/64]s ~= [5/15/60]s
40+
echo "[ERROR]: yarn install failed with exit code $return_value, waiting to retry in $((4 * i)) seconds..."
41+
sleep $((4 ** i))
42+
fi
3943
done
4044

4145
# exit 0 if last `yarn install` was successful, non-zero otherwise

.github/workflows/reusable-build-system-test-react-native.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ jobs:
134134
- name: Restore CocoaPods cache
135135
if: ${{ matrix.platform == 'ios' }}
136136
id: restore-cocoapods-cache
137-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
137+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
138138
with:
139139
path: ./examples/react-native/ios/Pods
140140
key: ${{ runner.os }}-cocoapods
@@ -143,7 +143,7 @@ jobs:
143143
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
144144
- name: Restore node_modules cache
145145
if: ${{ matrix.platform == 'ios' }}
146-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
146+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
147147
id: restore-cache
148148
with:
149149
path: |

.github/workflows/reusable-build-system-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
- name: Delete AWS Profile
126126
run: rm -rf ~/.aws
127127
- name: Restore cypress runner from Cache
128-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
128+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
129129
id: restore-cypress-cache
130130
with:
131131
path: ~/.cache/Cypress
@@ -148,7 +148,7 @@ jobs:
148148
# step, so we go ahead and update the cache entry.
149149
- name: Cache cypress runner
150150
if: steps.restore-cypress-cache.outputs.cache-hit != 'true'
151-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
151+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
152152
with:
153153
path: ~/.cache/Cypress
154154
key: ${{ runner.os }}-canary-cypress-${{ hashFiles('build-system-tests/e2e/yarn.lock') }}

.github/workflows/reusable-e2e.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
persist-credentials: false
9292

9393
- name: Next.js Cache
94-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
94+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
9595
with:
9696
path: ${{ github.workspace }}/.next/cache
9797
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}
@@ -107,7 +107,7 @@ jobs:
107107
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
108108

109109
- name: Restore cypress runner Cache
110-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
110+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
111111
id: restore-cypress-cache
112112
with:
113113
path: ~/.cache/Cypress
@@ -116,7 +116,7 @@ jobs:
116116
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
117117

118118
- name: Restore node_modules cache
119-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
119+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
120120
id: restore-cache
121121
with:
122122
path: |
@@ -127,15 +127,15 @@ jobs:
127127
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
128128

129129
- name: Restore ui/dist cache
130-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
130+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
131131
id: restore-ui-cache
132132
with:
133133
path: ./packages/ui/dist
134134
key: ${{ runner.os }}-ui-${{ inputs.commit }}
135135

136136
- name: Restore ${{ matrix.package }}/dist cache
137137
id: restore-package-cache
138-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
138+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
139139
with:
140140
path: ./packages/${{ matrix.package }}/dist
141141
key: ${{ runner.os }}-${{ matrix.package }}-${{ inputs.commit }}
@@ -394,7 +394,7 @@ jobs:
394394

395395
- name: Restore CocoaPods cache
396396
id: restore-cocoapods-cache
397-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
397+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
398398
with:
399399
path: ./examples/react-native/ios/Pods
400400
key: ${{ runner.os }}-cocoapods-${{ inputs.commit }}
@@ -652,7 +652,7 @@ jobs:
652652
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
653653

654654
- name: Restore cypress runner Cache
655-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
655+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
656656
id: restore-cypress-cache
657657
with:
658658
path: ~/.cache/Cypress
@@ -661,7 +661,7 @@ jobs:
661661
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
662662

663663
- name: Restore Puppeteer runner cache
664-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
664+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
665665
id: restore-puppeteer-cache
666666
with:
667667
path: ~/.cache/puppeteer
@@ -670,7 +670,7 @@ jobs:
670670
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
671671

672672
- name: Restore node_modules cache
673-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
673+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
674674
id: restore-cache
675675
with:
676676
path: |

.github/workflows/reusable-setup-cache.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ jobs:
3030
env:
3131
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
3232
- name: Restore cypress runner from Cache
33-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
33+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
3434
id: restore-cypress-cache
3535
with:
3636
path: ~/.cache/Cypress
3737
key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }}
3838
env:
3939
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1
4040
- name: Restore Puppeteer runner from Cache
41-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
41+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
4242
id: restore-puppeteer-cache
4343
with:
4444
path: ~/.cache/puppeteer
@@ -55,17 +55,17 @@ jobs:
5555
- name: Cache cypress runner
5656
# create new cypress cache entry only if cypress cache missed and we installed a new one.
5757
if: steps.restore-cypress-cache.outputs.cache-hit != 'true'
58-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
58+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
5959
with:
6060
path: ~/.cache/Cypress
6161
key: ${{ runner.os }}-cypress-${{ hashFiles('yarn.lock') }}
6262
- name: Cache packages/ui/dist
63-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
63+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
6464
with:
6565
path: ./packages/ui/dist
6666
key: ${{ runner.os }}-ui-${{ inputs.commit }}
6767
- name: Cache node_modules
68-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
68+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
6969
with:
7070
path: |
7171
./node_modules

.github/workflows/reusable-unit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
5555

5656
- name: Restore node_modules cache
57-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
57+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
5858
id: restore-cache
5959
with:
6060
path: |
@@ -65,7 +65,7 @@ jobs:
6565
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
6666

6767
- name: Restore ui/dist cache
68-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
68+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
6969
id: restore-ui-cache
7070
with:
7171
path: ./packages/ui/dist
@@ -154,7 +154,7 @@ jobs:
154154
run: yarn ${{ matrix.package }} size
155155

156156
- name: Cache ${{ matrix.package }}/dist
157-
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 https://github.com/actions/cache/commit/0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
157+
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 https://github.com/actions/cache/commit/1bd1e32a3bdc45362d1e726936510720a7c30a57
158158
with:
159159
path: ./packages/${{ matrix.package }}/dist
160160
key: ${{ runner.os }}-${{ matrix.package }}-${{ inputs.commit }}

build-system-tests/scripts/install-dependencies-with-retries.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Takes 2 parameters: the package manager and the dependencies to be installed
55
# Usage: install_with_retries npm "$DEPENDENCIES" or install_with_retries yarn "$DEPENDENCIES"
66
install_dependencies_with_retries() {
7-
local retries=3
7+
local retries=4
88
local attempt=1
99
echo "Disable exit-on-error temporarily"
1010
echo "set +e"
@@ -20,10 +20,13 @@ install_dependencies_with_retries() {
2020
set -e
2121
break
2222
fi
23+
# Add exponential backoff delay between failed attempts
24+
# [4/16/64]s ~= [5/15/60]s
25+
local wait=$((4 ** attempt))
2326
attempt=$((attempt + 1))
2427
if [ $attempt -le $retries ]; then
25-
echo "$1 install failed. Retrying in 5 seconds..."
26-
sleep 5
28+
echo "$1 install failed. Retrying in $wait seconds..."
29+
sleep $wait
2730
else
2831
echo "$1 install failed after $retries attempts."
2932
echo "Re-enable exit-on-error"

build-system-tests/scripts/mega-app-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ else
108108
# react-native-safe-area-context v5.0.0+ does not support RN 0.74 and lower
109109
DEPENDENCIES="$TAGGED_UI_FRAMEWORK @aws-amplify/react-native aws-amplify react-native-safe-area-context@^4.2.5 @react-native-community/netinfo @react-native-async-storage/async-storage react-native-get-random-values react-native-url-polyfill"
110110
echo "npm install $DEPENDENCIES"
111-
npm install $DEPENDENCIES
111+
install_dependencies_with_retries npm "$DEPENDENCIES"
112112
if [[ "$BUILD_TOOL" == "expo" ]]; then
113113
if [[ "$FRAMEWORK_VERSION" == "0.75" ]]; then
114114
# Expo SDK version 51.0.0 supports RN 0.74 and 0.75 but installs 0.74 by default https://expo.dev/changelog/2024/08-14-react-native-0.75#2-install-updated-packages

0 commit comments

Comments
 (0)