diff --git a/.github/scripts/poll_build_status.sh b/.github/scripts/poll_build_status.sh new file mode 100755 index 000000000..e1c097681 --- /dev/null +++ b/.github/scripts/poll_build_status.sh @@ -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; \ No newline at end of file diff --git a/.github/scripts/start_codebuild_batch.sh b/.github/scripts/start_codebuild_batch.sh new file mode 100755 index 000000000..9700f822b --- /dev/null +++ b/.github/scripts/start_codebuild_batch.sh @@ -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' \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75501c38b..53859b6b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ permissions: jobs: staticAnalysis: name: Static Analysis + environment: ci runs-on: &codebuild-linux codebuild-CryptoToolsCI-linux-aws-encryption-sdk-java-${{ github.run_id }}-${{ github.run_attempt }} steps: - name: Configure AWS Credentials @@ -30,6 +31,7 @@ jobs: image-override: "aws/codebuild/amazonlinux-x86_64-standard:5.0" vectorTests: name: Vector Tests + environment: ci runs-on: *codebuild-linux strategy: fail-fast: true @@ -60,6 +62,7 @@ jobs: JAVA_ENV_VERSION: ${{ matrix.platform.distribution }}${{ matrix.version }} vectorTestsMasterKeyProvider: name: Vector Tests MasterKeyProvider + environment: ci runs-on: *codebuild-linux strategy: fail-fast: true @@ -90,6 +93,7 @@ jobs: JAVA_ENV_VERSION: ${{ matrix.platform.distribution }}${{ matrix.version }} netVectorTests: name: ESDK-NET Vector Tests + environment: ci runs-on: *codebuild-linux strategy: fail-fast: true @@ -120,6 +124,7 @@ jobs: JAVA_ENV_VERSION: ${{ matrix.platform.distribution }}${{ matrix.version }} generateTestVectors: name: Generate Vectors + environment: ci runs-on: *codebuild-linux strategy: max-parallel: 1 @@ -172,6 +177,7 @@ jobs: --no-transfer-progress releaseCI: name: Release CI + environment: ci runs-on: *codebuild-linux steps: - name: Configure AWS Credentials @@ -194,6 +200,7 @@ jobs: validateCI: name: Validate CI + environment: ci runs-on: *codebuild-linux needs: releaseCI strategy: diff --git a/codebuild/ci/ci.yml b/codebuild/ci/ci.yml new file mode 100644 index 000000000..3b74de5a9 --- /dev/null +++ b/codebuild/ci/ci.yml @@ -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 ######### \ No newline at end of file