Skip to content

Compile public documentation snippets in CI - #2874

Merged
thomhurst merged 2 commits into
mainfrom
test/compile-doc-snippets
Aug 21, 2026
Merged

Compile public documentation snippets in CI#2874
thomhurst merged 2 commits into
mainfrom
test/compile-doc-snippets

Conversation

@thomhurst

Copy link
Copy Markdown
Owner

Summary

  • compile every public C# documentation fence against current Dekaf source projects
  • validate documented NuGet package IDs and dotnet run project paths
  • gate documentation and source changes in CI, with explicit reasoned exclusions
  • pin 155 known legacy failures by exact source and diagnostic fingerprint
  • update stale examples found by the new compiler gate

Adapted from thomhurst/Kevlar#69.

Validation

  • dotnet build tests/Dekaf.DocTests --configuration Release --framework net10.0
  • dotnet run --no-build --project tests/Dekaf.DocTests --configuration Release --framework net10.0 -- --repository-root .
  • dotnet format tests/Dekaf.DocTests/Dekaf.DocTests.csproj --verify-no-changes --no-restore --verbosity minimal
  • npm run build from docs/
  • git diff --check

No src/ changes; performance benchmarks are not applicable.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@thomhurst, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Limit details: You’ve used all 10 included reviews currently available.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1dc71857-a675-4aa3-8df6-e90ab43632f8

📥 Commits

Reviewing files that changed from the base of the PR and between 420d61d and 56c3a31.

📒 Files selected for processing (21)
  • .github/workflows/ci.yml
  • README.md
  • docs/docs/compression.md
  • docs/docs/configuration/consumer-options.md
  • docs/docs/configuration/presets.md
  • docs/docs/consumer/consumer-groups.md
  • docs/docs/consumer/dead-letter-queues.md
  • docs/docs/consumer/manual-assignment.md
  • docs/docs/dependency-injection.md
  • docs/docs/hosted-services.md
  • docs/docs/performance.md
  • docs/docs/producer/basics.md
  • docs/docs/producer/fire-and-forget.md
  • docs/docs/producer/partitioning.md
  • docs/docs/producer/topic-producer.md
  • docs/docs/serialization/json.md
  • docs/docs/testing.md
  • tests/Dekaf.DocTests/Dekaf.DocTests.csproj
  • tests/Dekaf.DocTests/DocContext.cs
  • tests/Dekaf.DocTests/KnownFailures.sha256
  • tests/Dekaf.DocTests/Program.cs

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

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds a CI gate that compiles public C# documentation fences against current Dekaf projects, validates selected shell commands, and fingerprints known legacy failures.

  • Adds the Dekaf.DocTests compiler harness and shared fragment context.
  • Runs documentation validation for relevant documentation, source, test, and build-system changes.
  • Updates stale public examples to use current APIs.
  • Documents the gate’s fragment-oriented scope and explicit exclusion mechanism.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
tests/Dekaf.DocTests/Program.cs Implements snippet extraction, Roslyn compilation, shell-sample validation, explicit exclusions, and deterministic legacy-failure fingerprinting.
tests/Dekaf.DocTests/DocContext.cs Provides the shared application context intentionally used to validate fragment-level public API usage.
.github/workflows/ci.yml Adds the documentation-snippet job to relevant path filtering and the required aggregate CI gate.
docs/docs/testing.md Documents local execution, known-failure handling, explicit exclusions, and the gate’s non-standalone scope.

Reviews (2): Last reviewed commit: "fix(docs): harden snippet validation" | Re-trigger Greptile

