From da51957ab8dcdda5c3516ec75fbf39608408a19f Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:08:21 -0700 Subject: [PATCH 01/20] chore: Package size reports. --- .github/workflows/browser.yml | 12 ++++++++++++ packages/sdk/browser/package.json | 2 ++ packages/shared/sdk-client/package.json | 1 + 3 files changed, 15 insertions(+) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index da12b51e5..c63e196ee 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -31,3 +31,15 @@ jobs: with: workspace_name: '@launchdarkly/js-client-sdk' workspace_path: packages/sdk/browser + - name: Install Brotli + if: github.event_name == 'pull_request' + run: apt-get update && apt-install brotli + - name: Check Package Size + if: github.event_name == 'pull_request' + env: + PR_NUMBER: ${{ github.event.number }} + run: | + brotli packages/sdk/browser/dist/index.js + export PR_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br) + gh pr comment $PR_NUMBER -b "`@launchdarkly/js-client-sdk` size: $PR_SIZE" + [ $PR_SIZE -le 25000 ] || exit 1 diff --git a/packages/sdk/browser/package.json b/packages/sdk/browser/package.json index 8f66ed8d7..67ddba615 100644 --- a/packages/sdk/browser/package.json +++ b/packages/sdk/browser/package.json @@ -48,6 +48,7 @@ "scripts": { "clean": "rimraf dist", "build": "tsup", + "build-with-deps": "yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/js-client-sdk' run build", "lint": "eslint . --ext .ts,.tsx", "prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore", "test": "npx jest --runInBand", @@ -59,6 +60,7 @@ }, "devDependencies": { "@jest/globals": "^29.7.0", + "@size-limit/preset-big-lib": "^11.1.6", "@trivago/prettier-plugin-sort-imports": "^4.1.1", "@types/jest": "^29.5.11", "@typescript-eslint/eslint-plugin": "^6.20.0", diff --git a/packages/shared/sdk-client/package.json b/packages/shared/sdk-client/package.json index 28f75f9f0..8f909eba3 100644 --- a/packages/shared/sdk-client/package.json +++ b/packages/shared/sdk-client/package.json @@ -35,6 +35,7 @@ "make-esm-package-json": "echo '{\"type\":\"module\"}' > dist/esm/package.json", "make-package-jsons": "npm run make-cjs-package-json && npm run make-esm-package-json", "build": "npx tsc --noEmit && rollup -c rollup.config.js && npm run make-package-jsons", + "build-with-deps": "yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/js-client-sdk-common' run build", "clean": "rimraf dist", "lint": "npx eslint . --ext .ts", "lint:fix": "yarn run lint -- --fix", From 163b78e0bc4ae69c5cea484fcb5617b067752859 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:01:40 -0700 Subject: [PATCH 02/20] Use sudo. --- .github/workflows/browser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index c63e196ee..36e147a06 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -33,7 +33,7 @@ jobs: workspace_path: packages/sdk/browser - name: Install Brotli if: github.event_name == 'pull_request' - run: apt-get update && apt-install brotli + run: sudo apt-get update && sudo apt-install brotli - name: Check Package Size if: github.event_name == 'pull_request' env: From 2374d52267a1c09fc9a09e11a4d66a181875a234 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:04:37 -0700 Subject: [PATCH 03/20] Use the correct command. --- .github/workflows/browser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 36e147a06..06099f758 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -33,7 +33,7 @@ jobs: workspace_path: packages/sdk/browser - name: Install Brotli if: github.event_name == 'pull_request' - run: sudo apt-get update && sudo apt-install brotli + run: sudo apt-get update && sudo apt-get install brotli - name: Check Package Size if: github.event_name == 'pull_request' env: From 218b00aab74fee25d81b0549db0008b5ac5abd6e Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:09:07 -0700 Subject: [PATCH 04/20] Permissions and token for adding a comment to the PR. --- .github/workflows/browser.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 06099f758..2f88c5aa3 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -12,6 +12,8 @@ on: jobs: build-test-browser: + permissions: + pull-requests: write runs-on: ubuntu-latest strategy: @@ -38,6 +40,7 @@ jobs: if: github.event_name == 'pull_request' env: PR_NUMBER: ${{ github.event.number }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | brotli packages/sdk/browser/dist/index.js export PR_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br) From 3fa30fe92a1f8f95227124a3524005e0e25b36bb Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:21:21 -0700 Subject: [PATCH 05/20] Try edit last. --- .github/workflows/browser.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 2f88c5aa3..dfcee73cc 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -37,12 +37,12 @@ jobs: if: github.event_name == 'pull_request' run: sudo apt-get update && sudo apt-get install brotli - name: Check Package Size - if: github.event_name == 'pull_request' + 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 PR_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br) - gh pr comment $PR_NUMBER -b "`@launchdarkly/js-client-sdk` size: $PR_SIZE" + gh pr comment --edit-last $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE" [ $PR_SIZE -le 25000 ] || exit 1 From d9d2fbe9b00332524243fc71a20d7e59606534eb Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:25:35 -0700 Subject: [PATCH 06/20] Try to edit comment, and if it cannot be edited, then create it. --- .github/workflows/browser.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index dfcee73cc..436fa9f4b 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -44,5 +44,5 @@ jobs: run: | brotli packages/sdk/browser/dist/index.js export PR_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br) - gh pr comment --edit-last $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE" + gh pr comment --edit-last $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE" || gh pr comment $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE" [ $PR_SIZE -le 25000 ] || exit 1 From 3f01ae518cdb39116f337d12dc42fbee3b48e846 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:28:24 -0700 Subject: [PATCH 07/20] Remove unused commands. --- packages/sdk/browser/package.json | 1 - packages/shared/sdk-client/package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/sdk/browser/package.json b/packages/sdk/browser/package.json index 67ddba615..c620a2d7a 100644 --- a/packages/sdk/browser/package.json +++ b/packages/sdk/browser/package.json @@ -48,7 +48,6 @@ "scripts": { "clean": "rimraf dist", "build": "tsup", - "build-with-deps": "yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/js-client-sdk' run build", "lint": "eslint . --ext .ts,.tsx", "prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore", "test": "npx jest --runInBand", diff --git a/packages/shared/sdk-client/package.json b/packages/shared/sdk-client/package.json index 8f909eba3..28f75f9f0 100644 --- a/packages/shared/sdk-client/package.json +++ b/packages/shared/sdk-client/package.json @@ -35,7 +35,6 @@ "make-esm-package-json": "echo '{\"type\":\"module\"}' > dist/esm/package.json", "make-package-jsons": "npm run make-cjs-package-json && npm run make-esm-package-json", "build": "npx tsc --noEmit && rollup -c rollup.config.js && npm run make-package-jsons", - "build-with-deps": "yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/js-client-sdk-common' run build", "clean": "rimraf dist", "lint": "npx eslint . --ext .ts", "lint:fix": "yarn run lint -- --fix", From a7c3bad26e94c974ba67b42d7a040eaf0f9d0a98 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:28:53 -0700 Subject: [PATCH 08/20] Remove size-limit package. --- packages/sdk/browser/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sdk/browser/package.json b/packages/sdk/browser/package.json index c620a2d7a..8f66ed8d7 100644 --- a/packages/sdk/browser/package.json +++ b/packages/sdk/browser/package.json @@ -59,7 +59,6 @@ }, "devDependencies": { "@jest/globals": "^29.7.0", - "@size-limit/preset-big-lib": "^11.1.6", "@trivago/prettier-plugin-sort-imports": "^4.1.1", "@types/jest": "^29.5.11", "@typescript-eslint/eslint-plugin": "^6.20.0", From 853a99237b607b6516f55dfbd424bdf1844d1fbc Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:33:44 -0700 Subject: [PATCH 09/20] Revise comment handling. --- .github/workflows/browser.yml | 37 +++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 436fa9f4b..b8f3965a1 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -36,13 +36,42 @@ jobs: - name: Install Brotli if: github.event_name == 'pull_request' run: sudo apt-get update && sudo apt-get install brotli - - name: Check Package Size + - 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 PR_SIZE=$(stat -c %s packages/sdk/browser/dist/index.js.br) - gh pr comment --edit-last $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE" || gh pr comment $PR_NUMBER -b "@launchdarkly/js-client-sdk: $PR_SIZE" - [ $PR_SIZE -le 25000 ] || exit 1 + 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: + 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: + body: | + @launchdarkly/js-client-sdk size report + 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 + 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 From bd1cc84f126fc9e9dafa83d54e9307243b11e189 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:07:07 -0700 Subject: [PATCH 10/20] Add issue number. --- .github/workflows/browser.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index b8f3965a1..9305a7948 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -51,6 +51,7 @@ jobs: uses: peter-evans/find-comment@v3 id: fc with: + issue-numer: ${{ github.event.number }} comment-author: 'github-actions[bot]' body-includes: '@launchdarkly/js-client-sdk size report' @@ -58,6 +59,7 @@ jobs: if: steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && matrix.version == '21' uses: peter-evans/create-or-update-comment@v4 with: + issue-numer: ${{ github.event.number }} body: | @launchdarkly/js-client-sdk size report Size: ${{ env.PACK_SIZE }} bytes From 87807056236b5e238c0cd99c6bc08835e4b05461 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:09:23 -0700 Subject: [PATCH 11/20] Fix typo --- .github/workflows/browser.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 9305a7948..e53b89331 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -51,7 +51,7 @@ jobs: uses: peter-evans/find-comment@v3 id: fc with: - issue-numer: ${{ github.event.number }} + issue-number: ${{ github.event.number }} comment-author: 'github-actions[bot]' body-includes: '@launchdarkly/js-client-sdk size report' @@ -59,7 +59,7 @@ jobs: if: steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && matrix.version == '21' uses: peter-evans/create-or-update-comment@v4 with: - issue-numer: ${{ github.event.number }} + issue-number: ${{ github.event.number }} body: | @launchdarkly/js-client-sdk size report Size: ${{ env.PACK_SIZE }} bytes From c1a8947a2c7c8d6b41db420a440cfc77d673aaa0 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:12:03 -0700 Subject: [PATCH 12/20] Refine comment and test updates. --- .github/workflows/browser.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index e53b89331..826ef8f29 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -62,6 +62,7 @@ jobs: 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 @@ -71,6 +72,7 @@ jobs: 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 From 521e39306dc4391a94f2323c9118a1e0c3bba457 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:15:58 -0700 Subject: [PATCH 13/20] Pin SHA and replace comment. --- .github/workflows/browser.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 826ef8f29..8600c56b9 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -48,7 +48,7 @@ jobs: - name: Find Size Comment if: github.event_name == 'pull_request' && matrix.version == '21' - uses: peter-evans/find-comment@v3 + uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e id: fc with: issue-number: ${{ github.event.number }} @@ -57,7 +57,7 @@ jobs: - 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 + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 with: issue-number: ${{ github.event.number }} body: | @@ -67,9 +67,10 @@ jobs: - 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 + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 with: comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace body: | @launchdarkly/js-client-sdk size report This is the brotli compressed size of the ESM build. From 31141b5c622c9d7228d05e780838dc7405ab9935 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:34:01 -0700 Subject: [PATCH 14/20] Move package-size to a shared action. --- .github/workflows/browser.yml | 51 ++++---------------------- actions/package-size/action.yml | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 actions/package-size/action.yml diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 8600c56b9..5b8f6d132 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -33,50 +33,11 @@ jobs: 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 + - name: Check 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@3eae4d37986fb5a8592848f6a574fdf654e61f9e - 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@71345be0265236311c031f5c7866368bd1eff043 + uses: ./actions/package-size 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@71345be0265236311c031f5c7866368bd1eff043 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - edit-mode: replace - 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 + github_token: ${{ secrets.GITHUB_TOKEN }} + target_file: 'packages/sdk/browser/dist/index.js' + package_name: '@launchdarkly/js-client-sdk' + pr_numer: ${{ github.event.number }} diff --git a/actions/package-size/action.yml b/actions/package-size/action.yml new file mode 100644 index 000000000..88d61adac --- /dev/null +++ b/actions/package-size/action.yml @@ -0,0 +1,63 @@ +name: Package Size Action +description: Checks that a compressed package is less than a certain size and also comments on the PR. +inputs: + github_token: + description: 'Github token with permission to write PR comments' + required: true + target_file: + description: 'Path to the JavaScript file to check' + required: true + package_name: + description: 'The name of the package' + required: true + pr_numer: + description: 'Th PR number' + required: true +runs: + using: composite + steps: + - name: Install Brotli + shell: bash + if: github.event_name == 'pull_request' + run: sudo apt-get update && sudo apt-get install brotli + - name: Get package size + shell: bash + run: | + brotli ${{ inputs.target_file }} + export PACK_SIZE=$(stat -c %s ${{ inputs.target_file }}.br) + echo "PACK_SIZE=$PACK_SIZE" >> $GITHUB_ENV + + - name: Find Size Comment + uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e + id: fc + with: + issue-number: ${{ inputs.pr_number }} + comment-author: 'github-actions[bot]' + body-includes: '${{ inputs.package_name }} 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@71345be0265236311c031f5c7866368bd1eff043 + with: + issue-number: ${{ inputs.pr_number }} + body: | + ${{ inputs.package_name }} 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@71345be0265236311c031f5c7866368bd1eff043 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace + body: | + ${{ inputs.package_name }} report + This is the brotli compressed size of the ESM build. + Size: ${{ env.PACK_SIZE }} bytes + + - name: Check package size limit + shell: bash + if: github.event_name == 'pull_request' && matrix.version == '21' + run: | + [ $PACK_SIZE -le 25000 ] || exit 1 From 6c103a4a48434beaea85667858e6e80bcbe62833 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:46:32 -0700 Subject: [PATCH 15/20] typo --- .github/workflows/browser.yml | 2 +- actions/package-size/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 5b8f6d132..d680e33ac 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -40,4 +40,4 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} target_file: 'packages/sdk/browser/dist/index.js' package_name: '@launchdarkly/js-client-sdk' - pr_numer: ${{ github.event.number }} + pr_number: ${{ github.event.number }} diff --git a/actions/package-size/action.yml b/actions/package-size/action.yml index 88d61adac..18bf83e46 100644 --- a/actions/package-size/action.yml +++ b/actions/package-size/action.yml @@ -10,7 +10,7 @@ inputs: package_name: description: 'The name of the package' required: true - pr_numer: + pr_number: description: 'Th PR number' required: true runs: From ba1f3330c12dc68b824cf6442047db51813ea3f7 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:52:59 -0700 Subject: [PATCH 16/20] Add to common and sdk-client. --- .github/workflows/common.yml | 8 ++++++++ .github/workflows/sdk-client.yml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index f2dc03e64..1e0f6f582 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -25,3 +25,11 @@ jobs: with: workspace_name: '@launchdarkly/js-sdk-common' workspace_path: packages/shared/common + - name: Check package size + if: github.event_name == 'pull_request' && matrix.version == '21' + uses: ./actions/package-size + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + target_file: 'packages/shared/common/dist/esm/index.mjs' + package_name: '@launchdarkly/js-sdk-common' + pr_number: ${{ github.event.number }} diff --git a/.github/workflows/sdk-client.yml b/.github/workflows/sdk-client.yml index 9ac1c9ebe..f18821529 100644 --- a/.github/workflows/sdk-client.yml +++ b/.github/workflows/sdk-client.yml @@ -22,3 +22,11 @@ jobs: with: workspace_name: '@launchdarkly/js-client-sdk-common' workspace_path: packages/shared/sdk-client + - name: Check package size + if: github.event_name == 'pull_request' && matrix.version == '21' + uses: ./actions/package-size + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + target_file: 'packages/shared/sdk-client/dist/esm/index.mjs' + package_name: '@launchdarkly/js-client-sdk-common' + pr_number: ${{ github.event.number }} From dc3af048364017a61f932403cd937ad16705f6c1 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:55:12 -0700 Subject: [PATCH 17/20] Fix string to compare and message. --- actions/package-size/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/package-size/action.yml b/actions/package-size/action.yml index 18bf83e46..c23269f1f 100644 --- a/actions/package-size/action.yml +++ b/actions/package-size/action.yml @@ -33,7 +33,7 @@ runs: with: issue-number: ${{ inputs.pr_number }} comment-author: 'github-actions[bot]' - body-includes: '${{ inputs.package_name }} report' + body-includes: '${{ inputs.package_name }} size report' - name: Create comment if: steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && matrix.version == '21' @@ -41,7 +41,7 @@ runs: with: issue-number: ${{ inputs.pr_number }} body: | - ${{ inputs.package_name }} report + ${{ inputs.package_name }} size report This is the brotli compressed size of the ESM build. Size: ${{ env.PACK_SIZE }} bytes @@ -52,7 +52,7 @@ runs: comment-id: ${{ steps.fc.outputs.comment-id }} edit-mode: replace body: | - ${{ inputs.package_name }} report + ${{ inputs.package_name }} size report This is the brotli compressed size of the ESM build. Size: ${{ env.PACK_SIZE }} bytes From f2fefa709ad44599b92ed9baf647c67c8276d858 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:58:09 -0700 Subject: [PATCH 18/20] Fix condition. --- .github/workflows/common.yml | 2 +- .github/workflows/sdk-client.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 1e0f6f582..27de974c0 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -26,7 +26,7 @@ jobs: workspace_name: '@launchdarkly/js-sdk-common' workspace_path: packages/shared/common - name: Check package size - if: github.event_name == 'pull_request' && matrix.version == '21' + if: github.event_name == 'pull_request' uses: ./actions/package-size with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sdk-client.yml b/.github/workflows/sdk-client.yml index f18821529..8dc250891 100644 --- a/.github/workflows/sdk-client.yml +++ b/.github/workflows/sdk-client.yml @@ -23,7 +23,7 @@ jobs: workspace_name: '@launchdarkly/js-client-sdk-common' workspace_path: packages/shared/sdk-client - name: Check package size - if: github.event_name == 'pull_request' && matrix.version == '21' + if: github.event_name == 'pull_request' uses: ./actions/package-size with: github_token: ${{ secrets.GITHUB_TOKEN }} From 77305798ab8269429d88592a3c630bef7c0a9040 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:10:03 -0700 Subject: [PATCH 19/20] Remove leftover action conditions. --- actions/package-size/action.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/actions/package-size/action.yml b/actions/package-size/action.yml index c23269f1f..3ad6e6eaa 100644 --- a/actions/package-size/action.yml +++ b/actions/package-size/action.yml @@ -36,7 +36,7 @@ runs: body-includes: '${{ inputs.package_name }} size report' - name: Create comment - if: steps.fc.outputs.comment-id == '' && github.event_name == 'pull_request' && matrix.version == '21' + if: steps.fc.outputs.comment-id == '' uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 with: issue-number: ${{ inputs.pr_number }} @@ -46,7 +46,7 @@ runs: Size: ${{ env.PACK_SIZE }} bytes - name: Update comment - if: steps.fc.outputs.comment-id != '' && github.event_name == 'pull_request' && matrix.version == '21' + if: steps.fc.outputs.comment-id != '' uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 with: comment-id: ${{ steps.fc.outputs.comment-id }} @@ -58,6 +58,5 @@ runs: - name: Check package size limit shell: bash - if: github.event_name == 'pull_request' && matrix.version == '21' run: | [ $PACK_SIZE -le 25000 ] || exit 1 From 8993970bf45f63a3fe86dc0936afe9ddce3f3776 Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:16:49 -0700 Subject: [PATCH 20/20] Add configurable size limit. --- .github/workflows/browser.yml | 1 + .github/workflows/common.yml | 1 + .github/workflows/sdk-client.yml | 1 + actions/package-size/action.yml | 9 +++++++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index d680e33ac..1442c4a56 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -41,3 +41,4 @@ jobs: target_file: 'packages/sdk/browser/dist/index.js' package_name: '@launchdarkly/js-client-sdk' pr_number: ${{ github.event.number }} + size_limit: 21000 diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 27de974c0..a64766e4c 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -33,3 +33,4 @@ jobs: target_file: 'packages/shared/common/dist/esm/index.mjs' package_name: '@launchdarkly/js-sdk-common' pr_number: ${{ github.event.number }} + size_limit: 21000 diff --git a/.github/workflows/sdk-client.yml b/.github/workflows/sdk-client.yml index 8dc250891..2c2fbaa7b 100644 --- a/.github/workflows/sdk-client.yml +++ b/.github/workflows/sdk-client.yml @@ -30,3 +30,4 @@ jobs: target_file: 'packages/shared/sdk-client/dist/esm/index.mjs' package_name: '@launchdarkly/js-client-sdk-common' pr_number: ${{ github.event.number }} + size_limit: 20000 diff --git a/actions/package-size/action.yml b/actions/package-size/action.yml index 3ad6e6eaa..4413259e9 100644 --- a/actions/package-size/action.yml +++ b/actions/package-size/action.yml @@ -11,7 +11,10 @@ inputs: description: 'The name of the package' required: true pr_number: - description: 'Th PR number' + description: 'The PR number' + required: true + size_limit: + description: 'The maximum size of the library' required: true runs: using: composite @@ -44,6 +47,7 @@ runs: ${{ inputs.package_name }} size report This is the brotli compressed size of the ESM build. Size: ${{ env.PACK_SIZE }} bytes + Size limit: ${{ inputs.size_limit }} - name: Update comment if: steps.fc.outputs.comment-id != '' @@ -55,8 +59,9 @@ runs: ${{ inputs.package_name }} size report This is the brotli compressed size of the ESM build. Size: ${{ env.PACK_SIZE }} bytes + Size limit: ${{ inputs.size_limit }} - name: Check package size limit shell: bash run: | - [ $PACK_SIZE -le 25000 ] || exit 1 + [ $PACK_SIZE -le ${{ inputs.size_limit }} ] || exit 1