chore: track artifact sizes #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Artifact Size Check | |
on: | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ published ] | |
permissions: | |
id-token: write | |
contents: read | |
pull-requests: write | |
concurrency: | |
group: ci-artifact-size-check-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
# BOOTSTRAP_SERVICES: +s3,+dynamodb,+sts,+polly | |
BOOTSTRAP_SERVICES: +s3 | |
jobs: | |
check-sizes: | |
if: ${{ github.event_name == 'pull_request' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
path: 'aws-sdk-kotlin' | |
- name: Setup Build | |
uses: ./aws-sdk-kotlin/.github/actions/setup-build | |
- name: Check artifact sizes | |
working-directory: ./aws-sdk-kotlin | |
shell: bash | |
run: | | |
./gradlew :codegen:sdk:bootstrap -Paws.services=${{ env.BOOTSTRAP_SERVICES }} | |
./gradlew artifactMetrics | |
- 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: Compare metrics | |
working-directory: ./aws-sdk-kotlin | |
shell: bash | |
run: | | |
./gradlew checkArtifactMetrics | |
- name: Publish PR comment | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('node:fs'); | |
const content = fs.readFileSync('./aws-sdk-kotlin/build/reports/metrics/artifact-summary.md', 'utf8'); | |
await github.rest.issues.createComment({ | |
issue_number: ${{ github.event.number }}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: content, | |
}); | |
publish-metrics: | |
if: ${{ github.event_name == 'release' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
path: 'aws-sdk-kotlin' | |
- name: Setup Build | |
uses: ./aws-sdk-kotlin/.github/actions/setup-build | |
- name: Check artifact sizes | |
working-directory: ./aws-sdk-kotlin | |
shell: bash | |
run: | | |
./gradlew :codegen:sdk:bootstrap -Paws.services=${{ env.BOOTSTRAP_SERVICES }} | |
./gradlew artifactMetrics | |
- 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: Publish new metrics | |
working-directory: ./aws-sdk-kotlin | |
shell: bash | |
run: | | |
aws --region us-west-2 cloudwatch put-metric-data --namespace "AwsSdkKotlin/ArtifactMetrics" --metric-data file://build/reports/metrics/artifacts.json |