|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build and Test Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +npm run build # Compile TypeScript (uses tsconfig.build.json) |
| 9 | +npm test # Run all tests with Jest |
| 10 | +npm test -- --watch # Run tests in watch mode |
| 11 | +npm test -- path/to/test.spec.ts # Run a single test file |
| 12 | +npm run lint # Run ESLint |
| 13 | +npm run fix # Run ESLint with auto-fix |
| 14 | +npm run format # Format code with Prettier |
| 15 | +npm run format:check # Check formatting without modifying |
| 16 | +``` |
| 17 | + |
| 18 | +## Architecture |
| 19 | + |
| 20 | +This is a GitHub Action that collects benchmark results from various tools and tracks them over time, optionally publishing to GitHub Pages. |
| 21 | + |
| 22 | +### Core Flow |
| 23 | + |
| 24 | +1. **`src/index.ts`** - Entry point that orchestrates the action |
| 25 | +2. **`src/config.ts`** - Parses and validates action inputs from `action.yml` |
| 26 | +3. **`src/extract.ts`** - Parses benchmark output from 12+ supported tools (cargo, go, benchmarkjs, pytest, googlecpp, catch2, julia, jmh, benchmarkdotnet, benchmarkluau, customBiggerIsBetter, customSmallerIsBetter) |
| 27 | +4. **`src/write.ts`** - Handles result storage: commits to gh-pages branch, alerts on regressions, and generates dashboard HTML |
| 28 | + |
| 29 | +### Key Types |
| 30 | + |
| 31 | +- `BenchmarkResult` - Single benchmark measurement with name, value, unit, optional range/extra |
| 32 | +- `Benchmark` - Collection of results tied to a commit |
| 33 | +- `Config` - All action configuration from inputs |
| 34 | + |
| 35 | +### Tool-Specific Extractors |
| 36 | + |
| 37 | +Each benchmark tool has its own extraction function in `src/extract.ts` (e.g., `extractGoResult`, `extractCargoResult`, `extractBenchmarkJsResult`). These parse tool-specific output formats into the unified `BenchmarkResult[]` format. |
| 38 | + |
| 39 | +### Comments and Alerts |
| 40 | + |
| 41 | +`src/comment/` contains logic for posting benchmark comparisons as GitHub commit comments or PR comments when performance regresses beyond a threshold. |
| 42 | + |
| 43 | +## Supported Benchmark Tools |
| 44 | + |
| 45 | +The `tool` input accepts: `cargo`, `go`, `benchmarkjs`, `benchmarkluau`, `pytest`, `googlecpp`, `catch2`, `julia`, `jmh`, `benchmarkdotnet`, `customBiggerIsBetter`, `customSmallerIsBetter` |
| 46 | + |
| 47 | +## Test Data |
| 48 | + |
| 49 | +Test fixtures for each tool's output format are in `test/data/extract/`. Snapshot tests are in `test/__snapshots__/`. |
| 50 | + |
| 51 | +## Plan Mode |
| 52 | + |
| 53 | +- Make the plan extremely concise. Sacrifice grammar for the sake of concision. |
| 54 | +- At the end of each plan, give me a list of unresolved questions to answer, if any. |
| 55 | + |
| 56 | +## Implementation |
| 57 | + |
| 58 | +- Avoid using the `as unknown as ExpectedType`. Instead use type assertions or make sure that the object complies with the expected type. |
0 commit comments