Skip to content

Modernize code samples and add deployment E2E CI - #6748

Open
dprotaso wants to merge 44 commits into
knative:mainfrom
dprotaso:modernize-code-samples
Open

dprotaso wants to merge 44 commits into
knative:mainfrom
dprotaso:modernize-code-samples

Conversation

@dprotaso

@dprotaso dprotaso commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Update and simplify code samples, with directory-scoped deployment E2E CI. Commits are organized as CI setup → one commit per sample → shared cleanup.

CI and cleanup

  • PR-only samples-test discovers changed sample directories through ci.sh; main() runs build, deploy, and test on kind/Kubernetes 1.36.
  • 25 samples have automated coverage, including Python's Broker/Trigger/reply flow. Samples without ci.sh are explicitly NOT TESTED by CI.
  • Add Docker image updates through Dependabot; remove obsolete shared sample tests, duplicate index pages, unused wrappers, and unnecessary ignore files.
  • Preserve public application image names, required dependency locks/bindings, and docs-root Python/tooling settings.

Sample changes

Community

  • Clojure: Clojure 1.12.6/Ring 1.15.6, Java 25, and a simpler deterministic JAR build.
  • Dart: Honor TARGET, remove unused test dependencies, and add HTTP smoke CI.
  • Elixir: Update Phoenix/Elixir, simplify release/assets builds, and use a demonstration signing key without Secret setup.
  • Haskell: Update GHC/Cabal builds, freeze dependencies, and pin the multi-architecture builder image.
  • Micronaut: Update the framework and Java 25 Maven/JRE build; verify HTTP deployment.
  • Quarkus: Update the framework/Java 25 fast-JAR build and inline startup without a wrapper script.
  • R server: Use R 4.6.1/Plumber with standard package installation and HTTP smoke CI.
  • Rust Hello World: Fix the greeting, enforce locked Cargo builds, and add HTTP smoke CI.
  • Swift: Replace the old implementation with Swift/Hummingbird and locked dependencies.
  • Vert.x Hello World: Refresh Vert.x/Java 25 builds and verify the HTTP service.

Eventing

  • Bookstore: Refresh application dependencies/SDK handling, fix response serialization, and simplify function directory names.
  • GitHub Source: Correct checked-in manifest usage and webhook/log verification instructions.
  • GitLab Source: Make inline deployment commands runnable and refresh controller/webhook/event instructions.
  • Python Hello World: Use Python 3.14.9, Gunicorn, and the official CloudEvents SDK with real Broker/reply E2E CI.
  • Kafka Channel: Add native Channel, ApiServerSource, RBAC, and Subscription manifests; correct channel defaults.
  • Parallel: Consolidate both routing configurations around one Go CloudEvents SDK helper and shared resources.
  • JavaScript event source: Fix CloudEvents emission/error handling and simplify ContainerSource/SinkBinding instructions.

CloudEvents receivers

  • .NET: Move to .NET 10 and refreshed ASP.NET CloudEvents bindings, with receiver smoke CI.
  • Go: Consolidate Serving/Eventing receivers with SDK reply/sink modes and standard Docker builds.
  • Node.js: Refresh runtime/SDK dependencies and CloudEvents request/response handling.
  • Rust: Refresh SDK/Actix dependencies and build a static runtime image.
  • Spring: Refresh Spring/CloudEvents bindings and build configuration.
  • Vert.x: Refresh Java/CloudEvents SDK integration and build configuration.