Comment on lines +22 to +95
private static readonly string Prelude = """
using System;
using System.Buffers;
using System.Buffers.Binary;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
using System.Threading;
using System.Threading.Tasks;
using Amazon;
using Avro;
using Avro.Generic;
using Azure.Identity;
using Azure.Core;
using BenchmarkDotNet.Attributes;
using Dekaf;
using Dekaf.Admin;
using Dekaf.Compression;
using Dekaf.Compression.Brotli;
using Dekaf.Compression.Lz4;
using Dekaf.Compression.Snappy;
using Dekaf.Compression.Zstd;
using Dekaf.Consumer;
using Dekaf.Consumer.DeadLetter;
using Dekaf.Errors;
using Dekaf.Extensions.DependencyInjection;
using Dekaf.Extensions.Hosting;
using Dekaf.OpenTelemetry;
using Dekaf.Networking;
using Dekaf.Outbox;
using Dekaf.Outbox.EntityFrameworkCore;
using Dekaf.Producer;
using Dekaf.Protocol;
using Dekaf.Protocol.Messages;
using Dekaf.Protocol.Records;
using Dekaf.Retry;
using Dekaf.SchemaRegistry;
using Dekaf.SchemaRegistry.Avro;
using Dekaf.SchemaRegistry.Json;
using Dekaf.SchemaRegistry.Jsonata;
using Dekaf.SchemaRegistry.Kms.Aws;
using Dekaf.SchemaRegistry.Kms.Azure;
using Dekaf.SchemaRegistry.Kms.Gcp;
using Dekaf.SchemaRegistry.Kms.Vault;
using Dekaf.SchemaRegistry.Protobuf;
using Dekaf.Security;
using Dekaf.Security.Sasl;
using Dekaf.ShareConsumer;
using Dekaf.Serialization;
using Dekaf.Serialization.Json;
using Dekaf.Serialization.Routing;
using Dekaf.Testing;
using Google.Cloud.Kms.V1;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.EntityFrameworkCore;
using Dekaf.DocTests;
using static Dekaf.DocTests.DocContext;
""";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Universal prelude masks prerequisites

The harness injects every Dekaf namespace, references nearly every source project, and exposes synthetic context to each fence. This lets examples with omitted imports, package dependencies, models, or variables pass CI even though the prerequisites shown to readers are insufficient, reducing the gate's ability to catch incomplete snippets.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16db679ceb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/Dekaf.DocTests/Program.cs Outdated
source = BuildBuilderChain(snippet, source);
}

source = MoveTopLevelStatementsBeforeDeclarations(source);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compile snippets without reordering their members

For fences that place a type declaration before example usage, this rewrite moves the global statements ahead of the declaration and compiles code different from what readers see. Existing examples such as the custom preset fence in docs/docs/configuration/presets.md contain a class followed by var producer = ...; copied verbatim, that is rejected with CS8803, but this gate reports it as compilable. The documentation check should compile the original ordering and require these examples to be rearranged or explicitly excluded.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/ci.yml
Comment on lines +77 to +84
docs:
- 'README.md'
- 'docs/docs/**'
- 'src/**'
- 'tests/Dekaf.DocTests/**'
- 'Directory.Build.props'
- 'Directory.Build.targets'
- 'Directory.Packages.props'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Run the docs gate when its workflow changes

The inspected doc-snippets job is controlled by this docs output, but .github/workflows/ci.yml is absent from the allowlist. Consequently, a PR that changes only the job's command or setup marks doc-snippets as skipped; the separate code filter runs the full solution, which does not include Dekaf.DocTests, and ci-passed explicitly accepts skipped jobs. Include this workflow among the docs inputs so changes to the gate itself are exercised.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 56c3a3174e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml
- 'Directory.Build.props'
- 'Directory.Build.targets'
- 'Directory.Packages.props'
- '.github/workflows/ci.yml'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Run snippet checks after SDK selection changes

When a PR adds or changes only global.json, the code filter runs but this docs filter remains false. The full-solution build does not include Dekaf.DocTests, and ci-passed accepts the skipped snippet job, so an SDK/compiler change can break this new project without being detected until a later documentation or source change. Include global.json in this allowlist.

Useful? React with 👍 / 👎.

@thomhurst
thomhurst merged commit 5cf6004 into main Aug 21, 2026
28 of 29 checks passed
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