read-size.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. name: Read size
  2. on:
  3. pull_request:
  4. paths:
  5. - 'src/**'
  6. - 'package.json'
  7. - 'utils/build/**'
  8. # This workflow runs in a read-only environment. We can safely checkout
  9. # the PR code here.
  10. # Reference:
  11. # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
  12. permissions:
  13. contents: read
  14. jobs:
  15. read-size:
  16. name: Tree-shaking
  17. runs-on: ubuntu-latest
  18. steps:
  19. - name: Git checkout
  20. uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
  21. - name: Install Node
  22. uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
  23. with:
  24. node-version: 18
  25. cache: 'npm'
  26. - name: Install dependencies
  27. run: npm ci
  28. - name: Build
  29. run: npm run build
  30. - name: === Test tree-shaking ===
  31. run: npm run test-treeshake
  32. - name: Read bundle sizes
  33. id: read-size
  34. run: |
  35. FILESIZE=$(stat --format=%s build/three.module.min.js)
  36. gzip -k build/three.module.min.js
  37. FILESIZE_GZIP=$(stat --format=%s build/three.module.min.js.gz)
  38. TREESHAKEN=$(stat --format=%s test/treeshake/index.bundle.min.js)
  39. gzip -k test/treeshake/index.bundle.min.js
  40. TREESHAKEN_GZIP=$(stat --format=%s test/treeshake/index.bundle.min.js.gz)
  41. PR=${{ github.event.pull_request.number }}
  42. # write the output in a json file to upload it as artifact
  43. node -pe "JSON.stringify({ filesize: $FILESIZE, gzip: $FILESIZE_GZIP, treeshaken: $TREESHAKEN, treeshakenGzip: $TREESHAKEN_GZIP, pr: $PR })" > sizes.json
  44. - name: Upload artifact
  45. uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
  46. with:
  47. name: sizes
  48. path: sizes.json