Skip to content

Commit

Permalink
added emit metric function with buildspec for canaries
Browse files Browse the repository at this point in the history
  • Loading branch information
tejas2008 committed Nov 20, 2024
1 parent 9436608 commit eae9262
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .codebuild/canary_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ batch:
depend-on:
- build_linux
- identifier: build_app_swift_us_east_1
buildspec: .codebuild/run_ios_modelgen_e2e_test.yml
buildspec: .codebuild/run_canary_ios_modelgen_e2e_test.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
Expand All @@ -31,7 +31,7 @@ batch:
depend-on:
- publish_to_local_registry
- identifier: build_app_android_us_east_1
buildspec: .codebuild/run_android_modelgen_e2e_test.yml
buildspec: .codebuild/run_canary_android_modelgen_e2e_test.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
Expand All @@ -40,7 +40,7 @@ batch:
depend-on:
- publish_to_local_registry
- identifier: build_app_ts_us_east_1
buildspec: .codebuild/run_e2e_tests.yml
buildspec: .codebuild/run_canary_e2e_tests.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
Expand Down
35 changes: 35 additions & 0 deletions .codebuild/run_canary_android_modelgen_e2e_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 0.2
env:
shell: bash
variables:
AMPLIFY_DIR: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin
AMPLIFY_PATH: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin/amplify
CI: true
CODEBUILD: true
NODE_OPTIONS: --max-old-space-size=8096

phases:
install:
commands:
- sudo apt update
- yes | sudo apt install android-sdk
- export ANDROID_HOME=/usr/lib/android-sdk
- yes | sudo apt install sdkmanager
# Review SDK licenses
- yes | sudo sdkmanager --licenses

build:
commands:
- source ./shared-scripts.sh && _setupE2ETestsLinux
- codebuild-breakpoint
- source ./shared-scripts.sh && _runE2ETestsLinux
post_build:
commands:
- source ./shared-scripts.sh && _unassumeTestAccountCredentials
- aws sts get-caller-identity
- source ./shared-scripts.sh && _scanArtifacts && _emitCodegenCanaryMetric

artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
26 changes: 26 additions & 0 deletions .codebuild/run_canary_e2e_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 0.2
env:
shell: bash
variables:
AMPLIFY_DIR: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin
AMPLIFY_PATH: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin/amplify
CI: true
CODEBUILD: true
NODE_OPTIONS: --max-old-space-size=8096

phases:
build:
commands:
- source ./shared-scripts.sh && _setupE2ETestsLinux
- codebuild-breakpoint
- source ./shared-scripts.sh && _runE2ETestsLinux
post_build:
commands:
- source ./shared-scripts.sh && _unassumeTestAccountCredentials
- aws sts get-caller-identity
- source ./shared-scripts.sh && _scanArtifacts && _emitCodegenCanaryMetric

artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
32 changes: 32 additions & 0 deletions .codebuild/run_canary_ios_modelgen_e2e_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 0.2
env:
shell: bash
variables:
AMPLIFY_DIR: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin
AMPLIFY_PATH: /root/.npm-global/lib/node_modules/@aws-amplify/cli-internal/bin/amplify
CI: true
CODEBUILD: true
NODE_OPTIONS: --max-old-space-size=8096
phases:
build:
commands:
- source ./shared-scripts.sh && _setupE2ETestsLinux
- codebuild-breakpoint
- source ./shared-scripts.sh && _runE2ETestsLinux
- unset AWS_ACCESS_KEY_ID
- unset AWS_SECRET_ACCESS_KEY
- unset AWS_SESSION_TOKEN
- export PATH_TO_MODELS=$CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/test-apps/swift/amplify/generated
- cd $PATH_TO_MODELS && zip -r models.zip models
- aws s3 cp $PATH_TO_MODELS/models.zip s3://$ARTIFACT_BUCKET_NAME/models.zip
- export MODELS_S3_URL=$(aws s3 presign s3://$ARTIFACT_BUCKET_NAME/models.zip --expires-in 3600)
- cd $CODEBUILD_SRC_DIR && ./.codebuild/scripts/run-ios-modelgen-e2e-test.sh
post_build:
commands:
- aws sts get-caller-identity
- source ./shared-scripts.sh && _scanArtifacts && _emitCodegenCanaryMetric

artifacts:
files:
- '**/*'
base-directory: $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports
11 changes: 11 additions & 0 deletions shared-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -492,3 +492,14 @@ function _deprecate {
yarn deprecate
unsetNpmRegistryUrl
}

function _emitCodegenCanaryMetric {
aws cloudwatch \
put-metric-data \
--metric-name CodegenCanarySuccessRate \
--namespace amplify-codegen-canary-e2e-tests \
--unit Count \
--value $CODEBUILD_BUILD_SUCCEEDING \
--dimensions branch=release \
--region us-west-2
}

0 comments on commit eae9262

Please sign in to comment.