Skip to content

test(codex): use fixture macro for group dedupe - #1162

Merged
ryoppippi merged 1 commit into
mainfrom
codex/fix-main-ci-fixture
May 25, 2026
Merged

test(codex): use fixture macro for group dedupe#1162
ryoppippi merged 1 commit into
mainfrom
codex/fix-main-ci-fixture

Conversation

@ryoppippi

@ryoppippi ryoppippi commented May 25, 2026

Copy link
Copy Markdown
Member

Fixes the main branch CI failure introduced by the Codex grouped dedupe test.

The test was still using a handwritten temporary directory after the shared fixture macro cleanup, which left SystemTime, UNIX_EPOCH, and fs undeclared in the test module. This switches the test to fs_fixture! and avoids adding any crate or manifest changes.

Testing:

  • direnv exec . pnpm run format
  • env -u CFLAGS -u CPPFLAGS -u LDFLAGS direnv exec . pnpm run test:rust
  • env -u CFLAGS -u CPPFLAGS -u LDFLAGS NIX_CONFIG="access-tokens = github.com=$(gh auth token)" nix flake check --print-build-logs

Summary by cubic

Fix main-branch CI by switching the Codex grouped dedupe test to the shared fs_fixture! macro. Removes the handwritten temp directory and undeclared SystemTime/UNIX_EPOCH/fs imports, keeping the test aligned with repo fixtures without any manifest changes.

Written for commit a918deb. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Tests
    • Improved test infrastructure for usage event grouping validation with better test data setup utilities.

Review Change Stack

Replace the handwritten temporary directory setup in the Codex grouped dedupe test with the shared fs_fixture! macro.

The main branch CI failed because the newly added test used SystemTime, UNIX_EPOCH, and fs without importing them after the fixture macro cleanup landed. Using the shared fixture helper removes those ad hoc dependencies and keeps the test aligned with the repo-local Rust testing guidance.
@ryoppippi

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1c208e3-8fcb-429e-9185-485830f923f9

📥 Commits

Reviewing files that changed from the base of the PR and between eef2543 and a918deb.

📒 Files selected for processing (1)
  • rust/crates/ccusage/src/adapter/codex/mod.rs

📝 Walkthrough

Walkthrough

The test keeps_matching_grouped_codex_usage_events_from_distinct_sessions was refactored to use the fs_fixture! helper macro for setting up test fixtures. The manual temp directory creation via SystemTime/UNIX_EPOCH, file writing with fs::write, and cleanup with fs::remove_dir_all were replaced with declarative fixture setup that creates session files inline.

Changes

Codex Session Grouping Test Refactoring

Layer / File(s) Summary
Test setup refactoring with fs_fixture! macro
rust/crates/ccusage/src/adapter/codex/mod.rs
Replaced manual temp directory creation and file I/O with declarative fs_fixture! macro for defining session files (session-a.jsonl and session-b.jsonl), shared usage line, and test fixtures.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • ryoppippi/ccusage#1136: The main PR's test refactor directly depends on and exercises the fixture-support crate/macro introduced in this PR.
  • ryoppippi/ccusage#1137: Both PRs update the Codex test module in adapter/codex/mod.rs; this PR switches temp-dir setup to fs_fixture! while that PR adjusts test module wiring.
  • ryoppippi/ccusage#1156: This PR's refactored test exercises grouping/deduping across multiple session files, which would be directly affected by changes to Codex loader dedupe logic in that PR.

Poem

🐰 A fixture helper, clean and bright,
Banished temp dirs from the night!
Sessions grouped with declarations fine,
The tests now read in perfect line.
Tidy code that makes us cheer—
Less boilerplate, more crystal clear!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(codex): use fixture macro for group dedupe' clearly and specifically describes the main change: refactoring a test to use a fixture macro instead of manual setup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-main-ci-fixture

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ccusage-guide a918deb Commit Preview URL

Branch Preview URL
May 25 2026, 09:43 PM

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@pkg-pr-new

pkg-pr-new Bot commented May 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

ccusage

npx https://pkg.pr.new/ccusage@1162

@ccusage/ccusage-darwin-arm64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-arm64@1162

@ccusage/ccusage-darwin-x64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-x64@1162

@ccusage/ccusage-linux-arm64

npx https://pkg.pr.new/@ccusage/ccusage-linux-arm64@1162

@ccusage/ccusage-linux-x64

npx https://pkg.pr.new/@ccusage/ccusage-linux-x64@1162

@ccusage/ccusage-win32-arm64

