Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ env:

jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
Expand All @@ -31,12 +35,47 @@ jobs:
- name: Build
run: dotnet build --no-restore -c Release

- name: Test
run: dotnet test --no-build -c Release --logger "trx" --results-directory ./artifacts/test-results
# Solution-wide: this includes BenchmarkGate.IntegrationTests, which
# packs + installs the real Tool project and invokes it as a real
# subprocess -- not an in-process Command.Run() shortcut. Running on
# all three OSes here is the actual point: BenchmarkGate is installed
# via `dotnet tool install` on all three, so a single-OS CI run
# doesn't prove it's genuinely portable.
- name: Test with coverage
run: >
dotnet test --no-build -c Release
--logger "trx"
--results-directory ./artifacts/test-results
--collect:"XPlat Code Coverage"
--settings coverlet.runsettings

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
name: test-results-${{ matrix.os }}
path: ./artifacts/test-results

- name: Generate local HTML coverage report
if: matrix.os == 'ubuntu-latest'
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator \
-reports:"./artifacts/test-results/**/coverage.cobertura.xml" \
-targetdir:"./artifacts/coverage-report" \
-reporttypes:Html

- name: Upload HTML coverage report
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-report-html
path: ./artifacts/coverage-report

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v4
with:
directory: ./artifacts/test-results
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
A local-first performance contract gate for BenchmarkDotNet and CI.

