Skip to content

Commit b3e48cf

Browse files
committed
feat(INFRA-2932): add retry to yarn commands
1 parent 6090afa commit b3e48cf

5 files changed

Lines changed: 101 additions & 67 deletions

File tree

.github/actions/checkout-and-setup/action.yml

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -26,63 +26,69 @@ outputs:
2626
runs:
2727
using: composite
2828
steps:
29-
# The "required: true" field is not enforced by GitHub, so we need to check it manually
30-
- name: Enforce required input is either "true" or "false"
31-
run: |
32-
if [[ "${{ inputs.is-high-risk-environment }}" == "true" ]]; then
33-
echo 'High-risk environment detected. Disabling cache for security.'
34-
elif [[ "${{ inputs.is-high-risk-environment }}" == "false" ]]; then
35-
echo 'Low-risk environment detected. Enabling cache for optimized performance.'
36-
else
37-
echo "::error::Invalid value for 'is-high-risk-environment'. Must be 'true' (secure, no cache) or 'false' (faster, cache enabled)."
38-
exit 1
39-
fi
40-
shell: bash
29+
# The "required: true" field is not enforced by GitHub, so we need to check it manually
30+
- name: Enforce required input is either "true" or "false"
31+
run: |
32+
if [[ "${{ inputs.is-high-risk-environment }}" == "true" ]]; then
33+
echo 'High-risk environment detected. Disabling cache for security.'
34+
elif [[ "${{ inputs.is-high-risk-environment }}" == "false" ]]; then
35+
echo 'Low-risk environment detected. Enabling cache for optimized performance.'
36+
else
37+
echo "::error::Invalid value for 'is-high-risk-environment'. Must be 'true' (secure, no cache) or 'false' (faster, cache enabled)."
38+
exit 1
39+
fi
40+
shell: bash
4141

42-
# Checkout repository only if not already checked out
43-
- name: Checkout repository
44-
uses: actions/checkout@v4
45-
if: ${{ hashFiles('.git') == '' }}
46-
with:
47-
fetch-depth: ${{ inputs.fetch-depth }}
48-
ref: ${{ inputs.ref }}
42+
# Checkout repository only if not already checked out
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
if: ${{ hashFiles('.git') == '' }}
46+
with:
47+
fetch-depth: ${{ inputs.fetch-depth }}
48+
ref: ${{ inputs.ref }}
4949

50-
- run: corepack enable
51-
shell: bash
50+
- run: corepack enable
51+
shell: bash
5252

53-
# In a low-risk environment, try to download cache of node_modules, if it exists
54-
# On failure, will run the yarn install instead
55-
- name: Download node_modules cache
56-
if: ${{ inputs.is-high-risk-environment == 'false' }}
57-
id: download-node-modules
58-
uses: actions/cache/restore@v4
59-
with:
60-
path: ./node_modules
61-
key: node-modules-${{ github.sha }}
53+
# In a low-risk environment, try to download cache of node_modules, if it exists
54+
# On failure, will run the yarn install instead
55+
- name: Download node_modules cache
56+
if: ${{ inputs.is-high-risk-environment == 'false' }}
57+
id: download-node-modules
58+
uses: actions/cache/restore@v4
59+
with:
60+
path: ./node_modules
61+
key: node-modules-${{ github.sha }}
6262

63-
- name: Set up Node.js
64-
uses: actions/setup-node@v4
65-
id: setup-node
66-
with:
67-
node-version-file: .nvmrc
68-
# If the node_modules cache was not found, use setup-node cache to restore the '.yarn' folder
69-
# Notes: if this is always set to 'yarn':
70-
# 1) Will not be secure for high-risk environment
71-
# 2) Self-hosted runners will fail to find this cache, and then fail on the 'Post Setup environment' step
72-
# 3) This action will run a few seconds slower, because when we restore the 'node_modules' folder from cache, there's no need to download the '.yarn' folder too
73-
# (GHA does not allow the : ? ternary operator, you must write && ||)
74-
cache: ${{ ( inputs.is-high-risk-environment != 'true' && steps.download-node-modules.outputs.cache-hit != 'true' ) && 'yarn' || '' }}
63+
- name: Set up Node.js
64+
uses: actions/setup-node@v4
65+
id: setup-node
66+
with:
67+
node-version-file: .nvmrc
68+
# If the node_modules cache was not found, use setup-node cache to restore the '.yarn' folder
69+
# Notes: if this is always set to 'yarn':
70+
# 1) Will not be secure for high-risk environment
71+
# 2) Self-hosted runners will fail to find this cache, and then fail on the 'Post Setup environment' step
72+
# 3) This action will run a few seconds slower, because when we restore the 'node_modules' folder from cache, there's no need to download the '.yarn' folder too
73+
# (GHA does not allow the : ? ternary operator, you must write && ||)
74+
cache: ${{ ( inputs.is-high-risk-environment != 'true' && steps.download-node-modules.outputs.cache-hit != 'true' ) && 'yarn' || '' }}
7575

