test(build): run Go integration tests against a real BuildKit
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- docker, github-actions, go
- Domain
- build-system, ci-cd, testing
Research direction
Start with pkg/build/build_test.go, the Dockerfile, and the Makefile; compare dalec's test/testenv/buildx.go and build.go for the BuildKit connection and frontend-input flow. Then implement the tagged integration package and four fixture tests, add make test-integration, CI, and guidance in docs/development.md. Done means the integration tests pass on default and selected builders, CI runs them, and go test ./... still works without Docker.
Written by the indexing model from the issue text.
Description
Problem
AgentKit's Go tests for the build (pkg/build/build_test.go) use fakeBuildClient, a stand-in for BuildKit. They're fast, but they can't show what BuildKit actually does with AgentKit's output:
- the image settings that get exported;
- the files that end up in the image;
- multi-platform results;
- attestations;
- build steps that run commands;
- network settings and cache behavior.
Real builds are only checked by shell scripts and CI jobs (scripts/*.sh and the Docker jobs in .github/workflows/ci.yml). Those need make build-agentkit to build the frontend image and --load it first. Their checks are written in bash, and they're slow to extend.
Several planned features can only really be proven against a real BuildKit:
| Issue | What only a real build can show |
|---|---|
| #55 | the attestation is attached |
| #57 | test steps run with network off, and the image stays unchanged |
| #58 | what --call actually returns |
| #61 | the cache is reused |
| #62 | what the debug target actually outputs |
| #63 | npm scripts really run offline |
| #64 | the runtime image is swapped |
dalec solves this with Go integration tests that use a real BuildKit through the current docker buildx builder:
- each test builds the frontend from the repo's source inside BuildKit and hands it in directly, so no frontend image is built, pushed or loaded first;
- the test then checks the real result in Go.
See dalec's test/testenv/:
buildx.goconnects throughdocker buildx dial-stdio;build.gobuilds the frontend (buildBaseFrontend) and passes it in (injectInput,withDalecInput).
What
- A new test package, for example
test/integration/, behind a build tag (//go:build integration). Plaingo test ./...stays fast and keeps working without Docker. make test-integrationruns it against the current buildx builder. An env var such asAGENTKIT_TEST_BUILDERpicks a different builder, for example a remote one.- A small helper (
test/integration/testenv) that:- connects to the builder through
docker buildx dial-stdio; - builds the AgentKit frontend from the repo's
Dockerfileinside BuildKit; - builds a given Agentkitfile with that frontend and returns the result so tests can read files, image settings and metadata.
- connects to the builder through
- First tests, covering what exists today:
test/agentkitfile-hello.yamlbuilds. The image settings have user1000:1000, the right entrypoint, the exposed ports and the AgentKit labels./agent/agent.yamlin the image matchesabi.Render.- Instructions from a file in the build context end up in
/agent/agent.yaml. - A two-platform build returns one image per platform and the right platform list.
- An invalid Agentkitfile fails with the expected message.
- A CI job that runs these tests on a
docker-containerbuilder. - Future feature PRs (#55, #57, #58, #61, #62, #63, #64) add their tests here.
Runtime images in tests
A real agent build starts from a runtime image.
- Tests that don't run the agent: use the published runtime image pinned by digest, or a tiny stand-in image, to keep them fast.
- Tests that do run the agent, such as #57: build the runtime image from
runtimes/<runtime>/Dockerfilein the same BuildKit and pass it in through theagentkit-runtimebuild context from #64.
Out of scope
- Measuring code coverage of the frontend while it runs inside BuildKit. Dalec does this in
test/testenv/frontend_coverage.go; it's a good follow-up. - Replacing the existing shell smoke tests. They can move over gradually.
License note
Dalec is Apache-2.0 and AgentKit is MIT. Prefer writing the small helper fresh with dalec as a guide. If you copy code, keep dalec's license notice with it.
Why
- New features can be proven against a real BuildKit, in Go, next to the code they test.
- No frontend image has to be built, loaded or pushed before testing.
- It works with any builder, including remote ones.
- Bugs that only show up in real builds get caught early, such as missing attestations, wrong image settings or broken multi-platform output.
How
Where things are
| File | What it does |
|---|---|
pkg/build/build_test.go |
Today's tests with fakeBuildClient. Keep them. |
Dockerfile |
Builds the frontend: a static Go binary at /bin/agentkit in an empty image. |
Makefile |
build-agentkit, build-test-agent. Add test-integration. |
.github/workflows/ci.yml |
Docker jobs. Actions are pinned by commit SHA; do the same. |
dalec test/testenv/buildx.go |
dialStdio: connecting to a buildx builder, including keepalive so a dead connection is noticed. |
dalec test/testenv/build.go |
buildBaseFrontend, injectInput, withDalecInput, withProjectRoot, testWriter. |
Steps
- Connect.
- Start
docker buildx dial-stdio, adding--builder <name>whenAGENTKIT_TEST_BUILDERis set. - Create a BuildKit client over it with
client.New(ctx, "", client.WithContextDialer(...)). - If
docker buildxisn't available, skip with a clear message.
- Start
- Build the frontend.
- Inside a
client.Build(...)call, solve the repo'sDockerfilewith BuildKit's built-indockerfile.v0frontend, using the repo root as the local context. - Dalec's
withProjectRootshows how to find the root.
- Inside a
- Hand it in and build the fixture.
- Add the frontend result as an input:
SolveRequest.FrontendInputs[id]plusFrontendOpt["context:"+id] = "input:"+id. - Then solve with
Frontend: "gateway.v0"andFrontendOpt["source"] = id. - Point the
contextanddockerfilelocal inputs at the fixture folder, and setFrontendOpt["filename"].
- Add the frontend result as an input:
- Read results. Add small helpers that:
- read a file from a result with
ref.ReadFile; - decode the image settings from metadata
exptypes.ExporterImageConfigKey(per platform for multi-platform builds); - read the platform list from
exptypes.ExporterPlatformsKey.
- read a file from a result with
- Logs. Collect build output and print it with
t.Logonly when a test fails, as dalec'stestWriterdoes. - CI.
- Add a job that uses
docker/setup-buildx-action(pinned by SHA) to create adocker-containerbuilder, then runsmake test-integration. - Run actionlint after editing workflows (see
AGENTS.md).
- Add a job that uses
- Docs. Add a section to
docs/development.mdon running the tests locally, choosing a builder, and adding a test for a new feature.
Tests
The four tests listed under What are the deliverable. Run:
go test ./... # unchanged; needs no Docker
make test-integration # new; needs docker buildx
make lint
Done when
make test-integrationpasses locally on Docker's default builder and on adocker-containerbuilder, without building or loading the frontend image first.AGENTKIT_TEST_BUILDERpoints the tests at another builder.- CI runs the integration tests.
go test ./...still runs without Docker.docs/development.mdexplains how to run and extend the tests.
- Dominant language
- Python
- Stars
- 7
- Forks
- 5
- Avg merge
- 3h 39m
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Possibly taken @gambtho claimed this 30 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
orka-agents/agentkit#77 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
orka-agents/agentkit#76 · 3 comments ·
-
area/build area/orka area/runtime blocked enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficulty 4/5 3-5 days Newbie friendliness 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
orka-agents/agentkit#64 ·
All issues in orka-agents/agentkit
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 62/100
DaoCloud/DaoCloud-docs#7839 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
sav-oss-org/ptusa_main#1610 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug status/accepted type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/apm#4925 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sagemathinc/sagebrush#1701 ·
Maintainers usually reply within 1 day