Add COG_WHEEL env var for runtime selection (cog/coglet/coglet-alpha) (#2616)
* Add COG_WHEEL env var parsing and dual wheel embedding
- Create pkg/dockerfile/wheel.go with WheelSource enum and WheelConfig
- Add ParseCogWheel() to parse COG_WHEEL env var values:
cog, coglet, coglet-alpha, URLs, or file paths
- Add GetWheelConfig() to determine wheel based on COG_WHEEL and cog_runtime flag
- Create pkg/wheels/ package with simple go:embed for cog.whl and coglet.whl
- Add script/generate-wheels to build both wheels to dist/ and copy to pkg/wheels/
- Add script/build-coglet-server for linux/amd64 coglet Go binary
- Simplify Makefile: remove complex wheel targets, use go generate
- Update StandardGenerator and migrator to use wheels.ReadCogWheel()
Closes cog-mrj, cog-a86, cog-i3w
* Integrate COG_WHEEL env var into StandardGenerator
Refactor installCog() to dispatch based on GetWheelConfig():
- installEmbeddedCogWheel() for COG_WHEEL=cog (default when cog_runtime: false)
- installEmbeddedCogletWheel() for COG_WHEEL=coglet
- installCogletAlpha() for COG_WHEEL=coglet-alpha (default when cog_runtime: true)
- installWheelFromURL() for COG_WHEEL=https://...
- installWheelFromFile() for COG_WHEEL=/path/to/file.whl
Backwards compatible: existing behavior unchanged without COG_WHEEL set.
Closes cog-1xb
* Add tests for COG_WHEEL env var scenarios
Test coverage for all COG_WHEEL values:
- Default with cog_runtime: false -> embedded cog wheel
- Default with cog_runtime: true -> coglet-alpha (PinnedCogletURL)
- COG_WHEEL=cog -> embedded cog wheel (overrides cog_runtime)
- COG_WHEEL=coglet -> embedded coglet wheel
- COG_WHEEL=coglet-alpha -> PinnedCogletURL
- COG_WHEEL=https://... -> URL install (with/without coglet env vars)
- COG_WHEEL=/path/to/file.whl -> local file install
Closes cog-6q8
* Move WheelConfig and parsing from dockerfile to wheels package
Better separation of concerns - wheel selection logic belongs
with wheel embedding, not Dockerfile generation.
* Fix CI: support pre-built wheels and add uv to test-go job
- Update generate-wheels to use COG_WHEEL/COGLET_WHEEL env vars if set
- Add astral-sh/setup-uv@v7 to test-go job for coglet wheel building
* Move compatgen to manual script, keep wheels in go:generate
- Remove go:generate directives from pkg/config/compatibility.go
- Add script/generate-compat for manual matrix regeneration
- Document in CONTRIBUTING.md when/how to update compatibility matrices
This speeds up 'go generate ./...' by only running wheel generation,
not the slow compatgen tool that rarely needs to run.
* Fix coglet wheel to include embedded Go binary
- Update package-data pattern in coglet/pyproject.toml to match
bin/coglet-server-* instead of cog-*
- Fix gocritic appendAssign lint error in installWheelFromURL
* Simplify wheel build and embed workflow
- Add script/build-wheels to build both cog and coglet wheels to dist/
- Replace go:generate script call with simple cp commands
- Delete script/generate-wheels (no longer needed)
- Add 'make wheel' target
- Simplify CI: use merge-multiple to download all artifacts at once
- Remove COG_WHEEL/COGLET_WHEEL env var setup from CI jobs
* Fix Makefile to use glob for versioned wheel names
* Preserve wheel filenames using embed.FS for PEP 427 compliance
pip requires wheel filenames to follow PEP 427 format (e.g.,
cog-0.16.10-py3-none-any.whl). Previously we renamed wheels to simple
names (cog.whl) which pip rejected.
Switch from []byte embedding to embed.FS which preserves the original
versioned filenames. Panic instead of returning error since missing
wheels indicate a broken build.
* Add CI matrix to run integration tests against both cog and coglet runtimes
* Fix coglet runtime boot failures
- Fix binary path in go_cog.py to use cog/bin/coglet-server-{os}-{arch}
- Add 'pip uninstall cog' before coglet install to avoid conflicts with
pre-installed cog in base images (e.g. r8.im/cog-base)
- Add wheel count assertion to prevent stale wheels from being embedded
- Clean old wheels in build-wheels script before building new ones
* CI: Add coglet-alpha to matrix, fail limits for coglet variants
---------
Co-authored-by: Michael Dwan <mdwan@cloudflare.com>
Co-authored-by: Mark Phelps <209477+markphelps@users.noreply.github.com>