Stream: wasm

Topic: using semver-check


view this post on Zulip Dan Gohman (Oct 30 2024 at 18:09):

How does one use wasm-tools component semver-check? For example, say I want to check that a wasi-http change is sermver-compatible with the current interface. The CLI only seems to take one wit directory; is there a convenient way to copy the old world into the new wit directory? Or is there another way to do this?

view this post on Zulip Alex Crichton (Oct 30 2024 at 18:14):

the rough intention is that both the old and the new are in the same directory so you could do something like:

wasm-tools component semver-check --prev wasi:http/proxy@0.2.0 --new wasi:http/proxy@0.2.1 ./wit

where you'd fill in wit/deps/* based on the various packages and dependencys (and probably a dummy wit/root.wit file for now)

view this post on Zulip Dan Gohman (Oct 30 2024 at 18:15):

How does one put two different versions of the same interfaces in wit/deps/* tree?

view this post on Zulip Alex Crichton (Oct 30 2024 at 18:20):

oh you can put them in separate folders, for example wit/deps/http@0.2.0/*.wit and wit/deps/http@0.2.1/*.wit

view this post on Zulip Alex Crichton (Oct 30 2024 at 18:21):

the names of the directories don't actually matter, they're ignored during parsing -- only used for human-readable organization

view this post on Zulip Dan Gohman (Oct 30 2024 at 18:33):

$ wasm-tools component semver-check --prev wasi:http/proxy@0.2.2 --new wasi:http/proxy@0.2.3 ./wit
error: the old world is in package wasi:http, which is not the same as the new world, which is in package wasi:http

view this post on Zulip Dan Gohman (Oct 30 2024 at 18:37):

I think I got everything in versioned directories under wit/deps now, and am now getting this error.

view this post on Zulip Dan Gohman (Oct 30 2024 at 18:39):

One of them has package wasi:http@0.2.2; and the other has package wasi:http@0.2.3;.

view this post on Zulip Dan Gohman (Oct 30 2024 at 18:49):

This change seems to fix it for me. Does this look reasonable?

diff --git a/crates/wit-component/src/semver_check.rs b/crates/wit-component/src/semver_check.rs
index 1c4a9f4f..58d0aa74 100644
--- a/crates/wit-component/src/semver_check.rs
+++ b/crates/wit-component/src/semver_check.rs
@@ -55,7 +55,7 @@ pub fn semver_check(mut resolve: Resolve, prev: WorldId, new: WorldId) -> Result
         .package
         .context("new world not in named package")?;
     let new_pkg_name = &resolve.packages[new_pkg_id].name;
-    if old_pkg_id != new_pkg_id {
+    if old_pkg_name != new_pkg_name {
         bail!("the old world is in package {old_pkg_name}, which is not the same as the new world, which is in package {new_pkg_name}", )
     }

view this post on Zulip Dan Gohman (Oct 30 2024 at 19:14):

I've now added a test and posted this as a PR.

In wasm-tools component semver-checks, instead of requiring that the old and new world live in packages with the same id, just require that they have the same name. This allows checking for semver ...

view this post on Zulip Alex Crichton (Oct 30 2024 at 19:15):

oops yeah I think the check there is a bit overly cautious, thanks!


Last updated: Dec 23 2024 at 13:07 UTC