Serving

  • Git webhook Go: Use Go 1.27, honor PORT, and support an explicit GitHub API endpoint.
  • gRPC ping Go: Use Go 1.27, honor PORT, and clarify plaintext/TLS client usage.
  • C# Hello World: Move to .NET 10 with updated container builds and HTTP smoke CI.
  • Go Hello World: Align Go 1.27 builds, add HTTP smoke CI, and correct its article link.
  • Spring Hello World: Update Spring/Java 25 and simplify the Maven/JRE container build.
  • Kotlin: Update Kotlin/Ktor/Java 25 and simplify Gradle configuration while retaining stable launcher names.
  • Node.js Hello World: Refresh Node/Express dependencies and container builds, with HTTP smoke CI.
  • PHP: Use PHP 8.5/Apache with PORT-aware startup and HTTP smoke CI.
  • Python Hello World: Use Python 3.14.9, Flask/Gunicorn, and HTTP smoke CI; align both sample Python Docker bases.
  • Ruby: Use Ruby 4, refresh Sinatra/Rack dependencies, and add HTTP smoke CI.
  • Shell: Retain BusyBox CGI, honor PORT, and verify the greeting through HTTP smoke CI.
  • Go routing: Reuse the canonical Go Hello World application instead of duplicating its source.
  • Multi-container: Align Go 1.27 builds and fix sidecar communication, port handling, and errors.
  • Secrets Go: Read a mounted Kubernetes Secret file instead of depending on Google Cloud Secret Manager.
  • Tag-header routing: Wait for the first revision before creating the second and derive the actual ingress Host.
  • WebSockets Go: Align Go 1.27 builds and correct deployment documentation/links.

Validation

Retained sample implementations and the sample-CI workflow are unchanged from the fully passing previous run. Checks are rerunning after rebasing onto current main.

Retired samples were removed by the merged #6725, #6726, #6727, #6728, #6729 and #6747; this PR preserves those deletions.

@knative-prow knative-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 25, 2026
@knative-prow

knative-prow Bot commented Oct 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for knative ready!

Name Link
🔨 Latest commit 0666039
🔍 Latest deploy log https://app.netlify.com/projects/knative/deploys/6ae016ad3b900252d9797614
😎 Deploy Preview https://deploy-preview-6748--knative.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@knative-prow knative-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 25, 2026
Comment thread .github/workflows/samples-test.yaml Outdated
Comment thread .github/workflows/samples-test.yaml Outdated
Comment thread .github/workflows/samples-test.yaml Outdated
Comment thread .github/workflows/samples-test.yaml Outdated
Comment thread .github/workflows/samples-test.yaml Outdated
Comment thread code-samples/serving/hello-world/helloworld-python/requirements.in Outdated
Comment thread code-samples/serving/hello-world/helloworld-ruby/Dockerfile Outdated
Comment thread code-samples/serving/hello-world/helloworld-shell/Dockerfile
Comment thread code-samples/serving/secrets-go/Dockerfile Outdated
Comment thread docs/versioned/bookstore/page-1/send-review-comment-to-broker.md
@dprotaso
dprotaso force-pushed the modernize-code-samples branch from a5c63d4 to 447a551 Compare October 26, 2026 13:17
@dprotaso
dprotaso marked this pull request as ready for review October 26, 2026 13:31
@dprotaso dprotaso changed the title [WIP] Modernize code samples and add deployment E2E CI Modernize code samples and add deployment E2E CI Oct 26, 2026
@knative-prow knative-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 26, 2026

@dsimansk dsimansk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. E2E workflow now tests nothing — test/e2e-tests.sh:34

The script still installs Istio + latest Knative Serving and runs go_test_e2e ./test/e2e, but this PR deleted every test in that package (only an empty package e2e stub remains in test/e2e/main.go). Every presubmit spends minutes standing up a cluster and executes zero tests — green but verifying nothing.

  1. Rust CloudEvents sample swallows bad PORT — code-samples/serving/cloudevents/cloudevents-rust/src/main.rs:87

port() does value.and_then(|v| v.parse().ok()).unwrap_or(8080), so PORT="8080x" silently binds 8080. Knative's queue-proxy and probes target the injected port, so the revision never goes Ready with no log explaining why. The sibling Vert.x sample rejects bad input — this one should too (or at least log).

  1. Lost README-vs-source consistency guard — test/sampleconsistency/ (deleted)

