[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

feat: add size-report CI workflow

Nate Moore (Jun 2, 2026, 8:58 PM -0500) 30fa63fd 4b5a8520

+118
+118
.github/workflows/size-report.yml
··· 1 + name: Size Report 2 + 3 + on: 4 + pull_request: 5 + 6 + permissions: 7 + contents: read 8 + pull-requests: write 9 + 10 + concurrency: 11 + group: ${{ github.workflow }}-${{ github.ref }} 12 + cancel-in-progress: true 13 + 14 + jobs: 15 + size-report: 16 + name: Size Report 17 + runs-on: ubuntu-latest 18 + 19 + steps: 20 + - name: checkout 21 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4 22 + with: 23 + submodules: true 24 + fetch-depth: 0 25 + persist-credentials: false 26 + 27 + - name: setup deno 28 + uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4 29 + with: 30 + deno-version: v2.x 31 + 32 + - name: setup node 33 + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v4 34 + with: 35 + node-version: 24 36 + 37 + - name: build (head) 38 + run: make && deno task build:npm 0.0.0 39 + 40 + - name: measure sizes (head) 41 + run: | 42 + cp tasks/measure-size.ts /tmp/measure-size.ts 43 + deno run --allow-read /tmp/measure-size.ts > /tmp/head-sizes.json 44 + 45 + - name: find merge base 46 + id: base 47 + run: | 48 + SHA=$(git merge-base HEAD origin/${{ github.base_ref }}) 49 + echo "sha=$SHA" >> $GITHUB_OUTPUT 50 + 51 + - name: checkout base commit 52 + run: | 53 + git checkout ${{ steps.base.outputs.sha }} 54 + git submodule update --init --recursive 55 + 56 + - name: build (base) 57 + run: make && deno task build:npm 0.0.0 58 + 59 + - name: measure sizes (base) 60 + run: deno run --allow-read /tmp/measure-size.ts > /tmp/base-sizes.json 61 + 62 + - name: post size report 63 + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 64 + with: 65 + script: | 66 + const fs = require('fs'); 67 + const head = JSON.parse(fs.readFileSync('/tmp/head-sizes.json', 'utf8')); 68 + const base = JSON.parse(fs.readFileSync('/tmp/base-sizes.json', 'utf8')); 69 + 70 + const total = (arr) => arr.reduce( 71 + (acc, f) => ({ raw: acc.raw + f.raw, gzip: acc.gzip + f.gzip }), 72 + { raw: 0, gzip: 0 } 73 + ); 74 + const headTotal = total(head); 75 + const baseTotal = total(base); 76 + 77 + const deltaRaw = headTotal.raw - baseTotal.raw; 78 + const deltaGzip = headTotal.gzip - baseTotal.gzip; 79 + 80 + const fmt = (n) => `${(n / 1024).toFixed(1)} KB`; 81 + const fmtDelta = (n) => 82 + n === 0 ? '±0 KB' : `${n > 0 ? '+' : ''}${(n / 1024).toFixed(1)} KB`; 83 + 84 + const takeaway = 85 + deltaGzip < 0 ? 'Size Reduced' : 86 + deltaGzip > 0 ? 'Size Increased' : 87 + 'No Change to Size'; 88 + 89 + const body = [ 90 + '<!-- size-report -->', 91 + `**${takeaway}** — ${fmtDelta(deltaGzip)} gz, ${fmtDelta(deltaRaw)} raw`, 92 + '', 93 + `${fmt(headTotal.gzip)} gz (${fmt(headTotal.raw)} raw)`, 94 + ].join('\n'); 95 + 96 + const { data: comments } = await github.rest.issues.listComments({ 97 + owner: context.repo.owner, 98 + repo: context.repo.repo, 99 + issue_number: context.issue.number, 100 + }); 101 + 102 + const existing = comments.find(c => c.body.startsWith('<!-- size-report -->')); 103 + 104 + if (existing) { 105 + await github.rest.issues.updateComment({ 106 + owner: context.repo.owner, 107 + repo: context.repo.repo, 108 + comment_id: existing.id, 109 + body, 110 + }); 111 + } else { 112 + await github.rest.issues.createComment({ 113 + owner: context.repo.owner, 114 + repo: context.repo.repo, 115 + issue_number: context.issue.number, 116 + body, 117 + }); 118 + }