mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
## What this changes
**The cause.** The pin bump in 588ba6f9 moved devvm's mise, on the host
and in VMs, from 2026.10.7 to 2026.11.3. Starting with mise 2026.10.9
(jdx/mise#14295), mise's registry puts npm first for opencode 2.x. Here
is `registry/opencode.toml` at each version:
```toml
# v2026.10.7
backends = ["aqua:anomalyco/opencode"]
# v2026.11.3
backends = [
{ full = "npm:@opencode/cli", min_version = "2.0.0", options = { allow_builds = ["@opencode/cli"] } },
"aqua:anomalyco/opencode",
]
```
devvm named opencode only as `opencode = "2"`, so mise 2026.11.3
resolved it to `npm:@opencode/cli`. That lock entry has no download for
any platform. As a result, every resolve warned that opencode 2.2.5
isn't published for every platform, opencode's tool image couldn't be
built, and the e2e check "the shared tools resolve to upstream's newest"
failed on every machine. opencode's GitHub releases still ship v2
binaries for every platform, musl included, along with a `SHA256SUMS`.
**The fix.** `assets/shared-tools/mise.toml` now has a `[tool_alias]`
table. It names the backend of every shared tool that isn't one of
mise's own `core:` tools, so the registry's choice can't move them:
- `opencode = "github:anomalyco/opencode"`: its GitHub releases. With
mise 2026.11.3, the aqua backend now gives opencode.ai URLs, and on musl
it gives the glibc tarball. The github backend gives musl VMs opencode's
own `-musl` build and records `provenance = "github-attestations"`.
- `claude`, `codex`, `pnpm` and `uv` keep the aqua backends they already
resolve to, so their lock entries are unchanged. They are named because
each of them already lists a second backend in the registry (http, npm,
npm, and asdf/pipx). That is how opencode's switch happened.
- node, bun, python, go and rust are mise's `core:` tools. None of them
changed between 2026.10.7 and 2026.11.3, so they are not aliased.
The other two places where mise picks a backend now follow the same
table:
- The step back (`lockVersions`) locks older versions from the backend
the newest one came from.
- Each project VM's `/etc/mise/config.toml` gets the same table, sent as
`tool-alias.toml` in the setup. Without it, the VM's mise 2026.11.3
reports opencode's backend as npm, and a non-shared version would be
installed from npm.
`tests/e2e-mise.lock` was resolved again with mise 2026.11.3 through
`scripts/bump.sh e2e-tools`. It now has lockfile version 4 and opencode
from GitHub. codex stays at 0.166.0, because mise's latest for codex is
still the older 0.163.0.
**The guard.** `TestToolBackendsNamed` fails in two cases: when a shared
tool that isn't on a `core:` backend has no `[tool_alias]` entry, and
when an alias isn't the backend that `tests/e2e-mise.lock` resolved. On
main it would have failed for claude, codex, opencode, pnpm and uv. The
existing download-per-platform check (`TestE2ELockPins`) couldn't catch
this regression, because the e2e lock had never been resolved again with
2026.11.3. `TestAliases` covers the VM's table, and
`TestRefreshStepsBack` now checks the step back's `mise.toml`.
Docs: internals/images.md (Versions) explains the aliases.
contributing/maintaining.md says where a new shared tool's alias goes
and what the test checks.
Co-authored-by: Claude Opus 5.5 <[email protected]>
121 lines
4.4 KiB
Go
121 lines
4.4 KiB
Go
package tools
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"maps"
|
|
"os"
|
|
"regexp"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/devvmhq/devvm/internal/image"
|
|
)
|
|
|
|
// TestMisePins checks the host's mise pins, one per host devvm runs on,
|
|
// 64 hex digits each, and that the mise base.sh installs in every VM,
|
|
// which installs the shared tools in their images, is the host's: the
|
|
// same version and, for Linux, the same checksums (scripts/bump.sh mise
|
|
// moves both).
|
|
func TestMisePins(t *testing.T) {
|
|
for _, p := range []string{"macos-arm64", "macos-x64", "linux-arm64", "linux-x64"} {
|
|
if !regexp.MustCompile(`^[0-9a-f]{64}$`).MatchString(miseSHA256[p]) {
|
|
t.Errorf("%s's checksum = %q", p, miseSHA256[p])
|
|
}
|
|
}
|
|
base := string(read(t, repo(t, "assets", "layers", "base.sh")))
|
|
v, err := image.MiseVersion(os.DirFS(repo(t, "assets")))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if v != miseVersion {
|
|
t.Errorf("base.sh pins mise %s, internal/tools/mise.go %s", v, miseVersion)
|
|
}
|
|
for arch, platform := range map[string]string{"arm64": "linux-arm64", "amd64": "linux-x64"} {
|
|
m := regexp.MustCompile(`(?m)^mise_sha256_` + arch + `=([0-9a-f]{64})$`).FindStringSubmatch(base)
|
|
if m == nil {
|
|
t.Errorf("base.sh has no mise_sha256_%s", arch)
|
|
continue
|
|
}
|
|
if m[1] != miseSHA256[platform] {
|
|
t.Errorf("base.sh's mise_sha256_%s is %s, mise.go's %s %s", arch, m[1], platform, miseSHA256[platform])
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestE2ELockPins checks e2e's pinned lock against what it pins:
|
|
// tests/e2e-mise.lock's first line names the SHA-256 of the
|
|
// shared-tools/mise.toml it was resolved from (tests/e2e stops on
|
|
// another), and it locks each of mise.toml's tools with a download for
|
|
// every platform but rust's (scripts/bump.sh e2e-tools makes it).
|
|
func TestE2ELockPins(t *testing.T) {
|
|
config := read(t, repo(t, "assets", "shared-tools", "mise.toml"))
|
|
data := read(t, repo(t, "tests", "e2e-mise.lock"))
|
|
first, _, _ := strings.Cut(string(data), "\n")
|
|
sum := sha256.Sum256(config)
|
|
if want := "# devvm e2e: shared-tools/mise.toml sha256:" + hex.EncodeToString(sum[:]); first != want {
|
|
t.Errorf("tests/e2e-mise.lock starts %q, want %q: run scripts/bump.sh e2e-tools", first, want)
|
|
}
|
|
names, _ := configTools(config)
|
|
if got := lockTools(t, data); !slices.Equal(got, slices.Sorted(slices.Values(names))) {
|
|
t.Errorf("tests/e2e-mise.lock locks %q, mise.toml has %q", got, names)
|
|
}
|
|
lock := parsed(t, data)
|
|
platforms := []string{"linux-arm64", "linux-arm64-musl", "linux-x64", "linux-x64-musl"}
|
|
for _, tool := range names {
|
|
if !lock.HasDownload(tool, platforms) {
|
|
t.Errorf("tests/e2e-mise.lock has no download of %s for every one of %q", tool, platforms)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestToolBackendsNamed checks that shared-tools/mise.toml's [tool_alias]
|
|
// names the backend of every shared tool that isn't one of mise's own
|
|
// (core:), and that it's the one tests/e2e-mise.lock resolved: mise's
|
|
// registry picks a tool's backend otherwise, and a mise release can move
|
|
// its pick (opencode 2's to npm, which has no download per platform).
|
|
func TestToolBackendsNamed(t *testing.T) {
|
|
config := read(t, repo(t, "assets", "shared-tools", "mise.toml"))
|
|
aliases, err := configAliases(config)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
lock := parsed(t, read(t, repo(t, "tests", "e2e-mise.lock")))
|
|
names, _ := configTools(config)
|
|
for _, tool := range names {
|
|
got, named := aliases[tool]
|
|
switch b := lock.Backend(tool); {
|
|
case b == "core:"+tool && !named:
|
|
case !named:
|
|
t.Errorf("mise.toml doesn't name %s's backend (the lock's is %s): add it to [tool_alias]", tool, b)
|
|
case got != b:
|
|
t.Errorf("mise.toml names %s's backend %s, tests/e2e-mise.lock has %s: run scripts/bump.sh e2e-tools", tool, got, b)
|
|
}
|
|
}
|
|
for tool := range aliases {
|
|
if !slices.Contains(names, tool) {
|
|
t.Errorf("mise.toml's [tool_alias] names %s, which isn't one of its [tools]", tool)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Aliases gives a VM's mise the [tool_alias] table, a tool a line.
|
|
func TestAliases(t *testing.T) {
|
|
got, err := Aliases(os.DirFS(repo(t, "assets")))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want, _ := configAliases(read(t, repo(t, "assets", "shared-tools", "mise.toml")))
|
|
back, err := configAliases(got)
|
|
if err != nil || !maps.Equal(back, want) || len(want) == 0 {
|
|
t.Errorf("Aliases = %q (%v), want %q", got, err, want)
|
|
}
|
|
if !strings.HasPrefix(string(got), "[tool_alias]\nclaude = \"aqua:anthropics/claude-code\"\n") {
|
|
t.Errorf("Aliases = %q", got)
|
|
}
|
|
if _, err := Aliases(os.DirFS(t.TempDir())); err == nil {
|
|
t.Error("no mise.toml, no error")
|
|
}
|
|
}
|