🤖 feat: add local dev workflow, envtest integration tests, and Kind e2e CI#8
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a8532faae
ℹ️ 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".
|
@codex review Addressed feedback: switched |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df375b51b6
ℹ️ 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".
|
@codex review Fixed README to mention the |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
d01b41f to
21bcb53
Compare
Summary
Add complete local cluster development workflow, envtest integration testing, and CI coverage for the
coder-k8soperator.Background
The repo had kubebuilder markers in API types and RBAC markers in the controller, but no CRD YAML manifests, no integration tests, no local dev workflow documentation, and no CI envtest or e2e coverage. This PR addresses all of those gaps.
Implementation
Phase 1: Manifest generation pipeline
sigs.k8s.io/controller-tools v0.20.0as a vendored dependency (viainternal/deps/controllergen_tools.gobuild-tagged file)hack/update-manifests.shscript with fail-fast assertions (mirrors existinghack/update-codegen.shpattern)make manifeststargetconfig/crd/bases/), RBAC (config/rbac/), and sample CR (config/samples/)Phase 2: envtest integration tests
internal/controller/suite_test.go— envtestTestMainlifecycle harness with scheme registration and defensive assertionsinternal/controller/codercontrolplane_controller_test.go— 4 integration test cases:TestReconcile_NotFound— reconcile non-existent CR returns nilTestReconcile_ExistingResource— reconcile existing CR returns nilTestReconcile_NilClient— assertion error on nil clientTestReconcile_NilScheme— assertion error on nil schememake setup-envtestandmake test-integrationtargetsmake testto automatically set up envtest assetsPhase 3: CI updates
testjob to install envtest assets and exportKUBEBUILDER_ASSETSe2e-kindjob: creates Kind cluster, builds/loads image, deploys controller with CRDs/RBAC/e2e manifests, applies sample CR, and verifies resource existsDocumentation
README.mdwith: project description, prerequisites, OrbStack quick start, essential commands, testing strategy, and project structure sectionsRisks
setup-envtest@release-0.23uses a branch ref rather than a pinned commit. This tracks the controller-runtime v0.23.x release branch. Could be pinned to a pseudo-version if strict immutability is desired.e2e-kindjob assumesjqis present onubuntu-latest(currently true).📋 Implementation Plan
Implementation Plan: Local cluster development + integration/e2e testing for
coder-k8sContext / Why
You want a concrete execution plan an agent can follow to: (1) develop quickly against a local Kubernetes cluster, (2) add reliable integration testing, and (3) add CI coverage in GitHub Actions. The current repository is scaffold-level, so the plan prioritizes a fast inner loop first (OrbStack), then deterministic tests (
envtest), then a real-cluster smoke test (Kind in CI).This plan explicitly addresses your CRD note: the API types/markers exist, but generated CRD YAML manifests are not currently present in the repo.
Evidence
api/v1alpha1/codercontrolplane_types.gocontains kubebuilder markers (+kubebuilder:resource,+kubebuilder:subresource:status) and CRD types.hack/update-codegen.shonly runsdeepcopy-gen; no CRD/manifest generation.Makefilehastest/build/lint/vuln/codegenbut nomanifests,install, or integration/e2e targets..github/workflows/ci.yamlruns lint/unit/build checks only; no envtest/Kind job.main.gousesctrl.GetConfigOrDie(), so local out-of-cluster runs depend on kubeconfig context.main_test.gocurrently contains unit-style checks only.config/crdor sample manifests (YAML files are only workflows/tooling YAML plus vendor files).These files are sufficient to design a full implementation path.
Implementation details
Planned edit map (ordered)
internal/deps/deps.go— import block: add blank import forsigs.k8s.io/controller-tools/cmd/controller-gen(vendoring anchor).hack/update-manifests.sh(new) — script entrypoint + fail-fast assertions +controller-geninvocation.Makefile—.PHONYlist + new targets:manifests,setup-envtest,test-integration.config/crd/bases/*,config/rbac/*,config/samples/*(new/generated) — committed generated manifests + sample CR.README.md— new “Local development (OrbStack)” and “Testing strategy” sections.internal/controller/suite_test.go(new) —TestMainenvtest lifecycle harness.internal/controller/codercontrolplane_controller_test.go(new) — integration tests aroundReconcileassertions and not-found/exists flows..github/workflows/ci.yaml—testjob envtest setup; newe2e-kindjob.test/e2e/*orconfig/e2e/*(new) — minimal Kind smoke deployment/test assets.Phase 1 — OrbStack-first local development workflow (recommended first)
Add manifest generation pipeline (CRD/RBAC) and commit generated outputs.
internal/deps/deps.goto keepcontroller-toolsvendored, then rungo mod tidy && go mod vendor.hack/update-manifests.shwith fail-fast assertions and deterministic output directories.Makefiletargetmanifestsand wire it into local docs/CI checks where appropriate.config/crd/bases/coder.com_codercontrolplanes.yamlconfig/rbac/role.yaml(and related generated RBAC if produced)config/samples/coder_v1alpha1_codercontrolplane.yamlAdd a simple OrbStack local-dev runbook in
README.md.make manifests kubectl apply -f config/crd/bases/ GOFLAGS=-mod=vendor go run . kubectl apply -f config/samples/coder_v1alpha1_codercontrolplane.yaml kubectl get codercontrolplanes -AAcceptance criteria (Phase 1).
CoderControlPlane.Phase 2 — Add
envtestintegration tests (highest-value test investment)Create envtest suite harness for controller package.
internal/controller/suite_test.gothat starts/stopsenvtest.Environment.client-goandcoderv1alpha1schemes and construct a controller-runtime client.Add reconciliation integration tests in
internal/controller/codercontrolplane_controller_test.go.Clientis nil.Schemeis nil.Add explicit Make targets for integration tests + envtest binary setup.
make setup-envtestmake test-integrationAcceptance criteria (Phase 2).
make test(or split unit/integration pair) passes locally with vendoring.Phase 3 — CI updates (GitHub Actions)
Extend existing
testjob in.github/workflows/ci.yamlto run envtest-backed tests.KUBEBUILDER_ASSETS.go test ./...withGOFLAGS=-mod=vendor.Add separate Kind-based smoke e2e job (new job, not replacement).
e2e-kindjob aftertest.helm/kind-action(or equivalent pinned action) to create ephemeral cluster.Acceptance criteria (Phase 3).
test) or cluster packaging/deploy broke (e2e-kind).Phase 4 — Optional DevSpace/Tilt layer (defer unless team asks)
devspace.yaml(orTiltfile) that wraps the same manifests and image build path used in CI.Why deferred
This repo currently has a minimal reconciler and no complex dependent resources yet. Adding DevSpace/Tilt immediately would increase maintenance surface before there is enough deployment complexity to justify it.Execution order (for agent handoff)
Validation checklist the implementing agent must run
make verify-vendormake manifests(new target)make testmake buildgo run github.com/rhysd/actionlint/cmd/actionlint@v1.7.10Generated with
mux• Model:anthropic:claude-opus-4-6• Thinking:xhigh• Cost:$0.68