Skip to content

chore: remove examples and compile docs snippets in CI - #1298

Open
dreamorosi wants to merge 17 commits into
developfrom
chore/remove-examples-compile-snippets
Open

dreamorosi wants to merge 17 commits into
developfrom
chore/remove-examples-compile-snippets

Conversation

@dreamorosi

@dreamorosi dreamorosi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Issue number: closes #1304

Summary

Changes

Removes examples/ and makes the docs snippets the single source of sample code, now compiled in CI.

The examples weren't used by the docs build, duplicated what the snippets show, and their CDK app (examples/Event Handler/BedrockAgentFunction/infra) caused 22 of the repo's open Dependabot alerts and most of the recent Dependabot PRs.

Compiling the snippets. None of the 72 .cs files under docs/snippets compiled before this PR. docs/snippets/Snippets.csproj now builds all of them against libraries/src. Most of the diff in docs/snippets is scaffolding outside the --8<-- regions, so the docs don't show it. That includes wrapper types, per-region namespaces and Support.cs stand-ins. Where a wrapper has to open inside a region, it goes on a line marked // --8<-- [start:hidden], which pymdownx.snippets drops. The project always builds the libraries in Release without transitive references, so snippets compile against the same layout as the published packages.

Docs bugs found by compiling. Visible changes are limited to return statements, ... becoming // ..., and real fixes. Notable ones:

  • Idempotency: the response hook example used Idempotency.Config()/WithConfig/Builder(), which don't exist. It now uses Configure/WithOptions/UseDynamoDb.
  • Bedrock Agent: the examples used ActionGroupInvocationInput/Output and set read-only response properties. They now use BedrockFunctionRequest/BedrockFunctionResponse.WithText(...).
  • Kafka:
    • The testing sample relied on internal APIs. It now builds records through the serializer.
    • [Idempotent] was on a void method, which throws at runtime.
  • Metrics:
    • MetricsMiddleware doesn't exist. The listing of the UseMetrics implementation was removed; the prose already explains it.
    • An unquoted Namespace = ExampleApplication is now a string, and a missing .Build() was added.
  • Logging: loggerFactory.Create (and oggerFactory) are now LoggerFactory.Create. The IConsoleWrapper test double was missing members.
  • Batch: the examples used exception types that are internal to the library.
  • AppSync Events: an undefined variable pd and a missing ); are fixed.
  • Parameters, tracing: smaller syntax fixes.

hl_lines were adjusted where line positions moved.

CI.

  • examples-tests.yml is replaced by docs-snippets.yml. It builds the snippets on PRs that touch docs/snippets/** or libraries/src/**.
  • publish-artifacts-examples-tests.yml is renamed to publish-artifacts.yml. Before publishing to GitHub Packages, it now swaps the snippets' project references for the freshly packed .nupkgs and builds them, instead of running the example tests. I ran this flow locally, and the snippets build against the packed packages.

Other cleanup.

  • Links to examples/ removed from README.md, docs/index.md, the batch, bedrock and kafka pages, and three package READMEs.
  • Kafka page: the "Full examples on GitHub" tip is replaced with short instructions for generating Avro/Protobuf classes.
  • Removed the root Dockerfile, which built a SimpleLambda example that no longer exists.
  • Removed stale examples entries from package.json and .gitignore.

User experience

Readers see the same snippets as before, with the fixes above. The standalone sample projects in examples/ are gone; each utility's docs page is now the reference.

Checklist

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The examples duplicated the docs snippets, were not referenced by the docs
build, and their CDK app was the largest source of Dependabot alerts. The
package publishing workflow now verifies the packed NuGet packages by
building the docs snippets against them instead of running example tests,
and a new workflow builds the snippets on changes to them or the libraries.
Compile batch, idempotency, JMESPath and metadata examples with invisible scaffolding.
Replace obsolete idempotency builder calls and inaccessible batch exceptions.
Avoid duplicate JMESPath types in Release.
Wrap top-level-statement regions in namespaces and a static method so they
compile in the snippets library. The wrapper's opening line carries a
"hidden" snippet marker so the rendered docs stay unchanged.

Move the class library and idempotency regions (file-scoped namespaces)
into their own files and compile out their [assembly: LambdaSerializer]
attributes. Add stand-ins for generated and domain types in Support.cs.

Fix docs bugs: missing return in record_metadata, invalid private local
functions in error_handling, ProcessPayment call/signature mismatch and
void [Idempotent] method, and a testing sample that used internal
ConsumerRecords members. Replace the examples/kafka tip with short code
generation guidance.
Wrap independent examples in isolated namespaces and supply hidden scaffolding so snippet regions remain recognizable.

Update the ASP.NET Core middleware example to use the current library API.
Wrap AppSync Events and Bedrock Agent examples in invisible compile scaffolding and fix outdated response APIs and example types.
Scope duplicate examples to separate namespaces, supply invisible compilation scaffolding, and align examples with the current logging and parameters APIs.

Reference AWSSDK.S3 for the custom provider example and alias the logging reference to disambiguate shared console interfaces.
Merge the per-area snippet fixes, always build referenced libraries in Release without
transitive references so the snippets see the published package shape, and keep reference
attributes when the publish workflow swaps them for packages.
Snippet namespaces under AWS.Lambda.Powertools shadowed the Metrics, Tracing and
Idempotency classes and needed aliases. Use Docs.<Area>Snippets instead.
Restore the using directives shown inside regions, using compile-only
lines with a hidden snippet marker where a wrapper class or method is
needed. Drop the extra md includes that split regions apart.

Revert scaffolding artifacts that showed in the docs: partial classes,
helper methods added to visible classes, renamed serializer contexts
(aliases outside the region instead), stray closing braces, duplicated
usings, and mis-indented return statements.

Update hl_lines in tracing and logging where added lines moved the
highlighted lines.
The listing showed library internals that can't be reproduced in user code. The prose
above it already explains what the middleware does.
@boring-cyborg boring-cyborg Bot added area/metrics Core metrics utility area/tracing Core tracing utility documentation Improvements or additions to documentation labels Nov 14, 2026
@boring-cyborg boring-cyborg Bot added github-actions Changes in GitHub workflows internal Maintenance changes labels Nov 14, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 14, 2026
@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.46%. Comparing base (8ed72cd) to head (732ce88).
⚠️ Report is 40 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1298   +/-   ##
========================================
  Coverage    79.46%   79.46%           
========================================
  Files          302      302           
  Lines        12662    12662           
  Branches      1507     1507           
========================================
  Hits         10062    10062           
  Misses        2142     2142           
  Partials       458      458           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

#1273 bumped only codeql-action/autobuild to v4.38.0, so the CodeQL job fails with a
config version mismatch against init and analyze at v4.37.6. Pin all three to v4.38.0
and group codeql-action updates in Dependabot so they move together.

Refs #1301
@sonarqubecloud

Copy link
Copy Markdown

@dreamorosi
dreamorosi marked this pull request as ready for review November 14, 2026 12:03
@dreamorosi
dreamorosi requested a review from hjgraca November 14, 2026 12:13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/metrics Core metrics utility area/tracing Core tracing utility documentation Improvements or additions to documentation github-actions Changes in GitHub workflows internal Maintenance changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance: remove examples and compile docs snippets in CI

1 participant