npx https://pkg.pr.new/@ccusage/ccusage-win32-arm64@1162

@ccusage/ccusage-win32-x64

npx https://pkg.pr.new/@ccusage/ccusage-win32-x64@1162

commit: a918deb

@ryoppippi
ryoppippi merged commit 0a4a7a2 into main May 25, 2026
41 checks passed
@ryoppippi
ryoppippi deleted the codex/fix-main-ci-fixture branch May 25, 2026 21:59
@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: a918deb6e43a
Base SHA: eef25437bece

This compares the PR package against the configured base package on the same CI runner.

Package runner startup

Execution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one bunx -p <url> ccusage --version run with an empty Bun install cache. Warm reuses that cache and reports the median of repeated runs.

Package SHA Execution setup Bunx temp cache Bunx warm median Warm samples
Base pkg.pr.new eef25437bece 773.1ms 734.2ms 36.0ms 3
PR pkg.pr.new a918deb 562.5ms 727.0ms 36.0ms 3

Cached bunx execution performance

Runs the same large fixture through bunx -p <pkg.pr.new URL> ccusage after the Bun install cache has already been populated by the startup measurement. This separates cached package-runner execution from first-fetch package materialization.

Fixtures: Claude /home/runner/work/_temp/ccusage-large-fixture (1.01 GiB, 2,597 files), Codex /home/runner/work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2,597 files)
Base package: eef25437bece; PR package: a918deb. Both run through bunx -p <pkg.pr.new URL> ccusage using the warmed Bun install cache from package runner startup, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
bunx -p <pkg> ccusage claude --offline --json 1.01 GiB 588.7ms 605.7ms 0.97x 276.45 MiB 334.58 MiB 1.21x 1.71 GiB/s 1.66 GiB/s
bunx -p <pkg> ccusage codex --offline --json 1.01 GiB 388.2ms 378.4ms 1.03x 81.58 MiB 67.08 MiB 0.82x 2.59 GiB/s 2.66 GiB/s

Package runtime diagnostics

Compares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself.

Fixtures: Claude /home/runner/work/_temp/ccusage-large-fixture (1.01 GiB, 2,597 files), Codex /home/runner/work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2,597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 570.7ms 1.76 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 546.4ms 1.84 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 391.1ms 2.57 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 341.3ms 2.95 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 32.0ms 32.6ms 0.98x 43.61 MiB 43.61 MiB 1.00x 0.05 MiB/s 0.05 MiB/s
claude session --offline --json 0.00 MiB 32.0ms 31.8ms 1.01x 43.61 MiB 43.48 MiB 1.00x 0.05 MiB/s 0.05 MiB/s
codex daily --offline --json 0.00 MiB 31.5ms 32.2ms 0.98x - - - 0.03 MiB/s 0.03 MiB/s
codex session --offline --json 0.00 MiB 32.5ms 32.3ms 1.00x 43.61 MiB 43.61 MiB 1.00x 0.03 MiB/s 0.03 MiB/s

Large real-world-shaped fixture performance

Generated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures.

Fixtures: Claude /home/runner/work/_temp/ccusage-large-fixture (1.01 GiB, 2,597 files), Codex /home/runner/work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2,597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs the published ccusage package from pkg.pr.new, installed before measurement. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 572.9ms 561.9ms 1.02x 302.83 MiB 329.95 MiB 1.09x 1.76 GiB/s 1.79 GiB/s
codex --offline --json 1.01 GiB 368.8ms 370.7ms 0.99x - - - 2.73 GiB/s 2.72 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 14.21 KiB 14.22 KiB +0.00 KiB 1.00x
installed native package binary 3289.49 KiB 3289.49 KiB +0.00 KiB 1.00x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: a918deb6e43a
Base SHA: eef25437bece

This compares the Rust PR release binary against the configured base package on the same CI runner.

Package runner startup

Execution setup measures any pre-benchmark package materialization used by the execution benchmark. Bunx temp cache measures one bunx -p <url> ccusage --version run with an empty Bun install cache. Warm reuses that cache and reports the median of repeated runs.

Package SHA Execution setup Bunx temp cache Bunx warm median Warm samples
Base pkg.pr.new eef25437bece 734.6ms 592.2ms 35.3ms 3
PR pkg.pr.new a918deb 515.2ms 463.2ms 35.8ms 3

Cached bunx execution performance

Runs the same large fixture through bunx -p <pkg.pr.new URL> ccusage after the Bun install cache has already been populated by the startup measurement. This separates cached package-runner execution from first-fetch package materialization.

