chore: Package size reports. #377
Workflow file for this run
This file contains hidden or 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: sdk/browser | |
| on: | |
| push: | |
| branches: [main, 'feat/**'] | |
| paths-ignore: | |
| - '**.md' #Do not need to run CI for markdown changes. | |
| pull_request: | |
| branches: [main, 'feat/**'] | |
| paths-ignore: | |
| - '**.md' | |
| jobs: | |
| build-test-browser: | |
| permissions: | |
| pull-requests: write | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| # Node versions to run on. | |
| version: [18, 21] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.version }} | |
| registry-url: 'https://registry.npmjs.org' | |
| - id: shared | |
| name: Shared CI Steps | |
| uses: ./actions/ci | |
| with: | |
| workspace_name: '@launchdarkly/js-client-sdk' | |
| workspace_path: packages/sdk/browser | |
| - name: Install Brotli | |
| if: github.event_name == 'pull_request' | |
| run: sudo apt-get update && sudo apt-get install brotli | |
| - name: Get package size | |
| if: github.event_name == 'pull_request' && matrix.version == '21' | |
| env: | |
| PR_NUMBER: ${{ github.event.number }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| brotli packages/sdk/browser/dist/index.js | |
| export PACK_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br) | |
| echo "PACK_SIZE=$PACK_SIZE" >> $GITHUB_ENV | |
| - name: Find Size Comment | |
| if: github.event_name == 'pull_request' && matrix.version == '21' | |
| uses: peter-evans/find-comment@v3 | |
| id: fc | |
| with: | |
| issue-number: ${{ github.event.number }} | |
| comment-author: 'github-actions[bot]' | |
| body-includes: '@launchdarkly/js-client-sdk size report' | |
| - name: Create comment | |
| if: steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && matrix.version == '21' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| issue-number: ${{ github.event.number }} | |
| body: | | |
| @launchdarkly/js-client-sdk size report | |
| This is the brotli compressed size of the ESM build. | |
| Size: ${{ env.PACK_SIZE }} bytes | |
| - name: Update comment | |
| if: steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request' && matrix.version == '21' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| comment-id: ${{ steps.fc.outputs.comment-id }} | |
| body: | | |
| @launchdarkly/js-client-sdk size report | |
| This is the brotli compressed size of the ESM build. | |
| Size: ${{ env.PACK_SIZE }} bytes | |
| - name: Check package size limit | |
| if: github.event_name == 'pull_request' && matrix.version == '21' | |
| run: | | |
| [ $PACK_SIZE -le 25000 ] || exit 1 |