From 9cfb9be3de76f79622281d4e28da30f69aeab4bd Mon Sep 17 00:00:00 2001 From: 0marperez Date: Mon, 22 Apr 2024 12:26:19 -0400 Subject: [PATCH 1/2] Testing workflow --- .github/workflows/artifact-size-metrics.yml | 110 ++++++++++++++++++++ build.gradle.kts | 7 ++ settings.gradle.kts | 6 +- 3 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/artifact-size-metrics.yml diff --git a/.github/workflows/artifact-size-metrics.yml b/.github/workflows/artifact-size-metrics.yml new file mode 100644 index 000000000..7d0a386d3 --- /dev/null +++ b/.github/workflows/artifact-size-metrics.yml @@ -0,0 +1,110 @@ +name: Artifact Size Metrics +on: + pull_request: + types: [ opened, synchronize, reopened, labeled, unlabeled ] + branches: [ main ] + release: + types: [published] + +permissions: + id-token: write + contents: read + pull-requests: write + +jobs: + release-metrics: + if: ${{ github.event_name }} == 'release' + runs-on: ubuntu-latest + steps: + - name: Checkout Sources + uses: actions/checkout@v4 + - 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: Generate Artifact Size Metrics + run: ./gradlew artifactSizeMetrics + - name: Save Artifact Size Metrics + run: | + cd build/reports/metrics/ + REPOSITORY=$(echo ${{ github.repository }} | cut -d '/' -f 2) + aws s3 cp artifact-size-metrics.csv s3://${{ secrets.ARTIFACT_METRICS_BUCKET }}/$REPOSITORY-${{ github.event.release.tag_name }}-release.csv + aws s3 cp artifact-size-metrics.csv s3://${{ secrets.ARTIFACT_METRICS_BUCKET }}/$REPOSITORY-latest-release.csv + - name: Put Artifact Size Metrics in CloudWatch + run: ./gradlew putArtifactSizeMetricsInCloudWatch -Prelease=${{ github.event.release.tag_name }} + size-check: + if: ${{ github.event_name }} == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Checkout Sources + uses: actions/checkout@v4 + - 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: Generate Artifact Size Metrics + run: ./gradlew artifactSizeMetrics + - name: Analyze Artifact Size Metrics + run: ./gradlew analyzeArtifactSizeMetrics + - name: Show Results + uses: actions/github-script@v7 + with: + script: | + const getComments = + `query { + repository(owner:"${context.repo.owner}", name:"${context.repo.repo}"){ + pullRequest(number: ${context.issue.number}) { + id + comments(last:100) { + nodes { + id + body + author { + login + } + isMinimized + } + } + } + } + }` + + const response = await github.graphql(getComments) + const comments = response.repository.pullRequest.comments.nodes + + for (const i in comments) { + if (comments[i].author.login == 'github-actions' && !comments[i].isMinimized && comments[i].body.startsWith('Affected Artifacts')) { + const hideComment = + `mutation { + minimizeComment(input:{subjectId:"${comments[i].id}", classifier:OUTDATED}){ + clientMutationId + } + }` + + await github.graphql(hideComment) + } + } + + const fs = require('node:fs') + const comment = fs.readFileSync('build/reports/metrics/artifact-analysis.md', 'utf8') + + const writeComment = + `mutation { + addComment(input:{body:"""${comment}""", subjectId:"${response.repository.pullRequest.id}"}){ + clientMutationId + } + }` + + await github.graphql(writeComment) + + - name: Evaluate + if: ${{ !contains(github.event.pull_request.labels.*.name, 'acknowledge-artifact-size-increase') }} + run: | + cd build/reports/metrics/artifact-analysis.md + cat has-significant-change.txt | grep true + if [ $? = 0 ]; then + echo An artifact increased in size by more than allowed or a new artifact was created. + exit 1 + fi diff --git a/build.gradle.kts b/build.gradle.kts index da4fdfb1e..0fee9c2cc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,6 +24,13 @@ plugins { // since build-plugins also has version in its dependency closure alias(libs.plugins.kotlin.multiplatform) apply false alias(libs.plugins.kotlin.jvm) apply false + id("artifact-size-metrics") version "0.4.2" // TODO: Use lib.versions.toml +} + +artifactSizeMetrics { + artifactPrefixes = setOf(":codegen", ":runtime") + significantChangeThresholdPercentage = 5.0 + projectRepositoryName = "smithy-kotlin" } val testJavaVersion = typedProp("test.java.version")?.let { diff --git a/settings.gradle.kts b/settings.gradle.kts index bbbbdff7e..4a6f0fad6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,9 +11,9 @@ pluginManagement { maven { name = "kotlinRepoTools" url = java.net.URI("https://d2gys1nrxnjnyg.cloudfront.net/releases") - content { - includeGroupByRegex("""aws\.sdk\.kotlin.*""") - } +// content { +// includeGroupByRegex("""aws\.sdk\.kotlin.*""") +// } } } } From d5bbb862434ffa149b337a3ec6ab1254ff5de2ad Mon Sep 17 00:00:00 2001 From: 0marperez Date: Mon, 22 Apr 2024 12:28:19 -0400 Subject: [PATCH 2/2] Remove exta CI --- .github/workflows/api-compat-verification.yml | 32 ----- .github/workflows/changelog-verification.yml | 24 ---- .github/workflows/continuous-integration.yml | 134 ------------------ .github/workflows/dependabot.yml | 17 --- 4 files changed, 207 deletions(-) delete mode 100644 .github/workflows/api-compat-verification.yml delete mode 100644 .github/workflows/changelog-verification.yml delete mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .github/workflows/dependabot.yml diff --git a/.github/workflows/api-compat-verification.yml b/.github/workflows/api-compat-verification.yml deleted file mode 100644 index 26c7ef390..000000000 --- a/.github/workflows/api-compat-verification.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: API compatibility verification - -on: - pull_request: - types: [ opened, synchronize, reopened, labeled, unlabeled ] - branches: [ main ] - -jobs: - api-compat-verification: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Check for API compatibility - if: ${{ !contains(github.event.pull_request.labels.*.name, 'acknowledge-api-break') }} - run: | - git fetch origin ${{ github.base_ref }} --depth 1 && \ - git diff remotes/origin/${{ github.base_ref }} --numstat "*.api" | awk ' - BEGIN { s = 0 } - - # git diff numstat shows lines deleted in field 2, hence sum up field 2 across all items - { s += $2 } - - # exit with the number of lines deleted as the result code so that `if failure()` works below - END { exit s } - ' - - name: Error message - if: ${{ failure() }} - run: | - echo "::error ::This change modifies the public API in a way that may be backwards-incompatible. Carefully review this pull request and either:" - echo "::error ::* Revert the changes which caused the API incompatibility –or–" - echo "::error ::* Add the 'acknowledge-api-break' label to this PR (in rare cases warranting an API breakage)" - exit 1 diff --git a/.github/workflows/changelog-verification.yml b/.github/workflows/changelog-verification.yml deleted file mode 100644 index 547b155ab..000000000 --- a/.github/workflows/changelog-verification.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Changelog verification - -on: - pull_request: - types: [ opened, synchronize, reopened, labeled, unlabeled ] - branches: [ main ] - -jobs: - changelog-verification: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Check for changelog entry - if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-changelog') }} - run: | - git fetch origin ${{ github.base_ref }} --depth 1 && \ - git diff remotes/origin/${{ github.base_ref }} --name-only | grep -P "\.changes/[0-9a-f-]+\.json" - - name: Error message - if: ${{ failure() }} - run: | - echo "::error ::No new/updated changelog entry found in /.changes directory. Please either:" - echo "::error ::* Add a changelog entry (see CONTRIBUTING.md for instructions) –or–" - echo "::error ::* Add the 'no-changelog' label to this PR (in rare cases not warranting a changelog entry)" - exit 1 diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml deleted file mode 100644 index c711fff64..000000000 --- a/.github/workflows/continuous-integration.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] - pull_request: - workflow_dispatch: - -# Allow one instance of this workflow per pull request, and cancel older runs when new changes are pushed -concurrency: - group: ci-pr-${{ github.ref }} - cancel-in-progress: true - -env: - RUN: ${{ github.run_id }}-${{ github.run_number }} - GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dkotlin.incremental=false" - -jobs: - jvm: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - # we build with a specific JDK version but source/target compatibility should ensure the jar is usable by - # the target versions we want to support - java-version: - - 8 - - 11 - - 17 - - 21 - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Configure JDK - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: 17 - cache: 'gradle' - - name: Test - shell: bash - run: | - ./gradlew -Ptest.java.version=${{ matrix.java-version }} jvmTest --stacktrace - - all-platforms: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Configure JDK - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: 17 - cache: 'gradle' - - name: Test - shell: bash - run: | - echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties - ./gradlew apiCheck - ./gradlew test jvmTest - - name: Save Test Reports - if: failure() - uses: actions/upload-artifact@v3 - with: - name: test-reports-${{ matrix.os }} - path: '**/build/reports' - - protocol-tests: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Configure JDK - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: 17 - cache: 'gradle' - - name: Test - shell: bash - run: | - ./gradlew publishToMavenLocal - ./gradlew testAllProtocols - - downstream: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - path: 'smithy-kotlin' - - name: Checkout tools - uses: actions/checkout@v4 - with: - path: 'aws-kotlin-repo-tools' - repository: 'awslabs/aws-kotlin-repo-tools' - ref: '0.2.3' - sparse-checkout: | - .github - - name: Checkout aws-sdk-kotlin - uses: ./aws-kotlin-repo-tools/.github/actions/checkout-head - with: - # smithy-kotlin is checked out as a sibling dir which will automatically make it an included build - path: 'aws-sdk-kotlin' - repository: 'awslabs/aws-sdk-kotlin' - - name: Configure JDK - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: 17 - cache: 'gradle' - - name: Build and Test aws-sdk-kotlin downstream - run: | - # TODO - JVM only - cd $GITHUB_WORKSPACE/smithy-kotlin - ./gradlew --parallel publishToMavenLocal - SMITHY_KOTLIN_RUNTIME_VERSION=$(grep sdkVersion= gradle.properties | cut -d = -f 2) - SMITHY_KOTLIN_CODEGEN_VERSION=$(grep codegenVersion= gradle.properties | cut -d = -f 2) - cd $GITHUB_WORKSPACE/aws-sdk-kotlin - # replace smithy-kotlin-runtime-version and smithy-kotlin-codegen-version to be - # whatever we are testing such that the protocol test projects don't fail with a - # version that doesn't exist locally or in maven central. Otherwise the generated - # protocol test projects will use whatever the SDK thinks the version of - # smithy-kotlin should be - sed -i "s/smithy-kotlin-runtime-version = .*$/smithy-kotlin-runtime-version = \"$SMITHY_KOTLIN_RUNTIME_VERSION\"/" gradle/libs.versions.toml - sed -i "s/smithy-kotlin-codegen-version = .*$/smithy-kotlin-codegen-version = \"$SMITHY_KOTLIN_CODEGEN_VERSION\"/" gradle/libs.versions.toml - ./gradlew --parallel publishToMavenLocal - ./gradlew test jvmTest - ./gradlew testAllProtocols \ No newline at end of file diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml deleted file mode 100644 index 69fb0c988..000000000 --- a/.github/workflows/dependabot.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Dependabot Dependency Submission - -on: - push: - branches: [ main ] - -permissions: - contents: write - -jobs: - dependency-submission: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Generate and submit dependency graph - uses: gradle/actions/dependency-submission@v3