The deleted sample-consistency suite enforced that README instructions matched the actual source/Dockerfile/service.yaml. The new samples-test.yaml workflow only runs samples that have a ci.sh and logs "NOT TESTED (no ci.sh)" for the rest (e.g. helloworld-java-spark, helloworld-scala). README drift in those samples now goes uncaught until a user follows broken instructions.

@evankanderson evankanderson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is pretty hard to review in any detail, FWIW. It seems like most of the index.md files have been rewritten as well as moved to README.md, and most of the apps have been rewritten (updated)?

More fundamentally, this makes me wonder whether having sample HTTP server containers for every programming language even makes sense.

Comment thread .github/workflows/samples-test.yaml Outdated
Comment on lines +35 to +40
collisions=$(find code-samples -type f -name ci.sh -print0 |
jq -Rs 'split("\u0000")[:-1] | map(split("/")[-2]) | group_by(.) | map(select(length > 1) | .[0])')
echo "directories=$(jq -cn --argjson collisions "$collisions" --args '
$ARGS.positional | unique | map(split("/") as $path |
{directory: ., name: (if $collisions | index($path[-1])
then $path[1] + "/" + $path[-1] else $path[-1] end)})' "${directories[@]}")" >> "$GITHUB_OUTPUT"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand what "collisions" is doing, and this is some unholy mix of bash and JQ that feels like it should be a real script.

If I'm reading correctly, it looks like "collisions" is supposed to be all the parent directories of ci.sh files where at least two children were changed. It's not not clear to me why we need that, though. (And IMO, cut and uniq would be clearer than map | group_by | map(select).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is essentially saying - find all the directories that have ci.sh scripts and compare it to the changed files in the PR. When there is a match then it's a candidate for the samples-e2e test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let me see if we can simplify this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done - the logic it had before was trying to be smart about handling dirs since we have two code-samples with the same child folder name

eg. serving/helloworld-python and eventing/helloworld-python

I dropped some requirement and it should be simpler now

Comment on lines +50 to +59
matrix:
include: ${{ fromJSON(needs.discover.outputs.directories) }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- uses: chainguard-dev/actions/setup-kind@8f31e9482b447ff2c69eca944a09b4b31a4a85d0
with:
k8s-version: 1.36.x

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're setting up a kind cluster and installing serving once for each changed samples directory? That seems like potentially a lot of clusters.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oddly i agree but it seems like github is handling well - eg. see checks in this PR it is running all of the code-sample e2e tests. Those are really just a light smoke test that the docker file builds and it can deploy.

I was expecting dependabot updates to really trigger one or two code-samples at most.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It feels like we need some meta-documentation (CONTRIBUTING.md or docs/contributing) about how this CI works. If I'm reading it correctly, it spins up a Kind cluster for each sample, loads serving (but not eventing) into the cluster, and then runs a CI script with a port-forwarder to see if whatever is loaded into the cluster is responding / working.

@dprotaso dprotaso Oct 27, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It should also install eventing for the samples that need it (eg. eventing - python example)

Let me revisit that

@dprotaso

dprotaso commented Oct 27, 2026 •

Copy link
Copy Markdown
Member Author

This is pretty hard to review in any detail

Yeah it was either a giant PR and many small ones. The benefit of the big one was coordinating the ci changes and seeing everything pass. Let me know what folks prefer to make reviews easier.

It seems like most of the index.md files have been rewritten as well as moved to README.md,

The index.md files were duplicates of README.md. We used to render them as pages on the site, but stopped doing that a long time ago. Now we link to the root of each code sample on GitHub, which displays its README.md.

For example: index.md and README.md.

and most of the apps have been rewritten (updated)?

Yes—by “modernized,” I mean bumping dependencies and updating the code accordingly.

More fundamentally, this makes me wonder whether having sample HTTP server containers for every programming language even makes sense.

Yeah i never questioned why we have it or who uses it :/ - I'm flexible here. Also note - I'm hoping with the skip-review changes and dependabot + CI checks will make keeping these on auto-pilot.

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

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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.

3 participants