Skip to content

Commit

Permalink
update sdk sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
andremion committed Dec 20, 2024
1 parent 881603a commit cc5ea2c
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 20 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/sdk-size-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:

env:
SDKS: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose"
MODULES: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose"
MAX_TOLERANCE: 500
FINE_TOLERANCE: 250

Expand All @@ -20,6 +20,13 @@ jobs:
with:
key-prefix: gradle-build

- name: Assemble SDKs
run: |
for module in $MODULES; do
modules+=" :$module:assembleDebug"
done
./gradlew $modules
- name: Get develop SDK sizes
run: |
# Reads the develop SDK sizes from JSON file
Expand All @@ -28,22 +35,15 @@ jobs:
DEVELOP_SDK_SIZES=$(jq -c .debug stream-chat-android.json)
echo "DEVELOP_SDK_SIZES=$DEVELOP_SDK_SIZES" >> $GITHUB_ENV
- name: Assemble SDKs
run: |
for sdk in $SDKS; do
modules+=" :$sdk:assembleDebug"
done
./gradlew $modules
- name: Calculate PR branch SDK sizes
run: |
echo '{}' > pr_sdk_sizes.json
# Calculate sizes from the .aar files and save them into a temporary JSON file
# so it can be exported for the next job step
for sdk in $SDKS; do
size=$(du -k $sdk/build/outputs/aar/*.aar | awk '{print $1}')
jq -c --arg sdk "$sdk" --arg size "$size" '. + {($sdk): ($size | tonumber)}' pr_sdk_sizes.json > temp.json && mv temp.json pr_sdk_sizes.json
for module in $MODULES; do
size=$(du -k $module/build/outputs/aar/*.aar | awk '{print $1}')
jq -c --arg sdk "$module" --arg size "$size" '. + {($sdk): ($size | tonumber)}' pr_sdk_sizes.json > temp.json && mv temp.json pr_sdk_sizes.json
done
echo "PR_SDK_SIZES=$(cat pr_sdk_sizes.json)" >> $GITHUB_ENV
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/update-sdk-sizes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Update SDK sizes

on:
pull_request:

workflow_dispatch:

env:
MODULES: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose"
VARIANTS: "debug release"
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
update-sdk-sizes:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: ./.github/actions/setup-java
- uses: ./.github/actions/gradle-cache
with:
key-prefix: gradle-build

- name: Assemble SDKs
run: |
for module in $MODULES; do
modules+=" :$module:assemble"
done
./gradlew $modules
- name: Update SDK sizes
run: |
echo '{}' > stream-chat-android.json
# Calculate sizes
for module in $MODULES; do
for variant in $VARIANTS; do
file="$module/build/outputs/aar/$module-$variant.aar"
# Ensure file exists
if [ -f "$file" ]; then
size=$(du -k "$file" | awk '{print $1}')
else
echo "Warning: $file not found. Setting size to 0."
size=0
fi
# Update JSON
jq --arg module "$module" --arg variant "$variant" --argjson size "$size" \
".\"$variant\".\"$module\" = $size" stream-chat-android.json > temp.json && mv temp.json stream-chat-android.json
done
done
- name: Validate Generated JSON
run: jq . stream-chat-android.json

- name: Commit and Push JSON
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch origin
git checkout $BRANCH_NAME
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Add and commit updated JSON file
git add stream-chat-android.json
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "Update SDK sizes JSON"
git push origin HEAD:$BRANCH_NAME
fi
- name: Update size badges
run: |
# Update README.md
for module in $MODULES; do
size=$(jq --arg module "$module" ".release.\"$module\"" stream-chat-android.json)
badgeUrl="https://img.shields.io/badge/${module//-/--}-$size%20KB-lightgreen"
sed -i "s|!\[$module\](.*)|![$module](${badgeUrl})|" README.md
done
- name: Commit and Push README
run: |
# Add and commit updated README file
git add README.md
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "Update SDK size badges"
git push origin HEAD:$BRANCH_NAME
fi
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
<a href="https://github.com/GetStream/stream-chat-android/releases"><img src="https://img.shields.io/github/v/release/GetStream/stream-chat-android" /></a>
</p>

<div align="center">

![stream-chat-android-client](https://img.shields.io/badge/stream--chat--android--client-2584%20KB-lightgreen)
![stream-chat-android-offline](https://img.shields.io/badge/stream--chat--android--offline-796%20KB-lightgreen)
![stream-chat-android-ui-components](https://img.shields.io/badge/stream--chat--android--ui--components-2700%20KB-lightgreen)
![stream-chat-android-compose](https://img.shields.io/badge/stream--chat--android--compose-3684%20KB-lightgreen)

</div>

This is the official Android SDK for [Stream Chat](https://getstream.io/chat/sdk/android/), a service for building chat and messaging applications. This library includes both a low-level chat SDK and a set of reusable UI components. Most users start with the UI components, and fall back to the lower level API when they want to customize things.

We're proud to say that we're the first Android Chat SDK that supports Jetpack Compose! We [released](https://github.com/GetStream/stream-chat-android/releases/tag/4.15.0) our Compose UI Components one day after the official Jetpack Compose 1.0 release and our team members have been working hard on it since then.
Expand Down
18 changes: 9 additions & 9 deletions stream-chat-android.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"debug": {
"stream-chat-android-client": 2400,
"stream-chat-android-offline": 740,
"stream-chat-android-ui-components": 2000,
"stream-chat-android-compose": 5000
"stream-chat-android-client": 2744,
"stream-chat-android-offline": 840,
"stream-chat-android-ui-components": 2840,
"stream-chat-android-compose": 4012
},
"release": {
"stream-chat-android-client": 2400,
"stream-chat-android-offline": 740,
"stream-chat-android-ui-components": 2000,
"stream-chat-android-compose": 5000
"stream-chat-android-client": 2584,
"stream-chat-android-offline": 796,
"stream-chat-android-ui-components": 2700,
"stream-chat-android-compose": 3684
}
}
}

0 comments on commit cc5ea2c

Please sign in to comment.