| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- name: Read size
- on:
- pull_request:
- paths:
- - 'src/**'
- - 'package.json'
- - 'utils/build/**'
- # This workflow runs in a read-only environment. We can safely checkout
- # the PR code here.
- # Reference:
- # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- permissions:
- contents: read
- jobs:
- read-size:
- name: Tree-shaking
- runs-on: ubuntu-latest
- steps:
- - name: Git checkout
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- - name: Install Node
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
- with:
- node-version: 18
- cache: 'npm'
- - name: Install dependencies
- run: npm ci
- - name: Build
- run: npm run build
- - name: === Test tree-shaking ===
- run: npm run test-treeshake
- - name: Read bundle sizes
- id: read-size
- run: |
- WEBGL_FILESIZE=$(stat --format=%s build/three.module.min.js)
- gzip -k build/three.module.min.js
- WEBGL_FILESIZE_GZIP=$(stat --format=%s build/three.module.min.js.gz)
- WEBGL_TREESHAKEN=$(stat --format=%s test/treeshake/index.bundle.min.js)
- gzip -k test/treeshake/index.bundle.min.js
- WEBGL_TREESHAKEN_GZIP=$(stat --format=%s test/treeshake/index.bundle.min.js.gz)
- WEBGPU_FILESIZE=$(stat --format=%s build/three.webgpu.min.js)
- gzip -k build/three.webgpu.min.js
- WEBGPU_FILESIZE_GZIP=$(stat --format=%s build/three.webgpu.min.js.gz)
- WEBGPU_TREESHAKEN=$(stat --format=%s test/treeshake/index.webgpu.bundle.min.js)
- gzip -k test/treeshake/index.webgpu.bundle.min.js
- WEBGPU_TREESHAKEN_GZIP=$(stat --format=%s test/treeshake/index.webgpu.bundle.min.js.gz)
- PR=${{ github.event.pull_request.number }}
- # write the output in a json file to upload it as artifact
- node -pe "JSON.stringify({ filesize: $WEBGL_FILESIZE, gzip: $WEBGL_FILESIZE_GZIP, treeshaken: $WEBGL_TREESHAKEN, treeshakenGzip: $WEBGL_TREESHAKEN_GZIP, filesize2: $WEBGPU_FILESIZE, gzip2: $WEBGPU_FILESIZE_GZIP, treeshaken2: $WEBGPU_TREESHAKEN, treeshakenGzip2: $WEBGPU_TREESHAKEN_GZIP, pr: $PR })" > sizes.json
- - name: Upload artifact
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
- with:
- name: sizes
- path: sizes.json
|