Skip to content

Commit

Permalink
Select random region in health check (#1911)
Browse files Browse the repository at this point in the history
* Select random region in e2e tests

* try this

* try this

* try this

* try this

* try this

* try this

* try this

* try this
  • Loading branch information
sobolk authored Aug 23, 2024
1 parent c8d1f10 commit 90eb24f
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 126 deletions.
75 changes: 75 additions & 0 deletions .github/actions/run_with_e2e_account/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: run_with_e2e_account
description: Runs commands with e2e test account
inputs:
run:
description: Script to run
required: true
shell:
description: Shell
required: false
node_version:
description: node version used to configure environment with
required: false
e2e_test_accounts:
description: Serialized JSON array of strings with account numbers
required: true
aws_region:
description: AWS region. If not provided random will be selected
required: false
link_cli:
description: Whether should link Gen2 CLI globally
default: false
fresh_build:
description: Whether should build from scratch
default: false
runs:
using: composite
steps:
- name: Setup Node.js
uses: ./.github/actions/setup_node
with:
node-version: ${{ inputs.node_version }}
- name: Restore Build Cache
if: inputs.fresh_build != 'true'
uses: ./.github/actions/restore_build_cache
- name: Build With Cache
if: inputs.fresh_build == 'true'
uses: ./.github/actions/build_with_cache
- name: Link CLI
if: inputs.link_cli == 'true'
shell: bash
run: cd packages/cli && npm link
- name: Select E2E test account
uses: ./.github/actions/select_e2e_account
id: selectE2EAccount
with:
e2e_test_accounts: ${{ inputs.e2e_test_accounts }}
- name: Select region
id: selectE2ERegion
shell: bash
run: |
if [ -z "${{ inputs.aws_region }}" ]; then
regions=("us-west-2" "us-east-1" "ca-central-1" "eu-central-1")
rand=$[$RANDOM % ${#regions[@]}]
selected_aws_region=${regions[$rand]}
else
selected_aws_region="${{ inputs.aws_region }}"
fi
echo "Selected AWS Region is $selected_aws_region"
echo "selected_aws_region=$selected_aws_region" >> "$GITHUB_OUTPUT"
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_test_tooling_role }}
aws-region: ${{ steps.selectE2ERegion.outputs.selected_aws_region }}
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_execution_role }}
aws-region: ${{ steps.selectE2ERegion.outputs.selected_aws_region }}
- name: Run script
shell: ${{ inputs.shell }}
run: ${{ inputs.run }}
env:
AWS_REGION: ${{ steps.selectE2ERegion.outputs.selected_aws_region }}
29 changes: 7 additions & 22 deletions .github/workflows/canary_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,18 @@ jobs:
matrix:
region: [us-west-2, us-east-1, ca-central-1, eu-central-1]
timeout-minutes: 20
env:
AWS_REGION: ${{ matrix.region }}
permissions:
# these permissions are required for the configure-aws-credentials action to get a JWT from GitHub
id-token: write
contents: read
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/build_with_cache
- name: Select E2E test account
uses: ./.github/actions/select_e2e_account
id: selectE2EAccount
- name: Run live dependency health checks
uses: ./.github/actions/run_with_e2e_account
with:
e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_test_tooling_role }}
aws-region: ${{ matrix.region }}
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_execution_role }}
aws-region: ${{ matrix.region }}
- name: Run live dependency health checks
shell: bash
run: |
./scripts/retry.js npm run live-dependency-health-checks
node_version: ${{ matrix.node-version }}
aws_region: ${{ matrix.region }}
fresh_build: true
shell: bash
run: ./scripts/retry.js npm run live-dependency-health-checks
131 changes: 27 additions & 104 deletions .github/workflows/health_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,12 @@ jobs:
echo "baseline_dir=$BASELINE_DIR" >> "$GITHUB_OUTPUT";
- name: Checkout current version
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/restore_build_cache
- name: Select E2E test account
uses: ./.github/actions/select_e2e_account
id: selectE2EAccount
- name: Run e2e iam access drift test
uses: ./.github/actions/run_with_e2e_account
with:
e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_test_tooling_role }}
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_execution_role }}
aws-region: us-west-2
- name: Run e2e iam access drift test
run: npm run test:dir packages/integration-tests/lib/test-e2e/iam_access_drift.test.js
node_version: ${{ matrix.node-version }}
run: npm run test:dir packages/integration-tests/lib/test-e2e/iam_access_drift.test.js
env:
BASELINE_DIR: ${{ steps.move_baseline_version.outputs.baseline_dir }}
e2e_deployment:
Expand Down Expand Up @@ -249,29 +235,14 @@ jobs:
contents: read
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4
- uses: ./.github/actions/setup_node
with:
node-version: ${{ matrix.node-version }}
- uses: ./.github/actions/restore_build_cache
- run: cd packages/cli && npm link
- name: Select E2E test account
uses: ./.github/actions/select_e2e_account
id: selectE2EAccount
- name: Run e2e deployment tests
uses: ./.github/actions/run_with_e2e_account
with:
e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_test_tooling_role }}
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_execution_role }}
aws-region: us-west-2
- name: Run e2e deployment tests
run: npm run test:dir packages/integration-tests/lib/test-e2e/deployment.test.js
node_version: ${{ matrix.node-version }}
link_cli: true
run: |
npm run test:dir packages/integration-tests/lib/test-e2e/deployment.test.js
e2e_sandbox:
if: needs.do_include_e2e.outputs.run_e2e == 'true'
strategy:
Expand All @@ -297,29 +268,13 @@ jobs:
contents: read
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4
- uses: ./.github/actions/setup_node
with:
node-version: ${{ matrix.node-version }}
- uses: ./.github/actions/restore_build_cache
- run: cd packages/cli && npm link
- name: Select E2E test account
uses: ./.github/actions/select_e2e_account
id: selectE2EAccount
- name: Run e2e sandbox tests
uses: ./.github/actions/run_with_e2e_account
with:
e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_test_tooling_role }}
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_execution_role }}
aws-region: us-west-2
- name: Run e2e sandbox tests
run: npm run test:dir packages/integration-tests/lib/test-e2e/sandbox.test.js
node_version: ${{ matrix.node-version }}
link_cli: true
run: npm run test:dir packages/integration-tests/lib/test-e2e/sandbox.test.js
e2e_backend_output:
if: needs.do_include_e2e.outputs.run_e2e == 'true'
runs-on: ubuntu-latest
Expand All @@ -333,27 +288,13 @@ jobs:
contents: read
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/restore_build_cache
- run: cd packages/cli && npm link
- name: Select E2E test account
uses: ./.github/actions/select_e2e_account
id: selectE2EAccount
- name: Run e2e backend output tests
uses: ./.github/actions/run_with_e2e_account
with:
e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_test_tooling_role }}
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_execution_role }}
aws-region: us-west-2
- name: Run e2e backend output tests
run: npm run test:dir packages/integration-tests/lib/test-e2e/backend_output.test.js
node_version: ${{ matrix.node-version }}
link_cli: true
run: npm run test:dir packages/integration-tests/lib/test-e2e/backend_output.test.js
e2e_create_amplify:
if: needs.do_include_e2e.outputs.run_e2e == 'true'
strategy:
Expand Down Expand Up @@ -403,34 +344,16 @@ jobs:
id-token: write
contents: read
steps:
- name: Checkout aws-amplify/amplify-cli repo
- name: Checkout aws-amplify/amplify-backend repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Node.js
uses: ./.github/actions/setup_node
with:
node-version: ${{ matrix.node-version }}
- name: Restore Build Cache
uses: ./.github/actions/restore_build_cache
- name: Select E2E test account
uses: ./.github/actions/select_e2e_account
id: selectE2EAccount
- name: Run E2E flow tests with ${{ matrix.pkg-manager }}
uses: ./.github/actions/run_with_e2e_account
with:
e2e_test_accounts: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_test_tooling_role }}
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ steps.selectE2EAccount.outputs.e2e_execution_role }}
aws-region: us-west-2
- name: Run E2E flow tests with ${{ matrix.pkg-manager }}
shell: bash
run: |
PACKAGE_MANAGER=${{matrix.pkg-manager}} npm run test:dir packages/integration-tests/src/package_manager_sanity_checks.test.ts
node_version: ${{ matrix.node-version }}
shell: bash
run: |
PACKAGE_MANAGER=${{matrix.pkg-manager}} npm run test:dir packages/integration-tests/src/package_manager_sanity_checks.test.ts
lint:
runs-on: ubuntu-latest
needs:
Expand Down

0 comments on commit 90eb24f

Please sign in to comment.