Skip to content

chore: Use Github environment for CI secrets #1311

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/scripts/poll_build_status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Polls the provided CodeBuild batch ID until the build terminates
# Script terminates when the build status is not "IN_PROGRESS".
#
# Usage: ./poll_build_status.sh [batch-build-id]

BUILD_TIMEOUT_MINUTES=120
POLL_COUNTER=0

while [ $POLL_COUNTER -lt $BUILD_TIMEOUT_MINUTES ]; do
BUILD_STATUS=$(aws codebuild batch-get-build-batches \
--ids "$1" \
| jq -r --arg BATCH_ID "$1" '.buildBatches[]
| select(.id == $BATCH_ID)
| .buildBatchStatus' )

echo "Build status is $BUILD_STATUS after $POLL_COUNTER minutes"
# If build succeeds, exit 0; Github will interpret 'exit 0' as successful job run
if [ "$BUILD_STATUS" == "SUCCEEDED" ]; then
exit 0
fi

# If build is not successful nor in-progress, it has either failed, timed-out, faulted, or been stopped.
# Github will interpret 'exit 1' as job failure
if [ "$BUILD_STATUS" != "IN_PROGRESS" ]; then
exit 1
fi

((POLL_COUNTER++))
sleep 60
done

# If job does not report success within BUILD_TIMEOUT_MINUTES, fail Github job
exit 1;
9 changes: 9 additions & 0 deletions .github/scripts/start_codebuild_batch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Starts a CodeBuild batch with provided source version
# Returns build batch ID for build
#
# Usage: ./start_codebuild_batch.sh [source_version]
aws codebuild start-build-batch \
--region us-west-2 \
--project-name AWS-ESDK-Java-CI \
--source-version "$1" \
| jq -r '.buildBatch.id'
106 changes: 14 additions & 92 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ permissions:
contents: read

jobs:
staticAnalysis:
name: Static Analysis
runCodeBuildCI:
name: Run CodeBuild CI
environment: ci
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
Expand All @@ -20,93 +21,14 @@ jobs:
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
aws-region: us-west-2
role-duration-seconds: 3600
- name: Run Static Analysis
uses: aws-actions/aws-codebuild-run-build@v1
timeout-minutes: 60
with:
project-name: AWS-ESDK-Java-CI
buildspec-override: codebuild/ci/static-analysis.yml
compute-type-override: BUILD_GENERAL1_MEDIUM
image-override: aws/codebuild/amazonlinux2-x86_64-standard:3.0
vectorTests:
name: Vector Tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
platform:
- distribution: openjdk
image: "aws/codebuild/standard:3.0"
- distribution: corretto
image: "aws/codebuild/amazonlinux2-x86_64-standard:3.0" # Corretto only runs on AL2
version: [ 8, 11 ]
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
role-duration-seconds: 3600
- name: Vector Tests ${{ matrix.platform.distribution }}${{ matrix.version }}
uses: aws-actions/aws-codebuild-run-build@v1
timeout-minutes: 60
with:
project-name: AWS-ESDK-Java-CI
buildspec-override: codebuild/ci/vectors-ci.yml
compute-type-override: BUILD_GENERAL1_LARGE
image-override: ${{ matrix.platform.image }}
env-vars-for-codebuild: JAVA_ENV_VERSION
env:
JAVA_ENV_VERSION: ${{ matrix.platform.distribution }}${{ matrix.version }}
releaseCI:
name: Release CI
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
role-duration-seconds: 3600
- name: Release CI
uses: aws-actions/aws-codebuild-run-build@v1
timeout-minutes: 60
with:
project-name: AWS-ESDK-Java-CI
buildspec-override: codebuild/ci/release-ci.yml
compute-type-override: BUILD_GENERAL1_LARGE
image-override: aws/codebuild/standard:3.0
validateCI:
name: Validate CI
runs-on: ubuntu-latest
needs: releaseCI
strategy:
fail-fast: true
matrix:
platform:
- distribution: openjdk
image: "aws/codebuild/standard:3.0"
- distribution: corretto
image: "aws/codebuild/amazonlinux2-x86_64-standard:3.0" # Corretto only runs on AL2
version: [ 8, 11 ]
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
role-duration-seconds: 3600
- name: Validate CI ${{ matrix.platform.distribution }}${{ matrix.version }}
uses: aws-actions/aws-codebuild-run-build@v1
timeout-minutes: 60
with:
project-name: AWS-ESDK-Java-CI
buildspec-override: codebuild/ci/validate-ci.yml
compute-type-override: BUILD_GENERAL1_MEDIUM
image-override: ${{ matrix.platform.image }}
env-vars-for-codebuild: |
JAVA_ENV_VERSION,
JAVA_NUMERIC_VERSION
env:
JAVA_ENV_VERSION: ${{ matrix.platform.distribution }}${{ matrix.version }}
JAVA_NUMERIC_VERSION: ${{ matrix.version }}
- name: Checkout
uses: actions/checkout@v3
- name: Start CodeBuild Batch Build
run: |
echo "BATCH_ID<<EOF" >> $GITHUB_ENV
./.github/scripts/start_codebuild_batch.sh ${{ github.sha }} >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash
- name: Wait for CodeBuild completion
run: ./.github/scripts/poll_build_status.sh ${{ env.BATCH_ID }}
shell: bash
89 changes: 89 additions & 0 deletions codebuild/ci/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
version: 0.2

# TODO: Replace/Augment build-graph with build-matrix
# Note: It's possible that 9 builds will be running concurrently with the current arrangement

batch:
fast-fail: false
build-graph:
- identifier: static_analysis
buildspec: codebuild/ci/static-analysis.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
######### Start Vector tests #########
- identifier: vectors_ci_openjdk8
buildspec: codebuild/ci/vectors-ci.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
JAVA_ENV_VERSION: openjdk8
image: aws/codebuild/standard:3.0
- identifier: vectors_ci_openjdk11
buildspec: codebuild/ci/vectors-ci.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
JAVA_ENV_VERSION: openjdk11
image: aws/codebuild/standard:3.0
- identifier: vectors_ci_corretto8
buildspec: codebuild/ci/vectors-ci.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
JAVA_ENV_VERSION: corretto8
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
- identifier: vectors_ci_corretto11
buildspec: codebuild/ci/vectors-ci.yml
env:
compute-type: BUILD_GENERAL1_LARGE
variables:
JAVA_ENV_VERSION: corretto11
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
######### End Vector tests #########
- identifier: release_ci
buildspec: codebuild/ci/release-ci.yml
env:
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:3.0
######### Start JAR Smoke tests #########
- identifier: validate_ci_openjdk8
depend-on:
- release_ci
buildspec: codebuild/ci/validate-ci.yml
env:
variables:
JAVA_ENV_VERSION: openjdk8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/standard:3.0
- identifier: validate_ci_openjdk11
depend-on:
- release_ci
buildspec: codebuild/ci/validate-ci.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
JAVA_ENV_VERSION: openjdk11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/standard:3.0
- identifier: validate_ci_corretto8
depend-on:
- release_ci
buildspec: codebuild/ci/validate-ci.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
JAVA_ENV_VERSION: corretto8
JAVA_NUMERIC_VERSION: 8
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
- identifier: validate_ci_corretto11
depend-on:
- release_ci
buildspec: codebuild/ci/validate-ci.yml
env:
compute-type: BUILD_GENERAL1_MEDIUM
variables:
JAVA_ENV_VERSION: corretto11
JAVA_NUMERIC_VERSION: 11
image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
######### End JAR Smoke tests #########