read-size.yml 1.6 KB

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