diff --git a/.github/workflows/codebuild-ci.yml b/.github/workflows/codebuild-ci.yml deleted file mode 100644 index 0951c5eff69..00000000000 --- a/.github/workflows/codebuild-ci.yml +++ /dev/null @@ -1,244 +0,0 @@ -name: AWS CodeBuild CI - -on: - release: - types: [ published ] - pull_request: - types: [ opened, synchronize, reopened, labeled, unlabeled ] - branches: - - main - - '*-main' - workflow_dispatch: - inputs: - aws-sdk-kotlin-pr: - description: aws-sdk-kotlin PR number (optional) - type: number - required: false - smithy-kotlin-pr: - description: smithy-kotlin PR number (optional) - type: number - required: false - check-pr: - description: I verified that the PRs are not running any malicious code (If running for an external contributor) - required: true - type: boolean - default: false - -env: - SDK_PR: ${{ inputs.aws-sdk-kotlin-pr }} - SMITHY_PR: ${{ inputs.smithy-kotlin-pr }} - -permissions: - id-token: write - contents: read - pull-requests: write - -# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed -concurrency: - group: ci-codebuild-${{ github.ref }} - cancel-in-progress: true - -jobs: - e2e-tests: - if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - steps: - - name: Set start timestamp - id: start - run: printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT" - - name: Verify PRs are not running malicious code - if: ${{ (inputs.aws-sdk-kotlin-pr != '' || inputs.smithy-kotlin-pr != '') && inputs.check-pr == false }} - run: | - echo Please verify the PRs are not running any malicious code and mark the checkbox true when running the workflow - exit 1 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} - aws-region: us-west-2 - - name: Setup kat - uses: aws/aws-kotlin-repo-tools/.github/actions/setup-kat@main - - name: Run E2E Tests - id: e2e-tests - uses: aws-actions/aws-codebuild-run-build@v1 - with: - project-name: gh-aws-sdk-kotlin-e2e-tests - env-vars-for-codebuild: SDK_PR, SMITHY_PR - - name: Cancel build - if: ${{ cancelled() }} - env: - BUILD_ID: ${{ steps.e2e-tests.outputs.aws-build-id }} - run: | - if [ ! -z "$BUILD_ID"]; then - echo "cancelling in-progress build: id=$BUILD_ID" - aws codebuild stop-build --id $BUILD_ID - fi - - name: Calculate duration - id: end - if: always() - run: | - printf -v now '%(%s)T' - duration=$(( now - ${{ steps.start.outputs.timestamp }} )) - echo "duration=$duration" >> "$GITHUB_OUTPUT" - - name: Emit metrics - if: always() # run this step even if previous steps failed or the job is canceled - uses: aws/aws-kotlin-repo-tools/.github/actions/emit-metrics@main - with: - namespace: CI Metrics - dimensions: | - Product=aws-sdk-kotlin - JobName=${{ github.job }} - Branch=${{ github.base_ref || github.ref_name }} - metrics: | - WorkflowSucceeded:${{ job.status == 'success' && '1' || '0' }}:Count - WorkflowDuration:${{ steps.end.outputs.duration }}:Seconds - - service-check-batch-and-artifact-size-metrics: - if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - steps: - - name: Set start timestamp - id: start - run: printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT" - - name: Verify PRs are not running malicious code - if: ${{ (inputs.aws-sdk-kotlin-pr != '' || inputs.smithy-kotlin-pr != '') && inputs.check-pr == false }} - run: | - echo Please verify the PRs are not running any malicious code and mark the checkbox true when running the workflow - exit 1 - - name: Checkout sources - uses: actions/checkout@v2 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} - aws-region: us-west-2 - - name: Setup kat - uses: aws/aws-kotlin-repo-tools/.github/actions/setup-kat@main - - name: Configure Gradle - uses: aws/aws-kotlin-repo-tools/.github/actions/configure-gradle@main - - name: Run Service Check Batch and Calculate Artifact Size Metrics - id: svc-check-batch - run: | - REPOSITORY=$(echo ${{ github.repository }} | cut -d '/' -f 2) - PULL_REQUEST="" - INTERNAL=${{ github.event.number }} - EXTERNAL=${{ inputs.aws-sdk-kotlin-pr }} - - if [ ! -z "$INTERNAL" ]; then - PULL_REQUEST=${{ github.event.number }} - echo "Identified this an internal pull request build: $PULL_REQUEST" - elif [ ! -z "$EXTERNAL" ]; then - PULL_REQUEST=${{ inputs.aws-sdk-kotlin-pr }} - echo "Identified this as an external pull request build: $PULL_REQUEST" - else - echo "Couldn't identify this as an internal or external pull request" - exit 1 - fi - - .github/scripts/run-codebuild-batch-job.sh \ - --project gh-aws-sdk-kotlin-svc-check-batch \ - --source ${{ github.event.pull_request.head.sha }} \ - --pr-number $PULL_REQUEST \ - --repository $REPOSITORY \ - --external-contributor-sdk-pr-number ${{ inputs.aws-sdk-kotlin-pr }} \ - --external-contributor-smithy-pr-number ${{ inputs.smithy-kotlin-pr }} - - name: Cancel build - if: ${{ cancelled() }} - env: - BUILD_ID: ${{ steps.svc-check-batch.outputs.aws-build-id }} - run: | - if [ ! -z "$BUILD_ID" ]; then - echo "cancelling in-progress batch build: id=$BUILD_ID" - aws codebuild stop-build --id $BUILD_ID - fi - - name: Collect Artifact Size Metrics - run: | - PULL_REQUEST="" - INTERNAL=${{ github.event.number }} - EXTERNAL=${{ inputs.aws-sdk-kotlin-pr }} - - if [ ! -z "$INTERNAL" ]; then - PULL_REQUEST=${{ github.event.number }} - echo "Identified this an internal pull request build: $PULL_REQUEST" - elif [ ! -z "$EXTERNAL" ]; then - PULL_REQUEST=${{ inputs.aws-sdk-kotlin-pr }} - echo "Identified this as an external pull request build: $PULL_REQUEST" - else - echo "Couldn't identify this as an internal or external pull request" - exit 1 - fi - - ./gradlew collectDelegatedArtifactSizeMetrics -PpullRequest=$PULL_REQUEST - - name: Analyze Artifact Size Metrics - run: ./gradlew analyzeArtifactSizeMetrics - - - name: Show Results - uses: aws/aws-kotlin-repo-tools/.github/actions/artifact-size-metrics/show-results@main - - - name: Evaluate Result - if: ${{ !contains(github.event.pull_request.labels.*.name, 'acknowledge-artifact-size-increase') }} - run: | - cd build/reports/metrics - cat has-significant-change.txt | grep false || { - echo An artifact increased in size by more than allowed or a new artifact was created. - echo If this is expected please add the 'acknowledge-artifact-size-increase' label to this pull request. - exit 1 - } - - name: Calculate duration - id: end - if: always() - run: | - printf -v now '%(%s)T' - duration=$(( now - ${{ steps.start.outputs.timestamp }} )) - echo "duration=$duration" >> "$GITHUB_OUTPUT" - - name: Emit metrics - if: always() # run this step even if previous steps failed or the job is canceled - uses: aws/aws-kotlin-repo-tools/.github/actions/emit-metrics@main - with: - namespace: CI Metrics - dimensions: | - Product=aws-sdk-kotlin - JobName=${{ github.job }} - Branch=${{ github.base_ref || github.ref_name }} - metrics: | - WorkflowSucceeded:${{ job.status == 'success' && '1' || '0' }}:Count - WorkflowDuration:${{ steps.end.outputs.duration }}:Seconds - - release-artifact-size-metrics: - if: github.event_name == 'release' - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} - aws-region: us-west-2 - - name: Configure Gradle - uses: aws/aws-kotlin-repo-tools/.github/actions/configure-gradle@main - - name: Calculate Artifact Size Metrics - id: svc-check-batch - run: | - REPOSITORY=$(echo ${{ github.repository }} | cut -d '/' -f 2) - - .github/scripts/run-codebuild-batch-job.sh \ - --project gh-aws-sdk-kotlin-svc-check-batch \ - --source ${{ github.event.pull_request.head.sha }} \ - --repository $REPOSITORY \ - --release ${{ github.event.release.tag_name }} - - name: Cancel build - if: ${{ cancelled() }} - env: - BUILD_ID: ${{ steps.svc-check-batch.outputs.aws-build-id }} - run: | - if [ ! -z "$BUILD_ID" ]; then - echo "cancelling in-progress batch build: id=$BUILD_ID" - aws codebuild stop-build --id $BUILD_ID - fi - - name: Collect Artifact Size Metrics - run: ./gradlew collectDelegatedArtifactSizeMetrics -Prelease=${{ github.event.release.tag_name }} - - name: Save Artifact Size Metrics - run: ./gradlew saveArtifactSizeMetrics -Prelease=${{ github.event.release.tag_name }} - - name: Put Artifact Size Metrics in CloudWatch - run: ./gradlew putArtifactSizeMetricsInCloudWatch -Prelease=${{ github.event.release.tag_name }} diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml new file mode 100644 index 00000000000..a98342dfe7e --- /dev/null +++ b/.github/workflows/e2e-tests.yml @@ -0,0 +1,41 @@ +name: E2E tests + +on: + pull_request: + workflow_dispatch: + +jobs: + e2e-tests: + runs-on: ubuntu-latest + steps: + - name: Configure credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} + aws-region: us-west-2 + + - name: Tests + id: e2e-tests + uses: aws-actions/aws-codebuild-run-build@v1 + with: + project-name: gh-aws-sdk-kotlin-e2e-tests + source-version-override: ${{ github.ref }} + + - name: Cancel + if: ${{ cancelled() }} + env: + BUILD_ID: ${{ steps.e2e-tests.outputs.aws-build-id }} + run: | + if [ ! -z "$BUILD_ID"]; then + echo "Cancelling in-progress build: $BUILD_ID" + aws codebuild stop-build --id $BUILD_ID + fi + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +permissions: + id-token: write + contents: read + diff --git a/.github/workflows/release-metrics.yml b/.github/workflows/release-metrics.yml new file mode 100644 index 00000000000..380383bd2a4 --- /dev/null +++ b/.github/workflows/release-metrics.yml @@ -0,0 +1,31 @@ +name: Release metrics + +on: + release: + types: [ published ] + +jobs: + build-sdk: + runs-on: ubuntu-latest + steps: + - name: Configure credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} + aws-region: us-west-2 + + - name: Build and upload metrics + env: + GITHUB_REPOSITORY: ${{ github.repository }} + UPLOAD: 'true' + RELEASE_METRICS: 'true' + IDENTIFIER: 'null' # Only needed for pull requests + uses: aws-actions/aws-codebuild-run-build@v1 + with: + project-name: aws-sdk-kotlin-service-build + source-version-override: ${{ github.ref }} + env-vars-for-codebuild: GITHUB_REPOSITORY, UPLOAD, RELEASE_METRICS, IDENTIFIER + +permissions: + id-token: write + contents: read diff --git a/.github/workflows/service-ci.yml b/.github/workflows/service-ci.yml new file mode 100644 index 00000000000..54a7a4392d8 --- /dev/null +++ b/.github/workflows/service-ci.yml @@ -0,0 +1,53 @@ +name: Service CI + +on: + pull_request: + workflow_dispatch: + +jobs: + build-sdk: + runs-on: ubuntu-latest + steps: + - name: Configure credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }} + aws-region: us-west-2 + + - name: Build and upload metrics + id: build + env: + GITHUB_REPOSITORY: ${{ github.repository }} + UPLOAD: 'true' + RELEASE_METRICS: 'false' + IDENTIFIER: ${{ github.ref_name }} + uses: aws-actions/aws-codebuild-run-build@v1 + with: + project-name: aws-sdk-kotlin-service-build + source-version-override: ${{ github.ref }} + env-vars-for-codebuild: GITHUB_REPOSITORY, UPLOAD, RELEASE_METRICS, IDENTIFIER + + - name: Process metrics + uses: awslabs/aws-kotlin-repo-tools/.github/actions/artifact-size-metrics/download-and-process@asm-v2 # TODO: Change to main before merging + with: + download: 'true' + + - name: Cancel + if: ${{ cancelled() }} + env: + BUILD_ID: ${{ steps.build.outputs.aws-build-id }} + run: | + if [ ! -z "$BUILD_ID"]; then + echo "Cancelling in-progress build: id=$BUILD_ID" + aws codebuild stop-build --id $BUILD_ID + fi + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +permissions: + pull-requests: write + id-token: write + contents: read + diff --git a/build.gradle.kts b/build.gradle.kts index 87a08af1de2..e89785a847a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,14 +34,6 @@ plugins { // ensure the correct version of KGP ends up on our buildscript classpath id(libs.plugins.kotlin.multiplatform.get().pluginId) apply false id(libs.plugins.kotlin.jvm.get().pluginId) apply false - alias(libs.plugins.aws.kotlin.repo.tools.artifactsizemetrics) -} - -artifactSizeMetrics { - artifactPrefixes = setOf(":services", ":aws-runtime") - closurePrefixes = setOf(":services") - significantChangeThresholdPercentage = 5.0 - projectRepositoryName = "aws-sdk-kotlin" } val testJavaVersion = typedProp("test.java.version")?.let { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 944b2a0099e..1d289cfe9de 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -155,5 +155,4 @@ kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", vers ksp = { id = "com.google.devtools.ksp", version.ref = "ksp-version" } aws-kotlin-repo-tools-kmp = { id = "aws.sdk.kotlin.gradle.kmp", version.ref = "aws-kotlin-repo-tools-version" } aws-kotlin-repo-tools-smithybuild = { id = "aws.sdk.kotlin.gradle.smithybuild", version.ref = "aws-kotlin-repo-tools-version" } -aws-kotlin-repo-tools-artifactsizemetrics = { id = "aws.sdk.kotlin.gradle.artifactsizemetrics", version.ref = "aws-kotlin-repo-tools-version" } gradle-plugin-publish = { id = "com.gradle.plugin-publish", version = "1.2.1"}