Skip to content

Scope deploy/publish/images to dev registry by default#25

Open
cardil wants to merge 3 commits intomainfrom
bugfix/scope-deploy-to-dev-registry
Open

Scope deploy/publish/images to dev registry by default#25
cardil wants to merge 3 commits intomainfrom
bugfix/scope-deploy-to-dev-registry

Conversation

@cardil
Copy link
Copy Markdown
Owner

@cardil cardil commented Apr 2, 2026

Summary

  • Renamed E2E_IMAGE_BASENAME to DEV_IMAGE_BASENAME in .env
  • Split setupKoEnv into setupKoEnvDev (for deploy/publish/images/e2e) and setupKoEnvProd (for release)
  • ./goyek deploy now targets the dev registry by default — production is gated behind ./goyek release
  • Removed dead localhost:5001 fallback code from e2e config
  • Added user.env override support (loaded before .env, gitignored)

Assisted-by: 🤖 Claude Opus/Sonnet 4.6


Summary by cubic

Defaulted deploy/publish/images to the dev registry via DEV_IMAGE_BASENAME; production pushes now require ./goyek release. KO_DOCKER_REPO is honored (and synced to DEV_IMAGE_BASENAME), user.env overrides are supported, and the localhost registry fallback is removed.

  • Migration
    • Set DEV_IMAGE_BASENAME in user.env or .env to your dev/test registry (required for e2e).
    • Use ./goyek release for production; ./goyek deploy, ./goyek publish, and ./goyek images target the dev registry.
    • Update any CI/scripts that set E2E_IMAGE_BASENAME to use DEV_IMAGE_BASENAME instead.

Written for commit 5d07a47. Summary will update on new commits.

Summary by CodeRabbit

  • Chores

    • Switched development workflows to use DEV_IMAGE_BASENAME while keeping IMAGE_BASENAME for production releases.
    • Simplified E2E image handling by removing local-registry detection and loading vars from user.env and .env.
    • CI e2e workflow now exports DEV_IMAGE_BASENAME.
    • Added user.env to .gitignore.
  • Tests

    • Improved wasmmodule reconciliation tests with richer client-backed setup.

Renamed E2E_IMAGE_BASENAME to DEV_IMAGE_BASENAME. Split setupKoEnv into Dev/Prod variants. Removed dead localhost fallback. Added user.env override support.

Assisted-by: 🤖 Claude Opus/Sonnet 4.6
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

Walkthrough

Reassigns the wasm test image basename from E2E_IMAGE_BASENAME to DEV_IMAGE_BASENAME, replaces local-registry detection with explicit dev/prod KO setup functions, adjusts dotenv loading, and removes a nil-client defensive return in the wasmmodule reconciler while updating tests to inject a fake Serving client.

Changes

Cohort / File(s) Summary
Environment Configuration
\.env, \.gitignore
Sets DEV_IMAGE_BASENAME=quay.io/cardil/knative/serving/wasm/test and removes E2E_IMAGE_BASENAME; adds build/resources/user.env to .gitignore.
Build Task Setup Functions
build/tasks/deploy.go, build/tasks/release.go
Adds setupKoEnvDev and setupKoEnvProd; deploy/undeploy/publish/images tasks now call setupKoEnvDev; release tasks call setupKoEnvProd instead of the old setupKoEnv.
E2E Test Simplification
build/tasks/test.go, test/e2e/...
Removes local-registry detection and setupE2EImageBasename; E2E tasks now use setupKoEnvDev; image-basename resolution simplified to read DEV_IMAGE_BASENAME.
Dotenv Loading
build/util/dotenv/load.go
Load now attempts to load user.env then .env explicitly (sequential godotenv loads) instead of relying on default lookup.
Reconciler & Tests
pkg/reconciler/wasmmodule/wasmmodule.go, pkg/reconciler/wasmmodule/reconciler_test.go
Removed nil-client early return in updateService; tests updated to create and inject a fake Knative Serving client for reconciler tests.
E2E test helpers
test/e2e/clients.go, test/e2e/config.go
GetE2EImageBasename signature simplified (context removed); image basename read from DEV_IMAGE_BASENAME with dotenv fallback; context parameter in callers becomes unused.
CI Workflow
.github/workflows/e2e-kind.yaml
Replaces exported E2E_IMAGE_BASENAME with DEV_IMAGE_BASENAME in e2e job step while keeping the same computed value expression.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #24: Overlaps reconciler changes—removes nil-client guard in updateService and updates tests to inject a fake Serving client.
  • PR #22: Modifies the wasmmodule reconciler's Service update path, directly related to the reconciler edits here.
  • PR #17: Adjusts release task KO environment initialization, related to the newly introduced setupKoEnvProd/setupKoEnvDev split.

Suggested labels

enhancement

Poem

🐰 I hopped through env files, sniffed each line,
Swapped E2E for DEV — now images align.
Dev and prod paths hop apart with cheer,
Reconciler trimmed, tests bring a fake peer. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Scope deploy/publish/images to dev registry by default' directly and clearly describes the main change: deploy, publish, and images tasks now target the dev registry by default instead of using environment-specific logic.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/scope-deploy-to-dev-registry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 10 files

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.98%. Comparing base (133aeb4) to head (5d07a47).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
- Coverage   51.39%   50.98%   -0.42%     
==========================================
  Files          10       10              
  Lines         358      355       -3     
