Skip to content

fix(ci): save all benchmark reports and use git-based dev versioning#196

Merged
carlos-alm merged 10 commits intomainfrom
fix/benchmark-all-reports
Mar 1, 2026
Merged

fix(ci): save all benchmark reports and use git-based dev versioning#196
carlos-alm merged 10 commits intomainfrom
fix/benchmark-all-reports

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Merges PR fix(ci): use commit-count versioning for dev builds and benchmarks #173 (fix/dogfood-missing-branch-compare): switches dev builds from timestamp-based versioning to git-based commit-count versioning (MAJOR.MINOR.PATCH-dev.SHA), keeping dev and stable versions consistent with scripts/bench-version.js.
  • Fixes untracked file detection in benchmark workflow: the "Check for changes" step in all 4 benchmark jobs (build, embedding, query, incremental) used git diff --quiet HEAD which only detects modifications to tracked files. When report files like EMBEDDING-BENCHMARKS.md, QUERY-BENCHMARKS.md, and INCREMENTAL-BENCHMARKS.md don't yet exist in the repo, they are created as untracked files and git diff silently reports no changes, so the PR is never created. Each step now also checks for untracked files via git ls-files --others --exclude-standard.

Test plan

  • Trigger the benchmark workflow manually and verify all 4 jobs detect new report files
  • Verify dev build versioning produces correct MAJOR.MINOR.PATCH-dev.SHA format
  • Confirm publish workflow compute-version step works with fetch-depth: 0

github-actions bot and others added 10 commits February 28, 2026 01:39
The branch-compare command was registered in cli.js and its exports
added to index.js, but the implementation file src/branch-compare.js
was never created. This caused two issues:

1. `codegraph branch-compare` crashed with ERR_MODULE_NOT_FOUND
2. `import('@optave/codegraph')` crashed entirely because index.js
   has a top-level re-export from the missing file, making the
   programmatic API completely unusable

Remove the dead references until an implementation exists.

Closes #166
The branch-compare command was registered in cli.js and index.js but
src/branch-compare.js was never committed — it was lost as untracked
files in the fix/complexity-sql-sanitize worktree. Recovered the full
implementation (568 lines) and integration test (192 lines, 7 tests)
from git object 22c8185.

This restores the cli.js command and index.js exports that were removed
in 746aa65, now that the implementation file exists. Updated the dogfood
report to reflect the recovery (no bugs found, rating 8.5/10).

Closes #166

Impact: 13 functions changed, 4 affected
Dev builds always produced 2.4.1-dev.<sha> because PATCH was hardcoded
to +1 from package.json. Now uses git rev-list to count commits since
the release tag, giving monotonically increasing versions like 2.4.5,
2.4.15, etc.

Benchmark scripts now use getBenchmarkVersion() (via git describe) to
detect dev vs release state, preventing dev runs from overwriting
release benchmark data in historical reports.

Impact: 2 functions changed, 6 affected
The bench-config.js local mode returned 'dev' as the version string.
Now uses getBenchmarkVersion() to derive a proper semver from git state,
so all 4 benchmark scripts that use bench-config get dev-aware versions.

Impact: 1 functions changed, 4 affected
Both now use git describe --tags --match "v*" to find the nearest
release tag and count commits from it. Previously publish.yml
constructed the tag from package.json (v${CURRENT}) while
bench-version.js used git describe, which would diverge if
package.json was bumped but not yet tagged.

Impact: 1 functions changed, 0 affected
When no git tags exist, bench-version.js now produces PATCH+1 (e.g.
"2.5.1-dev") matching publish.yml's fallback, instead of the bare
"2.5.0-dev" which diverged.

Impact: 1 functions changed, 0 affected
Refactor getBenchmarkVersion to use --abbrev=0 + git rev-list (same
as publish.yml) instead of parsing full git describe output. Both
now use identical steps: find tag, count commits, get short SHA.

Impact: 1 functions changed, 0 affected
…om/optave/codegraph into fix/benchmark-all-reports

# Conflicts:
#	.github/workflows/publish.yml

Impact: 3 functions changed, 7 affected
Merges PR #173 (commit-count versioning for dev builds) and fixes a bug
where embedding, query, and incremental benchmark reports were never
persisted. The "Check for changes" step used `git diff` which only
detects modifications to tracked files — newly created report files
(untracked) were invisible, so the PR was never created. Now also checks
for untracked files via `git ls-files --others`.
@claude
Copy link

claude bot commented Mar 1, 2026

Claude finished @carlos-alm's task —— View job


PR Review: Fix untracked file detection in benchmark workflow and implement git-based dev versioning

Review Checklist

  • Phase 1: Root cause analysis - understand the actual problem
  • Phase 2: Configuration change detection - scrutinize CI/workflow changes
  • Phase 3: Test integrity - check for weakened tests
  • Phase 4: Code quality review - examine implementation details
  • Final Assessment: Provide rating and recommendation

Root Cause Analysis

Problem Being Solved: Benchmark workflow fails to detect newly created report files because git diff --quiet HEAD only checks tracked files. When report files like EMBEDDING-BENCHMARKS.md, QUERY-BENCHMARKS.md, and INCREMENTAL-BENCHMARKS.md don't exist in the repo, they are created as untracked files and silently ignored, preventing PR creation.

