Skip to content

Commit 0dbe1eb

Browse files
authored
fix: e2e_amplify_outputs_backwards_compatibility only runs once, and often fails on network connectivity issues (#3017)
The `health_checks` workflow fails on the `Setup baseline version` due to network connectivity issues: https://github.com/aws-amplify/amplify-backend/actions/runs/18266505828/job/52001722478#logs <!-- Thank you for your Pull Request! Please describe the problem this PR fixes and a summary of the changes made. Link to any relevant issues, code snippets, or other PRs. For trivial changes, this template can be ignored in favor of a short description of the changes. --> ## Problem <!-- Describe the issue this PR is solving --> There are no retries on this intermittently failing task. ## Changes <!-- Summarize the changes introduced in this PR. This is a good place to call out critical or potentially problematic parts of the change. --> Implemented retries for the task. ## Validation <!-- Describe how changes in this PR have been validated. This may include added or updated unit, integration and/or E2E tests, test workflow runs, or manual verification. If manual verification is the only way changes in this PR have been validated, you will need to write some automated tests before this PR is ready to merge. For changes to test infra, or non-functional changes, tests are not always required. Instead, you should call out _why_ you think tests are not required here. If changes affect a GitHub workflow that is not included in the PR checks, include a link to a passing test run of the modified workflow. ---> The workflow run on this PR will validate the change. `run-e2e` is applied. ## Checklist <!-- These items must be completed before a PR is ready to be merged. Feel free to publish a draft PR before these items are complete. --> - [X] If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change. - [X] If this PR requires a change to the [Project Architecture README](../PROJECT_ARCHITECTURE.md), I have included that update in this PR. - [X] If this PR requires a docs update, I have linked to that docs PR above. - [X] If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the `run-e2e` label set. _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license._
1 parent 6263ef9 commit 0dbe1eb

File tree

1 file changed

+71
-19
lines changed

1 file changed

+71
-19
lines changed

.github/actions/setup_baseline_version/action.yml

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,86 @@ inputs:
44
node_version:
55
description: node version used to configure environment with
66
required: true
7+
max_retry_attempts:
8+
description: maximum number of retry attempts for network operations
9+
required: false
10+
default: '5'
11+
initial_wait_time:
12+
description: initial wait time in seconds before first retry (increases by this amount each retry)
13+
required: false
14+
default: '30'
715
outputs:
816
baseline_dir:
917
description: 'Path where baseline project directory is setup'
1018
value: ${{ steps.move_baseline_version.outputs.baseline_dir }}
1119
runs:
1220
using: composite
1321
steps:
22+
- name: Setup retry function
23+
shell: bash
24+
run: |
25+
# Create a shared retry function that can be used in other steps
26+
cat > /tmp/retry_function.sh << 'EOF'
27+
retry_with_backoff() {
28+
local max_attempts=$1
29+
local initial_wait=$2
30+
shift 2
31+
local command="$@"
32+
33+
local attempt=1
34+
local wait_time=$initial_wait
35+
36+
while [ $attempt -le $max_attempts ]; do
37+
echo "Attempt $attempt of $max_attempts"
38+
39+
if eval "$command"; then
40+
echo "Command completed successfully"
41+
return 0
42+
fi
43+
44+
if [ $attempt -lt $max_attempts ]; then
45+
echo "Command failed. Waiting ${wait_time} seconds before retry..."
46+
sleep $wait_time
47+
wait_time=$((wait_time + initial_wait))
48+
fi
49+
50+
attempt=$((attempt + 1))
51+
done
52+
53+
echo "All retry attempts failed"
54+
return 1
55+
}
56+
EOF
1457
- name: Get baseline commit sha
1558
id: get_baseline_commit_sha
1659
shell: bash
1760
env:
1861
GH_TOKEN: ${{ github.token }}
1962
run: |
20-
if [[ ${{ github.event_name }} == 'push' ]]; then
21-
# The SHA of the most recent commit on ref before the push.
22-
baseline_commit_sha="${{ github.event.before }}"
23-
elif [[ ${{ github.event_name }} == 'pull_request' ]]; then
24-
# The SHA of the HEAD commit on base branch.
25-
baseline_commit_sha="${{ github.event.pull_request.base.sha }}"
26-
elif [[ ${{ github.event_name }} == 'schedule' ]] || [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
27-
# The SHA of the parent of HEAD commit on main branch.
28-
# This assumes linear history of main branch, i.e. one parent.
29-
# These events have only information about HEAD commit, hence the need for lookup.
30-
baseline_commit_sha=$(gh api /repos/${{ github.repository }}/commits/${{ github.sha }} | jq -r '.parents[0].sha')
31-
else
32-
echo Unable to determine baseline commit sha;
33-
exit 1;
34-
fi
35-
echo baseline commit sha is $baseline_commit_sha;
36-
echo "baseline_commit_sha=$baseline_commit_sha" >> "$GITHUB_OUTPUT";
63+
source /tmp/retry_function.sh
64+
65+
get_baseline_commit() {
66+
if [[ ${{ github.event_name }} == 'push' ]]; then
67+
# The SHA of the most recent commit on ref before the push.
68+
baseline_commit_sha="${{ github.event.before }}"
69+
elif [[ ${{ github.event_name }} == 'pull_request' ]]; then
70+
# The SHA of the HEAD commit on base branch.
71+
baseline_commit_sha="${{ github.event.pull_request.base.sha }}"
72+
elif [[ ${{ github.event_name }} == 'schedule' ]] || [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
73+
# The SHA of the parent of HEAD commit on main branch.
74+
# This assumes linear history of main branch, i.e. one parent.
75+
# These events have only information about HEAD commit, hence the need for lookup.
76+
baseline_commit_sha=$(gh api /repos/${{ github.repository }}/commits/${{ github.sha }} | jq -r '.parents[0].sha')
77+
else
78+
echo "Unable to determine baseline commit sha"
79+
return 1
80+
fi
81+
}
82+
83+
# Execute with retries
84+
retry_with_backoff ${{ inputs.max_retry_attempts }} ${{ inputs.initial_wait_time }} get_baseline_commit
85+
echo "baseline commit sha is $baseline_commit_sha"
86+
echo "baseline_commit_sha=$baseline_commit_sha" >> "$GITHUB_OUTPUT"
3787
- name: Checkout baseline version
3888
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4
3989
with:
@@ -44,8 +94,10 @@ runs:
4494
- name: Install and build baseline version
4595
shell: bash
4696
run: |
47-
npm ci
48-
npm run build
97+
source /tmp/retry_function.sh
98+
99+
# Execute npm ci and build with retries
100+
retry_with_backoff ${{ inputs.max_retry_attempts }} ${{ inputs.initial_wait_time }} "npm ci && npm run build"
49101
- name: Move baseline version
50102
id: move_baseline_version
51103
shell: bash

0 commit comments

Comments
 (0)