diff --git a/.github/workflows/artifact-size-metrics.yml b/.github/workflows/artifact-size-metrics.yml new file mode 100644 index 00000000..1d266208 --- /dev/null +++ b/.github/workflows/artifact-size-metrics.yml @@ -0,0 +1,106 @@ +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: ./gradlew saveArtifactSizeMetrics + - 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 + + const mutations = comments + .filter(comment => comment.author.login == 'github-actions' && !comment.isMinimized && comment.body.startsWith('Affected Artifacts')) + .map(comment => + github.graphql( + `mutation { + minimizeComment(input:{subjectId:"${comment.id}", classifier:OUTDATED}){ + clientMutationId + } + }` + ) + ) + await Promise.all(mutations) + + 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 + 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 + } diff --git a/.github/workflows/changelog-verification.yml b/.github/workflows/changelog-verification.yml deleted file mode 100644 index 547b155a..00000000 --- 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/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index dfd3da2b..00000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: CI - -on: - push: - branches: - - '*' - - '!main' - -env: - BUILDER_VERSION: v0.8.22 - BUILDER_SOURCE: releases - BUILDER_HOST: https://d19elf31gohf1l.cloudfront.net - PACKAGE_NAME: aws-crt-kotlin - RUN: ${{ github.run_id }}-${{ github.run_number }} - -jobs: - linux-compat: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Build and Test ${{ env.PACKAGE_NAME }} - run: | - python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - chmod a+x builder.pyz - echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties - ./builder.pyz build -p ${{ env.PACKAGE_NAME }} - - macos-compat: - runs-on: macos-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Build and Test ${{ env.PACKAGE_NAME }} - run: | - python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - chmod a+x builder.pyz - echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties - ./builder.pyz build -p ${{ env.PACKAGE_NAME }} - - windows-compat: - runs-on: windows-latest - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Build and Test ${{ env.PACKAGE_NAME }} - run: | - python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')" - python3 builder.pyz build -p ${{ env.PACKAGE_NAME }} diff --git a/README.md b/README.md index 803ecfb4..34d14235 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## AWS CRT Kotlin +## AWS CRT Kotlin! Kotlin bindings to the AWS Common Runtime diff --git a/build.gradle.kts b/build.gradle.kts index 942fea26..19a19355 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,6 +18,13 @@ plugins { id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" alias(libs.plugins.kotlin.multiplatform) apply false alias(libs.plugins.aws.kotlin.repo.tools.kmp) + id("artifact-size-metrics") version "0.4.2" +} + +artifactSizeMetrics { + artifactPrefixes = setOf(":aws-crt-kotlin") + significantChangeThresholdPercentage = 5.0 + projectRepositoryName = "aws-crt-kotlin" } allprojects { diff --git a/settings.gradle.kts b/settings.gradle.kts index 4cf4beae..0594bef9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,9 +9,6 @@ pluginManagement { maven { name = "kotlinRepoTools" url = java.net.URI("https://d2gys1nrxnjnyg.cloudfront.net/releases") - content { - includeGroupByRegex("""aws\.sdk\.kotlin.*""") - } } } }