Skip to content

feat(binstat): track build mode (release/dev) in size stats and comparison#778

Open
Alan Wisper (wisper-dev) wants to merge 2 commits into
mainfrom
fix/binstat-build-mode
Open

feat(binstat): track build mode (release/dev) in size stats and comparison#778
Alan Wisper (wisper-dev) wants to merge 2 commits into
mainfrom
fix/binstat-build-mode

Conversation

@wisper-dev

Copy link
Copy Markdown
Member

Why

The PR "Binary Size Report" compares size stats without accounting for the build
mode. A release build (small) and a dev build (large) are indistinguishable, so
when a commit has stats for both modes the comparison picks the most recent by
timestamp and reports a large bogus delta.

What changes

Adds a mode dimension (release | dev), optional at every layer — fully
backward compatible:

  • commons: mode field on BinstatInfo and the zod schema (z.optional).
  • devstat: persist mode to D1 (binstats-v1); filter AND mode = ? only
    when the param is supplied; SQL extracted into a pure buildBinstatQuery.
  • client: --mode option on binstats and bincompare, threaded into the
    query URL, with value validation; version 0.1.1 -> 0.1.2.

Tests

bun test (10/10): schema (mode optional / invalid rejected), query building
(filter only when mode is present, os/arch/mode ordering), client (URL with/without
mode, per-platform dedup).

Compatibility

Rows without mode (NULL) do not match a mode=... filter; a platform with no
same-mode baseline renders N/A and self-heals as new stats accrue. Existing
clients and queries behave as before.

Deployment (out of CI, in order)

  1. ALTER TABLE 'binstats-v1' ADD COLUMN mode TEXT;
  2. Deploy the devstat worker.
  3. Publish client 0.1.2 to npm.

A companion change in the consuming CI threads --mode and pins the client version.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional build-mode dimension (release | dev) to binstat records and query/comparison flows to avoid mixing dev vs. release binaries in size reporting, while keeping legacy records/clients working.

Changes:

  • Extend the shared binstat model/schema to include optional mode, plus tests.
  • Persist and query mode in the devstat worker (D1 insert + optional query filter), with query SQL extracted to buildBinstatQuery and covered by tests.
  • Add a --mode option to the CLI (binstats + bincompare) and thread it through URL building and comparisons, with tests and a client version bump.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
services/devstat/tsconfig.json Excludes test files from TS compilation for the devstat package.
services/devstat/package.json Adds a bun test script for devstat.
services/devstat/handlers/stats.mts Persists mode to D1 when inserting binstat records.
services/devstat/handlers/query.mts Adds optional mode filtering and extracts SQL construction into buildBinstatQuery.
services/devstat/handlers/query.test.mts Adds unit tests for query SQL/parameter construction including mode.
services/commons/tsconfig.json Excludes test files from TS compilation for the commons package.
services/commons/package.json Adds a bun test script for commons.
services/commons/api.mts Introduces BuildMode and adds optional mode to BinstatInfo + schema.
services/commons/api.test.mts Adds schema tests verifying mode is optional and validated.
services/client/tsconfig.json Excludes test files from TS compilation for the client package.
services/client/package.json Bumps client version to 0.1.2 and adds a bun test script.
services/client/client.mts Adds --mode CLI options for binstats and bincompare.
services/client/actions/binstats.mts Validates and includes mode in posted binstat payloads.
services/client/actions/bincompare.mts Threads mode into query URL construction and fetches; exports helpers for testing.
services/client/actions/bincompare.test.mts Adds unit tests for URL building and per-platform deduplication behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/devstat/handlers/stats.mts Outdated
Comment thread services/devstat/handlers/query.mts
Comment thread services/commons/api.mts
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants