Skip to content

Commit

Permalink
chore: dx improvement for codebuild (#1752)
Browse files Browse the repository at this point in the history
* fix: artifact uploaded for both runs

* fix script

* change path

* debug e2e

* remove duplicate case

* debug nexpect

* fix: view artifact script to view tests with retries

* fix cancel push in codebuild

* debug

* debug

* fix push

* fix cleanup

* upload artifact for clean job

* fix spec and e2e

* use build id for artifact view

* change project name

* remove post build

* fix lint
  • Loading branch information
AaronZyLee committed Aug 4, 2023
1 parent db6c645 commit 07ac802
Show file tree
Hide file tree
Showing 26 changed files with 223 additions and 134 deletions.
4 changes: 4 additions & 0 deletions codebuild_specs/cleanup_e2e_resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ phases:
build:
commands:
- source ./shared-scripts.sh && _cleanupE2EResources
artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-e2e-tests/amplify-e2e-reports
4 changes: 4 additions & 0 deletions codebuild_specs/cleanup_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ phases:
commands:
- yarn production-build
- cd packages/amplify-e2e-tests && yarn clean-e2e-resources
artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-e2e-tests/amplify-e2e-reports
99 changes: 58 additions & 41 deletions codebuild_specs/e2e_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,54 +115,44 @@ batch:
depend-on:
- publish_to_local_registry
- identifier: >-
api_4_custom_policies_container_schema_iterative_rollback_1_schema_iterative_update_2
api_4_custom_policies_container_schema_iterative_update_2_api_connection_migration2
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
TEST_SUITE: >-
src/__tests__/api_4.test.ts|src/__tests__/custom_policies_container.test.ts|src/__tests__/schema-iterative-rollback-1.test.ts|src/__tests__/schema-iterative-update-2.test.ts
src/__tests__/api_4.test.ts|src/__tests__/custom_policies_container.test.ts|src/__tests__/schema-iterative-update-2.test.ts|src/__tests__/migration/api.connection.migration2.test.ts
CLI_REGION: us-east-1
depend-on:
- publish_to_local_registry
- identifier: >-
api_connection_migration2_schema_iterative_rollback_2_api_5_containers_api_secrets
- identifier: api_5_containers_api_secrets_schema_function_1_api_3
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
TEST_SUITE: >-
src/__tests__/migration/api.connection.migration2.test.ts|src/__tests__/schema-iterative-rollback-2.test.ts|src/__tests__/api_5.test.ts|src/__tests__/containers-api-secrets.test.ts
src/__tests__/api_5.test.ts|src/__tests__/containers-api-secrets.test.ts|src/__tests__/schema-function-1.test.ts|src/__tests__/api_3.test.ts
CLI_REGION: us-east-1
depend-on:
- publish_to_local_registry
- identifier: schema_function_1_api_3_base_cdk_api_1
- identifier: base_cdk_api_1_resolvers_sync_query_datastore
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
TEST_SUITE: >-
src/__tests__/schema-function-1.test.ts|src/__tests__/api_3.test.ts|src/__tests__/cdk/base-cdk.test.ts|src/__tests__/api_1.test.ts
CLI_REGION: ap-southeast-1
src/__tests__/cdk/base-cdk.test.ts|src/__tests__/api_1.test.ts|src/__tests__/resolvers.test.ts|src/__tests__/graphql-v2/sync_query_datastore.test.ts
CLI_REGION: ap-northeast-1
depend-on:
- publish_to_local_registry
- identifier: resolvers_sync_query_datastore_api_6_api_lambda_auth
- identifier: api_6_api_lambda_auth_api_9
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
TEST_SUITE: >-
src/__tests__/resolvers.test.ts|src/__tests__/graphql-v2/sync_query_datastore.test.ts|src/__tests__/api_6.test.ts|src/__tests__/graphql-v2/api_lambda_auth.test.ts
CLI_REGION: eu-west-2
depend-on:
- publish_to_local_registry
- identifier: api_9
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
TEST_SUITE: src/__tests__/api_9.test.ts
CLI_REGION: eu-central-1
src/__tests__/api_6.test.ts|src/__tests__/graphql-v2/api_lambda_auth.test.ts|src/__tests__/api_9.test.ts
CLI_REGION: ap-southeast-1
depend-on:
- publish_to_local_registry
- identifier: function_migration
Expand Down Expand Up @@ -285,13 +275,31 @@ batch:
USE_PARENT_ACCOUNT: 1
depend-on:
- publish_to_local_registry
- identifier: schema_iterative_rollback_1
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-iterative-rollback-1.test.ts
CLI_REGION: eu-central-1
depend-on:
- publish_to_local_registry
- identifier: schema_iterative_rollback_2
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-iterative-rollback-2.test.ts
CLI_REGION: ap-southeast-1
depend-on:
- publish_to_local_registry
- identifier: schema_key
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-key.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: ap-southeast-2
depend-on:
- publish_to_local_registry
- identifier: containers_api_1
Expand All @@ -309,7 +317,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-4.test.ts
CLI_REGION: us-east-1
CLI_REGION: us-east-2
depend-on:
- publish_to_local_registry
- identifier: schema_auth_8
Expand All @@ -318,7 +326,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-8.test.ts
CLI_REGION: us-east-2
CLI_REGION: us-west-2
depend-on:
- publish_to_local_registry
- identifier: api_key_migration2
Expand All @@ -327,7 +335,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/migration/api.key.migration2.test.ts
CLI_REGION: us-west-2
CLI_REGION: eu-west-2
USE_PARENT_ACCOUNT: 1
depend-on:
- publish_to_local_registry
Expand All @@ -337,7 +345,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-11.test.ts
CLI_REGION: eu-west-2
CLI_REGION: eu-central-1
depend-on:
- publish_to_local_registry
- identifier: api_key_migration1
Expand All @@ -346,7 +354,16 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/migration/api.key.migration1.test.ts
CLI_REGION: eu-central-1
CLI_REGION: ap-southeast-1
depend-on:
- publish_to_local_registry
- identifier: api_11
buildspec: codebuild_specs/run_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/api_11.test.ts
CLI_REGION: ap-southeast-2
depend-on:
- publish_to_local_registry
- identifier: schema_model
Expand All @@ -355,7 +372,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-model.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: us-east-1
depend-on:
- publish_to_local_registry
- identifier: apigw
Expand All @@ -364,7 +381,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/apigw.test.ts
CLI_REGION: ap-southeast-1
CLI_REGION: us-east-2
depend-on:
- publish_to_local_registry
- identifier: containers_api_2
Expand All @@ -382,7 +399,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-14.test.ts
CLI_REGION: us-east-1
CLI_REGION: eu-west-2
depend-on:
- publish_to_local_registry
- identifier: schema_auth_7
Expand All @@ -391,7 +408,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-7.test.ts
CLI_REGION: us-east-2
CLI_REGION: eu-central-1
depend-on:
- publish_to_local_registry
- identifier: schema_auth_9
Expand All @@ -400,7 +417,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-9.test.ts
CLI_REGION: us-west-2
CLI_REGION: ap-northeast-1
depend-on:
- publish_to_local_registry
- identifier: schema_auth_5
Expand All @@ -409,7 +426,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-5.test.ts
CLI_REGION: eu-central-1
CLI_REGION: ap-southeast-2
depend-on:
- publish_to_local_registry
- identifier: searchable_datastore
Expand All @@ -418,7 +435,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/graphql-v2/searchable-datastore.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: us-east-1
USE_PARENT_ACCOUNT: 1
depend-on:
- publish_to_local_registry
Expand All @@ -428,7 +445,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-iterative-update-4.test.ts
CLI_REGION: ap-southeast-1
CLI_REGION: us-east-2
depend-on:
- publish_to_local_registry
- identifier: schema_searchable
Expand All @@ -437,7 +454,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-searchable.test.ts
CLI_REGION: ap-southeast-2
CLI_REGION: us-west-2
USE_PARENT_ACCOUNT: 1
depend-on:
- publish_to_local_registry
Expand All @@ -447,7 +464,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-auth-6.test.ts
CLI_REGION: us-east-1
CLI_REGION: eu-west-2
depend-on:
- publish_to_local_registry
- identifier: schema_connection
Expand All @@ -456,7 +473,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/schema-connection.test.ts
CLI_REGION: us-east-2
CLI_REGION: eu-central-1
depend-on:
- publish_to_local_registry
- identifier: searchable_previous_deployment_had_node_to_node
Expand All @@ -466,7 +483,7 @@ batch:
variables:
TEST_SUITE: >-
src/__tests__/graphql-v2/searchable-node-to-node-encryption/searchable-previous-deployment-had-node-to-node.test.ts
CLI_REGION: us-west-2
CLI_REGION: ap-northeast-1
depend-on:
- publish_to_local_registry
- identifier: searchable_previous_deployment_no_node_to_node
Expand All @@ -476,7 +493,7 @@ batch:
variables:
TEST_SUITE: >-
src/__tests__/graphql-v2/searchable-node-to-node-encryption/searchable-previous-deployment-no-node-to-node.test.ts
CLI_REGION: eu-west-2
CLI_REGION: ap-southeast-1
depend-on:
- publish_to_local_registry
- identifier: api_2
Expand All @@ -485,7 +502,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/api_2.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: ap-southeast-2
depend-on:
- publish_to_local_registry
- identifier: searchable_migration
Expand All @@ -494,7 +511,7 @@ batch:
compute-type: BUILD_GENERAL1_SMALL
variables:
TEST_SUITE: src/__tests__/transformer-migrations/searchable-migration.test.ts
CLI_REGION: ap-southeast-1
CLI_REGION: us-east-1
USE_PARENT_ACCOUNT: 1
depend-on:
- publish_to_local_registry
Expand Down
4 changes: 2 additions & 2 deletions codebuild_specs/migration_tests_v10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ phases:

artifacts:
files:
- $CODEBUILD_SRC_DIR/packages/amplify-migration-tests/amplify-migration-reports/*
discard-paths: yes
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-migration-tests/amplify-migration-reports
4 changes: 2 additions & 2 deletions codebuild_specs/migration_tests_v5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ phases:

artifacts:
files:
- $CODEBUILD_SRC_DIR/packages/amplify-migration-tests/amplify-migration-reports/*
discard-paths: yes
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-migration-tests/amplify-migration-reports
4 changes: 2 additions & 2 deletions codebuild_specs/migration_tests_v6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ phases:

artifacts:
files:
- $CODEBUILD_SRC_DIR/packages/amplify-migration-tests/amplify-migration-reports/*
discard-paths: yes
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-migration-tests/amplify-migration-reports
7 changes: 2 additions & 5 deletions codebuild_specs/run_e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ env:
CI: true
CODEBUILD: true
NODE_OPTIONS: --max-old-space-size=8096
# mock values to test artifact scanning
ENV_VAR_WITH_SECRETS: 'MOCK_ENV_VAR_FOR_SCANNING_SECRETS'
MOCK_ENV_VAR_FOR_SCANNING_SECRETS: 'abc123xyz'
phases:
build:
commands:
Expand All @@ -23,5 +20,5 @@ phases:

artifacts:
files:
- $CODEBUILD_SRC_DIR/packages/amplify-e2e-tests/amplify-e2e-reports/*
discard-paths: yes
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-e2e-tests/amplify-e2e-reports
2 changes: 1 addition & 1 deletion packages/amplify-e2e-core/src/categories/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ interface AddApiOptions {

const defaultOptions: AddApiOptions = {
apiName: '\r',
testingWithLatestCodebase: true,
testingWithLatestCodebase: false,
transformerVersion: 2,
};

Expand Down
17 changes: 12 additions & 5 deletions packages/amplify-e2e-core/src/init/amplifyPush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,19 @@ export function cancelIterativeAmplifyPush(
.wait(`Deploying iterative update ${idx.current} of ${idx.max} into`)
.wait(/.*AWS::AppSync::GraphQLSchema.*UPDATE_IN_PROGRESS.*/)
.sendCtrlC()
.run((err: Error) => {
if (err && !/Process exited with non zero exit code 130/.test(err.message)) {
reject(err);
} else {
resolve();
.run((err: Error, signal) => {
if (err) {
if (process.env.CODEBUILD) {
// In codebuild the code 130 is not sent but with exit code 2
// This is to catch the error in that scenario so that the test will proceed
if (!/Killed the process as no output receive/.test(err.message)) {
reject(err);
}
} else if (!/Process exited with non zero exit code 130/.test(err.message)) {
reject(err);
}
}
resolve();
});
});
}
Expand Down
Loading

0 comments on commit 07ac802

Please sign in to comment.