Why This Approach: Adding git ls-files --others --exclude-standard to detect untracked files alongside the existing git diff check is the correct fix. This ensures both modified tracked files AND newly created untracked files trigger PR creation.

Risk Assessment: LOW RISK - This is a legitimate bug fix addressing a real workflow failure, not a workaround to hide issues.

Configuration Change Analysis ✅

LOW RISK - All changes are justified and improve functionality:

  1. Benchmark workflow changes (.github/workflows/benchmark.yml) lines 92-104, 217-229, 330-342, 443-455:

    • Proper fix: Added untracked file detection to all 4 benchmark jobs
    • Consistent implementation: Same git ls-files --others --exclude-standard <file> pattern applied uniformly
    • Preserves existing logic: Still checks tracked file changes with git diff --quiet HEAD
    • No rules relaxed: No permissions or safety checks weakened
  2. Publish workflow changes (.github/workflows/publish.yml) line 48:

    • Added fetch-depth: 0 to compute-version step for git history access
    • Legitimate requirement: Required for git describe and git rev-list commands in dev versioning
  3. New versioning script (scripts/bench-version.js):

    • Mirrors publish workflow logic: Uses identical git describe --tags and git rev-list strategy
    • Proper error handling: Graceful fallbacks for no git/no tags scenarios
    • Good separation of concerns: Extracted versioning logic into reusable module

Test Integrity ✅

  • No test modifications: No test files were changed
  • No weakened assertions: No test expectations lowered
  • New code not tested: The new bench-version.js has no tests, but it's a simple utility with good error handling

Code Quality ✅

Strengths:

  • Consistent file detection pattern applied across all 4 jobs
  • Proper error handling with 2>/dev/null redirects
  • Version consistency between benchmark and publish workflows
  • Good documentation in comments explaining the fix

Minor Issues:

  • ⚠️ Line 16 scripts/bench-version.js: Uses execFileSync without timeout - could hang on git operations
  • ⚠️ Line 18: GIT_OPTS includes both stdio: ['pipe', 'pipe', 'pipe'] and encoding: 'utf8' which is redundant

Architecture:

  • Proper separation: Extracted shared version logic into dedicated module
  • Consistent API: getBenchmarkVersion() matches expected interface
  • Good fallback strategy: Handles no-git and no-tags scenarios appropriately

Final Assessment

## Root Cause Analysis
**Problem Being Solved**: Real workflow bug where untracked benchmark report files weren't detected for PR creation
**Why This Approach**: Correct fix - adds untracked file detection while preserving existing tracked file checks
**Risk Assessment**: LOW RISK - Legitimate bug fix that improves CI functionality

## Critical Concerns
None. This is a well-implemented fix addressing a real issue with proper error handling and consistent patterns.

## Final Recommendation  
- Rating: ⭐⭐⭐⭐☆ (4/5)
- Action: **APPROVE** 
- Reasoning: Solid bug fix with good implementation. The untracked file detection resolves a real CI issue, and the git-based versioning provides better consistency. Minor improvements possible but not blocking.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 1, 2026

Greptile Summary

Fixed critical bug in benchmark workflow where new report files weren't detected because git diff --quiet only checks tracked files. All 4 benchmark jobs now properly detect untracked files via git ls-files --others --exclude-standard. Unified dev versioning strategy across publish workflow and benchmark scripts using git commit-count (MAJOR.MINOR.PATCH-dev.SHA where PATCH increments with each commit since last tag).

Key changes:

  • Fixed file detection in benchmark.yml by adding untracked file check to all 4 jobs (build, embedding, query, incremental)
  • Added fetch-depth: 0 to publish.yml checkout for full git history access
  • Created scripts/bench-version.js implementing the same two-step versioning as publish.yml (git describe + rev-list)
  • Updated bench-config.js and token-benchmark.js to use new versioning function
  • Maintains consistency: dev builds no longer overwrite release benchmark data due to identical versions

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes fix a concrete CI bug with proper untracked file detection and unify versioning logic across workflows. All implementations are consistent, include proper error handling and fallbacks, and don't modify runtime behavior
  • No files require special attention

Important Files Changed

Filename Overview
.github/workflows/benchmark.yml Fixed untracked file detection in all 4 benchmark jobs by adding git ls-files --others --exclude-standard check alongside existing git diff check
.github/workflows/publish.yml Added fetch-depth: 0 and switched dev versioning from simple PATCH+1 to git commit-count strategy matching bench-version.js
scripts/bench-version.js New file implementing git-based versioning with proper fallbacks, mirrors publish.yml's two-step strategy (git describe + rev-list)
scripts/lib/bench-config.js Updated local mode to use getBenchmarkVersion instead of hardcoded "dev" string
scripts/token-benchmark.js Updated to use getBenchmarkVersion for consistent git-based version labeling across all benchmark scripts

Last reviewed commit: 5f4cec0

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@carlos-alm carlos-alm merged commit 267cabe into main Mar 1, 2026
17 checks passed
@carlos-alm carlos-alm deleted the fix/benchmark-all-reports branch March 1, 2026 23:57
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