Skip to content

Commit

Permalink
ci: size diff (#201)
Browse files Browse the repository at this point in the history
## 馃摐 Description

Added script for calculation `.pkg` difference between current changes
and changes in target branch.

## 馃挕 Motivation and Context

To keep a track on package size and to be sure that I don't write
changes which could significantly increase package size.

## 馃摙 Changelog

### CI
- added `size-diff.yml` file;
- send sticky message with a report about size changes;

## 馃 How Has This Been Tested?

Tested on CI 馃檪 

## 馃摳 Screenshots (if appropriate):

<img width="919" alt="image"
src="https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/70cd6237-fc4f-4c35-b8b8-f6aef4ffa00f">

## 馃摑 Checklist

- [x] CI successfully passed
  • Loading branch information
kirillzyusko committed Aug 10, 2023
1 parent 37e9d39 commit da04d8c
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/size-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 馃И Size diff

on:
pull_request:
paths:
- '.github/workflows/size-diff.yml'
- '!example/**'
- '!FabricExample/**'
- '!docs/**'
- '!scripts/**'

jobs:
check-diff:
name: 馃敩 Find npm package size diff
runs-on: ubuntu-latest
steps:
- name: Checkout to target branch
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Calculate size of package (target)
id: old-size
run: echo "OLD_SIZE=$(node scripts/size.js)" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Calculate size of package (current)
id: new-size
run: echo "NEW_SIZE=$(node scripts/size.js)" >> "$GITHUB_OUTPUT"
- name: Calculate difference
id: diff
env:
NEW_SIZE: ${{ steps.new-size.outputs.NEW_SIZE }}
OLD_SIZE: ${{ steps.old-size.outputs.OLD_SIZE }}
run: |
echo "DIFF=$((NEW_SIZE - OLD_SIZE))" >> "$GITHUB_OUTPUT"
echo "SIGN=$([ $((NEW_SIZE - OLD_SIZE)) -gt 0 ] && echo "馃搱" || echo "馃搲")" >> "$GITHUB_OUTPUT"
- uses: marocchino/sticky-pull-request-comment@v2
env:
NEW_SIZE: ${{ steps.new-size.outputs.NEW_SIZE }}
OLD_SIZE: ${{ steps.old-size.outputs.OLD_SIZE }}
DIFF: ${{ steps.diff.outputs.DIFF }}
SIGN: ${{ steps.diff.outputs.SIGN }}
with:
message: |
### 馃搳 Package size report
| Current size | Target Size | Difference |
| ------------- | ------------- | ------------------------ |
| ${{ env.NEW_SIZE }} bytes | ${{ env.OLD_SIZE }} bytes | ${{ env.DIFF }} bytes ${{ env.SIGN }} |

0 comments on commit da04d8c

Please sign in to comment.