76-
# If the node_modules cache was not found (or it's a high-risk environment), run the yarn install
77-
- name: Install dependencies
78-
if: ${{ steps.download-node-modules.outputs.cache-hit != 'true'}}
79-
run: yarn --immutable
76+
# If the node_modules cache was not found (or it's a high-risk environment), run the yarn install
77+
- name: Install dependencies with retry
78+
if: ${{ steps.download-node-modules.outputs.cache-hit != 'true'}}
79+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
80+
with:
81+
max_attempts: 2
82+
timeout_minutes: 15
83+
retry_wait_seconds: 30
84+
retry_on: error
85+
command: yarn --immutable
8086
shell: bash
8187

82-
# For the 'prep-deps' job, save the node_modules cache
83-
- name: Cache workspace
84-
if: ${{ inputs.is-high-risk-environment == 'false' && inputs.cache-node-modules == 'true' }}
85-
uses: actions/cache/save@v4
86-
with:
87-
path: ./node_modules
88-
key: node-modules-${{ github.sha }}
88+
# For the 'prep-deps' job, save the node_modules cache
89+
- name: Cache workspace
90+
if: ${{ inputs.is-high-risk-environment == 'false' && inputs.cache-node-modules == 'true' }}
91+
uses: actions/cache/save@v4
92+
with:
93+
path: ./node_modules
94+
key: node-modules-${{ github.sha }}

.github/workflows/changelog-check.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,18 @@ jobs:
7777
cache-dependency-path: ./github-tools/yarn.lock
7878
cache: yarn
7979

80-
- name: Install dependencies
80+
- name: Install dependencies with retry
8181
if: ${{ steps.label-check.outputs.skip_check != 'true' }}
82-
run: yarn --immutable
83-
shell: bash
84-
working-directory: ./github-tools
82+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
83+
with:
84+
max_attempts: 2
85+
timeout_minutes: 15
86+
retry_wait_seconds: 30
87+
retry_on: error
88+
shell: bash
89+
command: |
90+
cd ./github-tools
91+
yarn --immutable
8592
8693
- name: Check Changelog
8794
if: ${{ steps.label-check.outputs.skip_check != 'true' }}

.github/workflows/flaky-test-report.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ jobs:
4040
run: corepack enable
4141
working-directory: ./github-tools
4242

43-
- name: Install dependencies
44-
working-directory: ./github-tools
45-
run: yarn --immutable
43+
- name: Install dependencies with retry
44+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
45+
with:
46+
max_attempts: 2
47+
timeout_minutes: 15
48+
retry_wait_seconds: 30
49+
retry_on: error
50+
command: |
51+
cd ./github-tools
52+
yarn --immutable
4653
4754
- name: Run flaky test report script
4855
env:

.github/workflows/post-merge-validation.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ jobs:
5050
run: corepack enable
5151
working-directory: ./github-tools
5252

53-
- name: Install dependencies
54-
working-directory: ./github-tools
55-
run: yarn --immutable
53+
- name: Install dependencies with retry
54+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
55+
with:
56+
max_attempts: 2
57+
timeout_minutes: 15
58+
retry_wait_seconds: 30
59+
retry_on: error
60+
command: |
61+
cd ./github-tools
62+
yarn --immutable
5663
5764
- name: Run post-merge-validation script
5865
working-directory: ./github-tools

.github/workflows/publish-slack-release-testing-status.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,17 @@ jobs:
4949
shell: bash
5050
working-directory: ./github-tools
5151

52-
- name: Install dependencies
53-
run: yarn --immutable
54-
shell: bash
55-
working-directory: ./github-tools
52+
- name: Install dependencies with retry
53+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 #v3.0.2
54+
with:
55+
max_attempts: 2
56+
timeout_minutes: 15
57+
retry_wait_seconds: 30
58+
retry_on: error
59+
shell: bash
60+
command: |
61+
cd ./github-tools
62+
yarn --immutable
5663
5764
# Step 4: Run Script
5865
- name: Publish Slack Release Testing Status

0 commit comments

Comments
 (0)