Skip to content

Commit b6113bd

Browse files
authored
Merge pull request #655 from aws-amplify/dx-improvements
feat: some ops improvements
2 parents b89bc86 + f90d542 commit b6113bd

14 files changed

+337
-63
lines changed

.codebuild/e2e_workflow.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ batch:
4141
variables:
4242
TEST_SUITE: src/__tests__/build-app-swift.test.ts
4343
CLI_REGION: us-east-2
44+
debug-session: true
4445
depend-on:
4546
- publish_to_local_registry
4647
- identifier: build_app_android
@@ -50,6 +51,7 @@ batch:
5051
variables:
5152
TEST_SUITE: src/__tests__/build-app-android.test.ts
5253
CLI_REGION: us-east-2
54+
debug-session: true
5355
depend-on:
5456
- publish_to_local_registry
5557
- identifier: >-

.codebuild/e2e_workflow_base.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ batch:
4141
variables:
4242
TEST_SUITE: src/__tests__/build-app-swift.test.ts
4343
CLI_REGION: us-east-2
44+
debug-session: true
4445
depend-on:
4546
- publish_to_local_registry
4647
- identifier: build_app_android
@@ -50,5 +51,6 @@ batch:
5051
variables:
5152
TEST_SUITE: src/__tests__/build-app-android.test.ts
5253
CLI_REGION: us-east-2
54+
debug-session: true
5355
depend-on:
5456
- publish_to_local_registry

.codebuild/release_workflow.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ batch:
1818
buildspec: .codebuild/test.yml
1919
depend-on:
2020
- build_linux
21-
- identifier: lint
22-
buildspec: .codebuild/lint.yml
23-
depend-on:
24-
- build_linux
2521
- identifier: verify_api_extract
2622
buildspec: .codebuild/verify_api_extract.yml
2723
depend-on:

.codebuild/run_android_modelgen_e2e_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ phases:
2020

2121
build:
2222
commands:
23+
- source ./shared-scripts.sh && _setupE2ETestsLinux
24+
- codebuild-breakpoint
2325
- source ./shared-scripts.sh && _runE2ETestsLinux
2426
post_build:
2527
commands:

.codebuild/run_e2e_tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ env:
1111
phases:
1212
build:
1313
commands:
14+
- source ./shared-scripts.sh && _setupE2ETestsLinux
15+
- codebuild-breakpoint
1416
- source ./shared-scripts.sh && _runE2ETestsLinux
1517
post_build:
1618
commands:

.codebuild/run_ios_modelgen_e2e_test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ env:
1010
phases:
1111
build:
1212
commands:
13+
- source ./shared-scripts.sh && _setupE2ETestsLinux
14+
- codebuild-breakpoint
1315
- source ./shared-scripts.sh && _runE2ETestsLinux
16+
- unset AWS_ACCESS_KEY_ID
17+
- unset AWS_SECRET_ACCESS_KEY
18+
- unset AWS_SESSION_TOKEN
1419
- export PATH_TO_MODELS=$CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/test-apps/swift/amplify/generated
1520
- cd $PATH_TO_MODELS && zip -r models.zip models
1621
- aws s3 cp $PATH_TO_MODELS/models.zip s3://$ARTIFACT_BUCKET_NAME/models.zip

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ test.out.log
2727
package-lock.json
2828
.idea
2929
scripts/.env
30+
.codebuild/debug_workflow.yml

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@
3333
"refresh-lockfile": "rimraf yarn.lock && yarn",
3434
"extract-api": "lerna run extract-api",
3535
"verify-api-extract": "yarn extract-api && ./scripts/verify-extract-api.sh",
36-
"trigger-release": "source ./scripts/cloud-release.sh && release",
36+
"trigger-release": "source ./scripts/cloud-release.sh && triggerRelease",
37+
"trigger-tag-release": "source ./scripts/cloud-release.sh && triggerTagRelease",
3738
"view-test-artifact": "./scripts/view-test-artifacts.sh",
3839
"cleanup-stale-resources": "source ./scripts/cloud-utils.sh && cleanupStaleResources",
3940
"cloud-e2e": "source scripts/cloud-utils.sh && cloudE2E",
4041
"cloud-e2e-beta": "source scripts/cloud-utils.sh && cloudE2EBeta",
41-
"split-e2e-tests": "yarn ts-node ./scripts/split-e2e-tests.ts && git add .codebuild/e2e_workflow.yml"
42+
"split-e2e-tests": "yarn ts-node ./scripts/split-e2e-tests.ts && git add .codebuild/e2e_workflow.yml",
43+
"view-test-artifacts": "yarn ts-node ./scripts/view-test-artifacts.ts",
44+
"cloud-e2e-debug": "source scripts/cloud-utils.sh && cloudE2EDebug"
4245
},
4346
"bugs": {
4447
"url": "https://github.com/aws-amplify/amplify-codegen/issues"
@@ -71,11 +74,16 @@
7174
"@commitlint/config-conventional": "^17.0.3",
7275
"@commitlint/config-lerna-scopes": "^17.0.2",
7376
"@microsoft/api-extractor": "^7.33.5",
77+
"@types/cli-progress": "3.11.0",
78+
"@types/fs-extra": "^8.0.1",
79+
"@types/glob": "^7.2.0",
7480
"@types/jest": "^27.0.0",
7581
"@types/js-yaml": "^4.0.0",
7682
"@typescript-eslint/eslint-plugin": "^4.0.0",
7783
"@typescript-eslint/parser": "^4.0.0",
7884
"amplify-headless-interface": "^1.13.1",
85+
"aws-sdk": "2.1414.0",
86+
"cli-progress": "3.12.0",
7987
"cmd-shim": "^3.0.3",
8088
"codecov": "^3.7.0",
8189
"commitizen": "^4.2.4",
@@ -92,6 +100,7 @@
92100
"eslint-plugin-prettier": "^3.1.2",
93101
"eslint-plugin-react": "^7.21.5",
94102
"eslint-plugin-spellcheck": "^0.0.17",
103+
"execa": "^5.1.1",
95104
"glob": "^7.1.6",
96105
"graphql-transformer-core": "^8.0.0",
97106
"husky": "^3.0.3",
@@ -106,8 +115,7 @@
106115
"rimraf": "^3.0.0",
107116
"ts-jest": "^27.0.0",
108117
"ts-node": "^8.10.1",
109-
"typescript": "4.7.4",
110-
"execa": "^5.1.1"
118+
"typescript": "4.7.4"
111119
},
112120
"resolutions": {
113121
"@aws-amplify/amplify-cli-core": "4.0.4",

scripts/cloud-release.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ export RELEASE_ROLE_NAME=CodebuildDeveloper
44
export RELEASE_PROFILE_NAME=AmplifyAPIPluginRelease
55
export RELEASE_PROJECT_NAME=amplify-codegen-release-workflow
66

7-
function release {
7+
function triggerRelease {
8+
triggerProjectBatch $RELEASE_ACCOUNT_PROD $RELEASE_ROLE_NAME "${RELEASE_PROFILE_NAME}Prod" $RELEASE_PROJECT_NAME "release"
9+
}
10+
11+
function triggerTagRelease {
812
branch_name=$(git branch --show-current)
9-
echo "Running release workflow from branch ${branch_name}"
13+
echo "Running tag release workflow from branch ${branch_name}"
14+
15+
git fetch origin
16+
if [ $(git rev-parse HEAD) != $(git rev-parse origin/${branch_name}) ]
17+
then
18+
echo "You have local commits on branch ${branch_name} that are not pushed to origin. Push them before running the tag release workflow."
19+
exit 1
20+
fi
1021
triggerProjectBatch $RELEASE_ACCOUNT_PROD $RELEASE_ROLE_NAME "${RELEASE_PROFILE_NAME}Prod" $RELEASE_PROJECT_NAME $branch_name
1122
}

scripts/cloud-utils.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,52 @@ function cleanupStaleResources {
8585
TARGET_BRANCH=$CURR_BRANCH
8686
triggerProject $E2E_ACCOUNT_PROD $CLEANUP_ROLE_NAME $CLEANUP_PROFILE_NAME $CLEANUP_PROJECT_NAME $TARGET_BRANCH
8787
}
88+
89+
function triggerProjectBatchWithDebugSession {
90+
account_number=$1
91+
role_name=$2
92+
profile_name=$3
93+
project_name=$4
94+
target_branch=$5
95+
authenticate $account_number $role_name $profile_name
96+
echo AWS Account: $account_number
97+
echo Project: $project_name
98+
echo Target Branch: $target_branch
99+
debug_spec=$(cat .codebuild/debug_workflow.yml)
100+
RESULT=$(aws codebuild start-build-batch --region=$REGION --profile="${profile_name}" --project-name $project_name --source-version=$target_branch \
101+
--debug-session-enabled \
102+
--buildspec-override "$debug_spec" \
103+
--environment-variables-override name=BRANCH_NAME,value=$target_branch,type=PLAINTEXT \
104+
--query 'buildBatch.id' --output text)
105+
echo "https://$REGION.console.aws.amazon.com/codesuite/codebuild/$account_number/projects/$project_name/batch/$RESULT?region=$REGION"
106+
}
107+
108+
function cloudE2EDebug {
109+
echo Generating the debug E2E buildspec
110+
if [ $# -eq 0 ]; then
111+
echo "Please provide the batch build id of codebuild"
112+
exit 1
113+
fi
114+
generatedDebugSpecForFailedTests $1
115+
echo Running Prod E2E Test Suite
116+
E2E_ROLE_NAME=CodebuildDeveloper
117+
E2E_PROFILE_NAME=AmplifyAPIE2EProd
118+
E2E_PROJECT_NAME=amplify-codegen-e2e-workflow
119+
TARGET_BRANCH=$CURR_BRANCH
120+
triggerProjectBatchWithDebugSession $E2E_ACCOUNT_PROD $E2E_ROLE_NAME $E2E_PROFILE_NAME $E2E_PROJECT_NAME $TARGET_BRANCH
121+
}
122+
123+
function generatedDebugSpecForFailedTests {
124+
# Get temporary access for the account
125+
E2E_ROLE_NAME=CodebuildDeveloper
126+
E2E_PROFILE_NAME=AmplifyAPIE2EProd
127+
authenticate $E2E_ACCOUNT_PROD $E2E_ROLE_NAME "$E2E_PROFILE_NAME"
128+
local batch_build_id=$1
129+
echo "Getting failed test suites"
130+
failed_tests=$(aws codebuild batch-get-build-batches --profile="$E2E_PROFILE_NAME" --ids "$batch_build_id" --region us-east-1 --query 'buildBatches[0].buildGroups' | jq -c '.[] | select(.currentBuildSummary.buildStatus == "FAILED").identifier')
131+
if [ -z "$failed_tests" ]; then
132+
echo "No failed tests found in batch $1"
133+
exit 0
134+
fi
135+
echo $failed_tests | xargs yarn ts-node ./scripts/split-e2e-tests.ts --debug
136+
}

0 commit comments

Comments
 (0)