![build](https://img.shields.io/github/actions/workflow/status/Bijecta/BenchmarkGate/ci.yml?branch=main&style=flat-square&label=build)
[![codecov](https://codecov.io/gh/Bijecta/BenchmarkGate/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/Bijecta/BenchmarkGate)
![nuget](https://img.shields.io/nuget/v/Bijecta.BenchmarkGate.Tool?style=flat-square&label=nuget)
![license](https://img.shields.io/badge/license-Apache--2.0-4B5163?style=flat-square)
</div>
Expand Down
46 changes: 46 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
codecov:
branch: main
require_ci_to_pass: true

coverage:
precision: 2
round: down
range: "70...100"

status:
# Overall project coverage vs. the base commit (main). Fails (red,
# blocking status check) if coverage drops by more than 1 percentage
# point compared to main -- adjust `threshold` to taste.
project:
default:
target: auto
threshold: 1%
base: auto
if_ci_failed: error
informational: false

# Diff/"patch" coverage -- only the lines actually added or changed in
# this PR. Fails if fewer than 80% of new/changed lines are covered.
# This is usually the more useful gate day-to-day: it catches
# uncovered new code even on a repo whose overall coverage is already
# high, without demanding 100% everywhere.
patch:
default:
target: 80%
threshold: 0%
if_ci_failed: error
informational: false

# Posts/updates a PR comment showing overall + diff coverage vs. main.
comment:
layout: "reach, diff, flags, files"
behavior: default
require_changes: false
require_base: true
require_head: true

# Coverage should measure src/, not the test projects themselves --
# matches coverlet.runsettings' <Exclude> filter, so Codecov and the local
# HTML report agree on what counts.
ignore:
- "tests/**"
23 changes: 23 additions & 0 deletions coverlet.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Format>cobertura</Format>
<!--
Exclude test assemblies from their own coverage numbers
coverage should measure src/, not tests/. [*.Tests] excludes
every project ending in .Tests (Core.Tests, Reporting.Tests,
Tool.Tests, ...); [*IntegrationTests] excludes
BenchmarkGate.IntegrationTests specifically, since it has no
"src equivalent" to measure at all (it only drives a real
subprocess).
-->
<Exclude>[*.Tests]*,[*IntegrationTests]*</Exclude>
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
103 changes: 33 additions & 70 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,96 +20,59 @@ See `PRODUCT-SCOPE.md` for what this tool explicitly is not.

## v0.1.0-alpha.1 — shipped
## v0.2.0-alpha.1 — shipped
## v0.3.0-alpha.1 — Validation — shipped
## v0.4.0-alpha.1 — Comparison — shipped

(see CHANGELOG.md for full detail on both)
(see CHANGELOG.md for full detail on all four)

## v0.2.x — stabilization (before starting v0.3 work)

Confirm, not implement — these should already be true; this is a checklist
to verify before building on top of them:

- [ ] baseline schema is explicitly versioned (`schemaVersion` — done, v2)
- [ ] benchmark identity is centralized (`BenchmarkIdentity` — done)
- [ ] metric units are normalized (`MetricFormatters` — done)
- [ ] parsing exceptions are separated from domain validation
- [x] baseline schema is explicitly versioned (`schemaVersion` — done, v2)
- [x] benchmark identity is centralized (`BenchmarkIdentity` — done)
- [x] metric units are normalized (`MetricFormatters` — done)
- [x] parsing exceptions are separated from domain validation
(`BenchmarkResultParseException` vs. `PolicyFileException`/
`BaselineFileException` — done)
- [ ] commands do not contain evaluation rules (`CheckCommand` orchestrates,
- [x] commands do not contain evaluation rules (`CheckCommand` orchestrates,
`RegressionEvaluator` decides — done)
- [ ] public JSON output has snapshot/regression tests
- [ ] `docs/BUILD-TOOL-INTEGRATION.md` exists — plain shell, NUKE, and Cake
- [X] public JSON output has snapshot/regression tests
- [X] `docs/BUILD-TOOL-INTEGRATION.md` exists — plain shell, NUKE, and Cake
invocation examples. The tool already installs and runs fine under
either build system via a standard local-tool manifest (`dotnet tool
restore`) — this is purely a documentation gap, not a functionality
gap, and it's cheap to close now rather than leave people guessing.
- [ ] exit-code meanings are documented in one place (currently inline on
`ExitCodes` — consider a standalone `EXIT-CODES.md`)
- [x] exit-code meanings are documented in one place (`docs/EXIT-CODES.md`)

## net8.0 multi-targeting (parallel track, not version-gated)

Widen the install floor from net10.0-only to net8.0+net10.0. Small,
mechanical, no design risk — do whenever convenient, doesn't block
anything below.

## v0.3.0 — Validation

New command: `benchmark-gate validate`

Validates, without running the full check pipeline:
- a policy file
- a baseline/snapshot file
- BenchmarkDotNet input
- (later) a comparison report

Core additions:
- `ValidationResult`, `ValidationDiagnostic`, `DiagnosticSeverity`,
`DiagnosticCode`
- `PolicyValidator`, `SnapshotValidator`, `ObservationValidator`

Diagnostic codes, namespaced so they're greppable and stable:
```
BGV101 warningPercent must be lower than failurePercent
BGV203 Duplicate benchmark identity
BGV302 Mean cannot be negative
BGV401 Unsupported snapshot schema version
```

Goal: make invalid data explicit before Compare/History add more surface
that could silently misbehave on bad input.

Not yet: history aggregation, signatures, Merkle trees, profiling, plugin
loading.

## v0.4.0 — Comparison

New command: `benchmark-gate compare --baseline <path> --current <path>`

The architectural change this version exists for:

```
Before: baseline + current + policy → evaluation
After: baseline + current → comparison → (+ policy) → evaluation
```

`check` is refactored to consume `ComparisonResult` rather than compute
deltas itself. This is the load-bearing change of the whole roadmap —
everything from here on (history, explain, later) depends on "what
changed" being a first-class, independently-producible artifact instead
of something baked into the evaluator.

Core additions:
- `BenchmarkComparisonEngine`, `ComparisonResult`, `BenchmarkComparison`,
`MetricComparison`
- `PercentDeltaCalculator`
- `MetricCatalog`, `MetricDescriptor`, `OptimizationDirection`

Comparison statuses: `Comparable`, `Added`, `Removed`,
`MissingReferenceMetric`, `MissingCandidateMetric`, `UnitMismatch`,
`InvalidValue`

Important: `compare` succeeds even when results are slower — it describes
change, it doesn't judge it. `check` applies policy on top of the same
`ComparisonResult`.
## v0.4.x — stabilization (before starting v0.5 work)

Same purpose as the v0.2.x checklist above: confirm, not implement.
v0.5.0 (History) builds directly on `ComparisonResult` being trustworthy
and the CLI surface being solid across platforms — worth locking that
down explicitly before adding a new command surface on top of it.

- [X] Code coverage is measured in CI, not just asserted by test count
- [X] CI runs the full test suite on Windows, Linux, and macOS —
BenchmarkGate is installed via `dotnet tool install` on all
three; a Linux-only CI run doesn't actually prove that
- [X] End-to-end tests exist that install the real packed tool (not an
in-process `Command.Run()` call) and invoke it as a subprocess —
proves the packed artifact people actually install works, not
just the code that builds it
- [x] Tag-driven release pipeline confirmed working end-to-end
(see `.github/workflows/release.yml`: pack, smoke-test the
installed package, publish to NuGet.org via Trusted Publishing,
auto-generate the GitHub release)
- [X] A coverage badge is visible in the README, not just collected
silently in CI

## v0.5.0 — Filesystem history

Expand Down Expand Up @@ -297,4 +260,4 @@ platform":
- Diagnostic comparison and explanation engine

See the architecture notes (`docs/architecture/`) for the fuller sketch of
where these could go — not committed, not scheduled.
where these could go — not committed, not scheduled.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
<PackageReference Include="xunit.v3" />
</ItemGroup>

<ItemGroup>
<None Include="Fixtures\sample-results.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading
Loading