-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from phani-srikar/cb
feat: support e2e workflow on codebuild
- Loading branch information
Showing
13 changed files
with
185 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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 && _runE2ETestsLinux | ||
- 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 | ||
|
||
artifacts: | ||
files: | ||
- $CODEBUILD_SRC_DIR/packages/amplify-codegen-e2e-tests/amplify-e2e-reports/* | ||
discard-paths: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
REPO_OWNER="aws-amplify" | ||
REPO_NAME="amplify-codegen" | ||
|
||
# Function to get the latest workflow run ID | ||
get_latest_run_id() { | ||
latest_run_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs?event=workflow_dispatch&per_page=1" | \ | ||
jq -r '.workflow_runs[0].id') | ||
echo "$latest_run_id" | ||
} | ||
|
||
# Function to get the status of a workflow run | ||
get_run_status() { | ||
run_id="$1" | ||
run_status=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/runs/$run_id" | \ | ||
jq -r '.status') | ||
echo "$run_status" | ||
} | ||
|
||
# Function to trigger a workflow dispatch event to run the e2e test | ||
trigger_workflow() { | ||
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/actions/workflows/build-swift-modelgen.yml/dispatches" \ | ||
-d "{\"ref\":\"main\", \"inputs\":{\"MODELS_S3_URL\":\"${MODELS_S3_URL}\"}}" | ||
} | ||
|
||
main() { | ||
trigger_workflow | ||
sleep 10 # Wait to allow for the workflow to be triggered | ||
|
||
# Get the latest run ID and initial status | ||
latest_run_id=$(get_latest_run_id) | ||
echo "Latest run ID: $latest_run_id" | ||
latest_status=$(get_run_status "$latest_run_id") | ||
timeout=$((SECONDS + 600)) # 600 seconds = 10 minutes | ||
|
||
# Continuously check for status until completion | ||
while [[ "$latest_status" != "completed" && "$SECONDS" -lt "$timeout" ]]; do | ||
echo "Test run status: $latest_status" | ||
sleep 10 # Wait before checking again | ||
latest_status=$(get_run_status "$latest_run_id") | ||
done | ||
|
||
# Check if the run completed within the specified duration | ||
if [[ "$latest_status" != "completed" ]]; then | ||
echo "The test run did not complete within the specified duration." | ||
exit 1 | ||
fi | ||
|
||
# Check if the run failed and throw an error if it did | ||
if [[ "$latest_status" == "failure" ]]; then | ||
echo "The test run failed." | ||
exit 1 | ||
else | ||
echo "The test run succeeded." | ||
fi | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.