[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay bomb.sh/docs/tty
Something went wrong. Try again.
YAML
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124name: Size Report
on: pull_request:
permissions: contents: read pull-requests: write
concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true
jobs: size-report: name: Size Report runs-on: ubuntu-latest
steps: - name: checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4 with: submodules: true fetch-depth: 0 persist-credentials: false
- name: setup deno uses: denoland/setup-deno@22d081ff2d3a40755e97629de92e3bcbfa7cf2ed # v2.0.5 with: # Pinned to v2.8.3 to avoid https://github.com/denoland/deno/issues/35529 # (v2.9.0 rejects JSR files without a manifest checksum on warm cache). # Restore to v2.x once v2.9.1 ships. deno-version: v2.8.3
- name: setup node uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v4 with: node-version: 24
- name: build (head) run: make clean && make && deno task build:npm 0.0.0
- name: measure sizes (head) run: | cp tasks/measure-size.ts /tmp/measure-size.ts deno run --allow-read /tmp/measure-size.ts > /tmp/head-sizes.json
- name: find merge base id: base run: | SHA=$(git merge-base HEAD origin/${{ github.base_ref }}) echo "sha=$SHA" >> $GITHUB_OUTPUT
- name: checkout base commit run: | git checkout ${{ steps.base.outputs.sha }} git submodule update --init --recursive
- name: build (base) run: make clean && make && deno task build:npm 0.0.0
- name: measure sizes (base) run: deno run --allow-read /tmp/measure-size.ts > /tmp/base-sizes.json
- name: post size report uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: script: | const fs = require('fs'); const head = JSON.parse(fs.readFileSync('/tmp/head-sizes.json', 'utf8')); const base = JSON.parse(fs.readFileSync('/tmp/base-sizes.json', 'utf8'));
const total = (arr) => arr.reduce((acc, f) => acc + f.size, 0); const headTotal = total(head); const baseTotal = total(base);
const delta = headTotal - baseTotal;
const fmt = (n) => `${(n / 1024).toFixed(1)} KB`; const fmtDelta = (n) => `${n > 0 ? '+' : ''}${(n / 1024).toFixed(1)} KB`;
if (delta === 0) return;
const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, });
const existing = comments.find(c => c.body.startsWith('<!-- size-report -->'));
// Skip if the head sizes haven't changed since the last push if (existing) { const match = existing.body.match(/<!-- sizes:(\d+) -->/); if (match && Number(match[1]) === headTotal) return; }
const takeaway = delta < 0 ? 'Size Reduced' : 'Size Increased';
const body = [ '<!-- size-report -->', `<!-- sizes:${headTotal} -->`, `**${takeaway}** — ${fmtDelta(delta)}`, '', `${fmt(headTotal)} unpacked`, ].join('\n');
if (existing) { await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existing.id, body, }); } else { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body, }); }