==========================================
- Hits          184      181       -3     
  Misses        154      154              
  Partials       20       20              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@build/tasks/test.go`:
- Line 63: The e2e runner basename can diverge from the pushed images because
setupKoEnvDev(a) only sets KO_DOCKER_REPO; update the test task to also set
DEV_IMAGE_BASENAME to the same value when KO_DOCKER_REPO is present (or derive
DEV_IMAGE_BASENAME from the repo value) so test/e2e/config.go resolves the same
images; modify the call/site around setupKoEnvDev(a) to export
DEV_IMAGE_BASENAME (using the same string used for KO_DOCKER_REPO) or extend
setupKoEnvDev to set both env vars (referencing setupKoEnvDev, KO_DOCKER_REPO,
DEV_IMAGE_BASENAME, and test/e2e/config.go).

In `@test/e2e/config.go`:
- Line 62: The error message returned when DevImageBasenameEnv is not set should
mention both user.env and .env (in that order) since the lookup checks user.env
first; update the fmt.Errorf call that currently returns "%s is not set (check
.env or environment)" to instead reference "user.env, .env or the environment"
so the message guides users correctly when the override in user.env is missing;
modify the return where DevImageBasenameEnv is used to include the new wording.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 33dfee47-41ad-4803-a714-6e83189afb43

📥 Commits

Reviewing files that changed from the base of the PR and between 0338bb4 and ac62d02.

📒 Files selected for processing (10)
  • .env
  • .gitignore
  • build/tasks/deploy.go
  • build/tasks/release.go
  • build/tasks/test.go
  • build/util/dotenv/load.go
  • pkg/reconciler/wasmmodule/reconciler_test.go
  • pkg/reconciler/wasmmodule/wasmmodule.go
  • test/e2e/clients.go
  • test/e2e/config.go
💤 Files with no reviewable changes (1)
  • pkg/reconciler/wasmmodule/wasmmodule.go

Comment thread build/tasks/test.go
// This must be done before building images so they get tagged correctly
setupE2EImageBasename(a)
setupKoEnv(a)
setupKoEnvDev(a)
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Apr 2, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Keep the e2e runner's basename aligned with the repo you just built.

setupKoEnvDev(a) only guarantees KO_DOCKER_REPO, but the test binary resolves images from DEV_IMAGE_BASENAME. When KO_DOCKER_REPO is pre-set, this task builds and pushes to that override while test/e2e/config.go can still fall back to the basename from dotenv, so goyek e2e may validate the wrong images.

💡 Minimal fix
 			setupKoEnvDev(a)
+			a.Setenv("DEV_IMAGE_BASENAME", os.Getenv(koDockerRepo))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@build/tasks/test.go` at line 63, The e2e runner basename can diverge from the
pushed images because setupKoEnvDev(a) only sets KO_DOCKER_REPO; update the test
task to also set DEV_IMAGE_BASENAME to the same value when KO_DOCKER_REPO is
present (or derive DEV_IMAGE_BASENAME from the repo value) so test/e2e/config.go
resolves the same images; modify the call/site around setupKoEnvDev(a) to export
DEV_IMAGE_BASENAME (using the same string used for KO_DOCKER_REPO) or extend
setupKoEnvDev to set both env vars (referencing setupKoEnvDev, KO_DOCKER_REPO,
DEV_IMAGE_BASENAME, and test/e2e/config.go).

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 5d07a47. setupKoEnvDev now syncs DEV_IMAGE_BASENAME from KO_DOCKER_REPO when the latter is explicitly set, so the test binary always resolves the same images that were built and pushed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
git show 5d07a47 --stat
git show 5d07a47 -- build/tasks/deploy.go

Length of output: 1034


@cardil, confirmed — the fix in 5d07a47 looks correct. When KO_DOCKER_REPO is pre-set, setupKoEnvDev now captures its value and propagates it to DEV_IMAGE_BASENAME via a.Setenv before returning, ensuring test/e2e/config.go always resolves the same registry that images were built and pushed to.


🧠 Learnings used
Learnt from: cardil
Repo: cardil/knative-serving-wasm PR: 6
File: test/e2e/config.go:56-86
Timestamp: 2026-02-12T16:56:23.580Z
Learning: In the knative-serving-wasm project, E2E tests are executed via the goyek build system (not directly with `go test`), which sets the current working directory to the repository root before running tasks. This ensures that relative paths like `.env` in `godotenv.Read(".env")` resolve correctly to the project root.

Learnt from: cardil
Repo: cardil/knative-serving-wasm PR: 2
File: build/tasks/deploy.go:0-0
Timestamp: 2025-06-27T20:04:53.653Z
Learning: In the knative-serving-wasm project, environment variables like IMAGE_BASENAME are managed through a `.env` file that provides default values, and `build/util/dotenv/load.go` provides a goyek.Executor wrapper that loads these environment variables before task execution. This ensures environment variables are always available when build tasks run, eliminating the need for validation in individual task functions.

If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

Comment thread test/e2e/config.go Outdated
…essage

Assisted-by: 🤖 Claude Opus/Sonnet 4.6
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