Fixtures: Claude /home/runner/work/_temp/ccusage-large-fixture (1.01 GiB, 2,597 files), Codex /home/runner/work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2,597 files)
Base package: eef25437bece; PR package: a918deb. Both run through bunx -p <pkg.pr.new URL> ccusage using the warmed Bun install cache from package runner startup, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
bunx -p <pkg> ccusage claude --offline --json 1.01 GiB 568.6ms 563.4ms 1.01x 292.45 MiB 306.95 MiB 1.05x 1.77 GiB/s 1.79 GiB/s
bunx -p <pkg> ccusage codex --offline --json 1.01 GiB 374.7ms 378.7ms 0.99x 74.95 MiB 69.58 MiB 0.93x 2.69 GiB/s 2.66 GiB/s

Package runtime diagnostics

Compares the PR package wrapper, the installed native optional dependency binary, and the workspace release binary on the same large fixture. This identifies whether slow package results come from JavaScript wrapper overhead, the published native binary build, or the Rust core itself.

Fixtures: Claude /home/runner/work/_temp/ccusage-large-fixture (1.01 GiB, 2,597 files), Codex /home/runner/work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2,597 files)
All rows run --offline --json, measured by hyperfine with 0 warmups and 1 runs. This isolates wrapper overhead from the installed native optional dependency and the workspace release binary built on the runner.

Command Runtime Input Median Throughput Samples
claude --offline --json Package wrapper 1.01 GiB 560.0ms 1.80 GiB/s 1
claude --offline --json Installed native binary 1.01 GiB 535.1ms 1.88 GiB/s 1
codex --offline --json Package wrapper 1.01 GiB 369.5ms 2.72 GiB/s 1
codex --offline --json Installed native binary 1.01 GiB 344.0ms 2.93 GiB/s 1

Committed fixture performance

Committed small fixtures for stable PR-to-PR feedback and explicit Claude/Codex command coverage.

Fixtures: Claude apps/ccusage/test/fixtures/claude (0.00 MiB, 2 files), Codex apps/ccusage/test/fixtures/codex (0.00 MiB, 1 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs rust/target/release/ccusage directly. Both run --offline --json, measured by hyperfine with 2 warmups and 7 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude daily --offline --json 0.00 MiB 32.0ms 4.4ms 7.23x - 2.83 MiB - 0.05 MiB/s 0.35 MiB/s
claude session --offline --json 0.00 MiB 32.2ms 4.4ms 7.29x - 2.83 MiB - 0.05 MiB/s 0.35 MiB/s
codex daily --offline --json 0.00 MiB 32.8ms 4.1ms 8.09x 43.73 MiB 2.83 MiB 0.06x 0.03 MiB/s 0.21 MiB/s
codex session --offline --json 0.00 MiB 32.4ms 4.2ms 7.81x 43.61 MiB 2.83 MiB 0.06x 0.03 MiB/s 0.21 MiB/s

Large real-world-shaped fixture performance

Generated fixtures shaped from aggregate local log statistics: thousands of JSONL files, many small sessions, and a long tail of larger sessions. No real prompts, paths, or outputs are stored in the fixtures.

Fixtures: Claude /home/runner/work/_temp/ccusage-large-fixture (1.01 GiB, 2,597 files), Codex /home/runner/work/_temp/ccusage-large-codex-fixture (1.01 GiB, 2,597 files)
Base runs the published ccusage package from pkg.pr.new, installed before measurement; PR runs rust/target/release/ccusage directly. Both run --offline --json, measured by hyperfine with 0 warmups and 1 runs.
Peak RSS is measured separately with /usr/bin/time using 1 runs. Lower RSS ratios are better.

Command Input Base median PR median PR vs base Base peak RSS PR peak RSS PR/base RSS Base throughput PR throughput
claude --offline --json 1.01 GiB 575.1ms 528.6ms 1.09x - 274.45 MiB - 1.75 GiB/s 1.90 GiB/s
codex --offline --json 1.01 GiB 374.6ms 343.8ms 1.09x 79.45 MiB 79.20 MiB 1.00x 2.69 GiB/s 2.93 GiB/s

Artifact size

Artifact Base PR Delta Ratio
packed ccusage-*.tgz 14.21 KiB 14.22 KiB +0.00 KiB 1.00x
installed native package binary 3289.49 KiB 3289.49 KiB +0.00 KiB 1.00x

Lower medians and smaller artifacts are better. CI runner noise still applies; use same-run ratios as directional PR feedback, not release guarantees.

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.

1 participant