Skip to content

Commit

Permalink
move metrics file
Browse files Browse the repository at this point in the history
  • Loading branch information
andremion committed Dec 23, 2024
1 parent cc5ea2c commit fc0e3f6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 34 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/sdk-size-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

env:
MODULES: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose"
METRICS_FILE: "metrics/size.json"
MAX_TOLERANCE: 500
FINE_TOLERANCE: 250

Expand All @@ -29,10 +30,10 @@ jobs:
- name: Get develop SDK sizes
run: |
# Reads the develop SDK sizes from JSON file
# Reads develop SDK sizes from the metrics file
# and define to a variable using a compact JSON format
# so it can be exported for the next job step
DEVELOP_SDK_SIZES=$(jq -c .debug stream-chat-android.json)
DEVELOP_SDK_SIZES=$(jq -c .debug $METRICS_FILE)
echo "DEVELOP_SDK_SIZES=$DEVELOP_SDK_SIZES" >> $GITHUB_ENV
- name: Calculate PR branch SDK sizes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update SDK sizes
name: SDK sizes updates

on:
pull_request:
Expand All @@ -8,6 +8,7 @@ on:
env:
MODULES: "stream-chat-android-client stream-chat-android-offline stream-chat-android-ui-components stream-chat-android-compose"
VARIANTS: "debug release"
METRICS_FILE: "metrics/size.json"
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
Expand All @@ -29,9 +30,9 @@ jobs:
done
./gradlew $modules
- name: Update SDK sizes
- name: Update size metrics
run: |
echo '{}' > stream-chat-android.json
echo '{}' > temp.json
# Calculate sizes
for module in $MODULES; do
Expand All @@ -48,51 +49,42 @@ jobs:
# 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
".\"$variant\".\"$module\" = $size" temp.json > temp.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
# Validate Generated JSON
jq . temp.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
# Move JSON to the metrics file
mv temp.json $METRICS_FILE
- name: Update size badges
run: |
# Update README.md
for module in $MODULES; do
size=$(jq --arg module "$module" ".release.\"$module\"" stream-chat-android.json)
size=$(jq --arg module "$module" ".release.\"$module\"" $METRICS_FILE)
badgeUrl="https://img.shields.io/badge/${module//-/--}-$size%20KB-lightgreen"
sed -i "s|!\[$module\](.*)|![$module](${badgeUrl})|" README.md
done
- name: Commit and Push README
- name: Commit and Push JSON
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 metrics file
git add $METRICS_FILE
git commit -m "Update SDK size metrics"
# Add and commit updated README file
git add README.md
git commit -m "Update SDK size badges"
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
echo "No changes to push"
else
git commit -m "Update SDK size badges"
git push origin HEAD:$BRANCH_NAME
fi
File renamed without changes.

0 comments on commit fc0e3f6

Please sign in to comment.