-
Notifications
You must be signed in to change notification settings - Fork 54
chore(ci): add GH workflow for service check batch and e2e tests #713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,62 @@ | ||
#!/bin/bash | ||
|
||
error_exit() { | ||
echo "$1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
PROJECT_NAME=$1 | ||
# get the source version to be built (defaults to main branch if not specified) | ||
SOURCE_VERSION=${2:-main} | ||
|
||
echo "Starting CodeBuild project ${PROJECT_NAME}" | ||
|
||
# dump all GITHUB_* environment variables to file and pass to start job | ||
jq -n 'env | to_entries | [.[] | select(.key | startswith("GITHUB_"))] | [.[] | {name: .key, value:.value, type:"PLAINTEXT"}]' >/tmp/gh_env_vars.json | ||
|
||
START_RESULT=$( | ||
aws codebuild start-build-batch \ | ||
--project-name ${PROJECT_NAME} \ | ||
--source-version $SOURCE_VERSION \ | ||
--environment-variables-override file:///tmp/gh_env_vars.json | ||
) | ||
|
||
if [ "$?" != "0" ]; then | ||
error_exit "Could not start project. Exiting." | ||
else | ||
echo "Build started successfully." | ||
fi | ||
|
||
BUILD_ID=$(echo ${START_RESULT} | jq '.buildBatch.id' -r) | ||
echo "Build id $BUILD_ID" | ||
|
||
BUILD_STATUS="IN_PROGRESS" | ||
while [ "$BUILD_STATUS" == "IN_PROGRESS" ]; do | ||
echo "Checking build status." | ||
BUILD=$(aws codebuild batch-get-build-batches --ids ${BUILD_ID}) | ||
BUILD_STATUS=$(echo $BUILD | jq '.buildBatches[0].buildBatchStatus' -r) | ||
|
||
JOBS=$(echo $BUILD | jq '.buildBatches[0].buildGroups | [.[] | {identifier: .identifier, status: .currentBuildSummary.buildStatus} | select(.identifier | startswith("JOB"))]') | ||
TOTAL_JOBS=$(echo $JOBS | jq 'length') | ||
|
||
SUCCEEDED_CNT=$(echo $JOBS | jq '[.[] | select(.status == "SUCCEEDED")] | length') | ||
IN_PROGRESS_CNT=$(echo $JOBS | jq '[.[] | select(.status == "IN_PROGRESS")] | length') | ||
|
||
FAILED_CNT=$(($TOTAL_JOBS - $SUCCEEDED_CNT - $IN_PROGRESS_CNT)) | ||
|
||
if [ "$BUILD_STATUS" == "IN_PROGRESS" ]; then | ||
echo "Build is still in progress (failed=$FAILED_CNT; in_progress=$IN_PROGRESS_CNT; succeeded=$SUCCEEDED_CNT; total=$TOTAL_JOBS), waiting..." | ||
|
||
fi | ||
sleep 10 | ||
done | ||
|
||
if [ "$BUILD_STATUS" != "SUCCEEDED" ]; then | ||
BUILD=$(aws codebuild batch-get-build-batches --ids ${BUILD_ID}) | ||
FAILED_BUILDS=$(echo $BUILD | jq '.buildBatches[0].buildGroups | [.[] | {identifier: .identifier, status: .currentBuildSummary.buildStatus} | select(.status == "FAILED")]') | ||
echo "Failed builds in batch" | ||
echo $FAILED_BUILDS | ||
error_exit "Build failed, please review job output" | ||
else | ||
echo "Build succeeded." | ||
fi |
This file contains hidden or 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,38 @@ | ||
name: AWS CodeBuild CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write | ||
|
||
jobs: | ||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} | ||
aws-region: us-west-2 | ||
- name: Run E2E Tests | ||
uses: aws-actions/aws-codebuild-run-build@v1 | ||
with: | ||
project-name: gh-aws-sdk-kotlin-e2e-tests | ||
|
||
service-check-batch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v2 | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} | ||
aws-region: us-west-2 | ||
- name: Run Service Check Batch | ||
run: | | ||
.github/scripts/runCodeBuildBatchJob.sh gh-aws-sdk-kotlin-svc-check-batch ${{ github.event.pull_request.head.sha }} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: Should probably echo
START_RESULT
here in case there's anything useful for debugging.