From abcc9e74b32cef0482a25ee3b09a70cba60e60aa Mon Sep 17 00:00:00 2001 From: Simon Davies Date: Mon, 9 Jun 2025 14:12:18 +0100 Subject: [PATCH 1/3] Update Crate descriptions for guest crates (#590) Add verification of crate versions for new crates to Crate Publish job Amend the order of crate publishing to account for dependencies Signed-off-by: Simon Davies --- .github/workflows/CargoPublish.yml | 16 ++++++++-------- src/hyperlight_guest/Cargo.toml | 2 +- src/hyperlight_guest_bin/Cargo.toml | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CargoPublish.yml b/.github/workflows/CargoPublish.yml index b97800910..146ed2b09 100644 --- a/.github/workflows/CargoPublish.yml +++ b/.github/workflows/CargoPublish.yml @@ -45,7 +45,7 @@ jobs: VERSION="${{ github.ref }}" VERSION="${VERSION#refs/heads/release/v}" fi - ./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host + ./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host hyperlight-component-util hyperlight-component-macro - name: Publish hyperlight-common continue-on-error: ${{ inputs.dry_run }} @@ -64,13 +64,6 @@ jobs: run: cargo publish --manifest-path ./src/hyperlight_guest_bin/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} - - - name: Publish hyperlight-host - continue-on-error: ${{ inputs.dry_run }} - run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} - - name: Publish hyperlight-component-util continue-on-error: ${{ inputs.dry_run }} run: cargo publish --manifest-path ./src/hyperlight_component_util/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} @@ -82,6 +75,13 @@ jobs: run: cargo publish --manifest-path ./src/hyperlight_component_macro/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + + - name: Publish hyperlight-host + continue-on-error: ${{ inputs.dry_run }} + run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + # TODO: Do we want to publish hyperlight-guest-capi to crates.io given that it's not for Rust consumption? # - name: Publish hyperlight-guest-capi diff --git a/src/hyperlight_guest/Cargo.toml b/src/hyperlight_guest/Cargo.toml index 7178cfa10..8fce35293 100644 --- a/src/hyperlight_guest/Cargo.toml +++ b/src/hyperlight_guest/Cargo.toml @@ -8,7 +8,7 @@ homepage.workspace = true repository.workspace = true readme.workspace = true description = """ -Library to build guest applications for hyperlight. +Provides only the essential building blocks for interacting with the host environment, including the VM exit mechanism, abstractions for calling host functions and receiving return values, and the input/output stacks used for guest-host communication. """ [dependencies] diff --git a/src/hyperlight_guest_bin/Cargo.toml b/src/hyperlight_guest_bin/Cargo.toml index 10038211f..1b8202f51 100644 --- a/src/hyperlight_guest_bin/Cargo.toml +++ b/src/hyperlight_guest_bin/Cargo.toml @@ -8,6 +8,10 @@ license.workspace = true homepage.workspace = true repository.workspace = true readme.workspace = true +description = """ +This crate provides the opinionated bits of the guest library, such as the panic handler, the entry point, the guest logger, the exception handling logic, +and third-party code used by our C-API needed to build a native hyperlight-guest binary. +""" [features] default = ["libc", "printf"] From 7df2e0191d8688e9781f0240b21a7c9e48e04d90 Mon Sep 17 00:00:00 2001 From: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Date: Fri, 13 Jun 2025 14:10:25 -0700 Subject: [PATCH 2/3] Make cargo publish only publish unreleased crates (#623) Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> --- .github/workflows/CargoPublish.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/CargoPublish.yml b/.github/workflows/CargoPublish.yml index 146ed2b09..a0e26e036 100644 --- a/.github/workflows/CargoPublish.yml +++ b/.github/workflows/CargoPublish.yml @@ -44,43 +44,79 @@ jobs: else VERSION="${{ github.ref }}" VERSION="${VERSION#refs/heads/release/v}" + echo "VERSION=$VERSION" >> $GITHUB_ENV fi ./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host hyperlight-component-util hyperlight-component-macro + - name: Determine which crates need publishing + run: | + needs_publish() { + local crate=$1 + local crate_env_var=$(echo "$crate" | tr '[:lower:]' '[:upper:]' | tr '-' '_') + + if [ -z "$VERSION" ]; then + echo "No version set (dry run?), skipping crates.io existence checks." + echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV" + return + fi + + if curl -s "https://crates.io/api/v1/crates/$crate/$VERSION" | jq -e .version > /dev/null; then + echo "PUBLISH_${crate_env_var}=false" >> "$GITHUB_ENV" + echo "✅ $crate@$VERSION already exists." + else + echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV" + echo "🚀 $crate@$VERSION will be published." + fi + } + + needs_publish hyperlight-common + needs_publish hyperlight-guest + needs_publish hyperlight-guest-bin + needs_publish hyperlight-component-util + needs_publish hyperlight-component-macro + needs_publish hyperlight-host + - name: Publish hyperlight-common continue-on-error: ${{ inputs.dry_run }} run: cargo publish --manifest-path ./src/hyperlight_common/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + if: env.PUBLISH_HYPERLIGHT_COMMON != 'false' - name: Publish hyperlight-guest continue-on-error: ${{ inputs.dry_run }} run: cargo publish --manifest-path ./src/hyperlight_guest/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + if: env.PUBLISH_HYPERLIGHT_GUEST != 'false' - name: Publish hyperlight-guest-bin continue-on-error: ${{ inputs.dry_run }} run: cargo publish --manifest-path ./src/hyperlight_guest_bin/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + if: env.PUBLISH_HYPERLIGHT_GUEST_BIN != 'false' + - name: Publish hyperlight-component-util continue-on-error: ${{ inputs.dry_run }} run: cargo publish --manifest-path ./src/hyperlight_component_util/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + if: env.PUBLISH_HYPERLIGHT_COMPONENT_UTIL != 'false' - name: Publish hyperlight-component-macro continue-on-error: ${{ inputs.dry_run }} run: cargo publish --manifest-path ./src/hyperlight_component_macro/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + if: env.PUBLISH_HYPERLIGHT_COMPONENT_MACRO != 'false' - name: Publish hyperlight-host continue-on-error: ${{ inputs.dry_run }} run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }} env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }} + if: env.PUBLISH_HYPERLIGHT_HOST != 'false' # TODO: Do we want to publish hyperlight-guest-capi to crates.io given that it's not for Rust consumption? From 9c09d806c4eb508e96fa521ac0f19f24200a407c Mon Sep 17 00:00:00 2001 From: Jorge Prendes Date: Sat, 14 Jun 2025 00:56:19 +0100 Subject: [PATCH 3/3] make socket component example work (#624) * make socket component example work Signed-off-by: Jorge Prendes * bump Cargo.lock for witguest Signed-off-by: Jorge Prendes --------- Signed-off-by: Jorge Prendes --- src/hyperlight_component_util/src/rtypes.rs | 7 ++-- src/hyperlight_host/tests/wit_test.rs | 37 +++++++++++++++++++++ src/tests/rust_guests/witguest/Cargo.lock | 18 +++++----- 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/hyperlight_component_util/src/rtypes.rs b/src/hyperlight_component_util/src/rtypes.rs index 7498d2407..a6b2266a3 100644 --- a/src/hyperlight_component_util/src/rtypes.rs +++ b/src/hyperlight_component_util/src/rtypes.rs @@ -386,7 +386,7 @@ fn emit_value_toplevel(s: &mut State, v: Option, id: Ident, vt: &Value) -> }; quote! { #derives - #[derive(Debug, Clone, PartialEq)] + #[derive(Debug)] pub struct #id #vs { #toks } } } @@ -444,7 +444,7 @@ fn emit_value_toplevel(s: &mut State, v: Option, id: Ident, vt: &Value) -> }; quote! { #derives - #[derive(Debug, Clone, PartialEq)] + #[derive(Debug)] pub enum #id #vs { #toks } } } @@ -471,7 +471,6 @@ fn emit_value_toplevel(s: &mut State, v: Option, id: Ident, vt: &Value) -> #[derive(::wasmtime::component::ComponentType)] #[derive(::wasmtime::component::Lift)] #[derive(::wasmtime::component::Lower)] - #[derive(::core::marker::Copy)] #[component(enum)] #[repr(u8)] // todo: should this always be u8? } @@ -480,7 +479,7 @@ fn emit_value_toplevel(s: &mut State, v: Option, id: Ident, vt: &Value) -> }; quote! { #derives - #[derive(Debug, Clone, PartialEq)] + #[derive(Debug, Copy, Clone, PartialEq)] pub enum #id #vs { #toks } } } diff --git a/src/hyperlight_host/tests/wit_test.rs b/src/hyperlight_host/tests/wit_test.rs index d07e32bfa..1fd5e95cd 100644 --- a/src/hyperlight_host/tests/wit_test.rs +++ b/src/hyperlight_host/tests/wit_test.rs @@ -26,8 +26,45 @@ mod bindings { hyperlight_component_macro::host_bindgen!("../tests/rust_guests/witguest/interface.wasm"); } +use bindings::test::wit::roundtrip::{Testrecord, Testvariant}; use bindings::*; +impl PartialEq for Testrecord { + fn eq(&self, other: &Self) -> bool { + self.contents == other.contents && self.length == other.length + } +} + +impl PartialEq for Testvariant { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Testvariant::VariantA, Testvariant::VariantA) => true, + (Testvariant::VariantB(s1), Testvariant::VariantB(s2)) => s1 == s2, + (Testvariant::VariantC(c1), Testvariant::VariantC(c2)) => c1 == c2, + _ => false, + } + } +} + +impl Clone for Testrecord { + fn clone(&self) -> Self { + Self { + contents: self.contents.clone(), + length: self.length, + } + } +} + +impl Clone for Testvariant { + fn clone(&self) -> Self { + match self { + Self::VariantA => Self::VariantA, + Self::VariantB(s) => Self::VariantB(s.clone()), + Self::VariantC(c) => Self::VariantC(*c), + } + } +} + struct Host {} impl test::wit::Roundtrip for Host { diff --git a/src/tests/rust_guests/witguest/Cargo.lock b/src/tests/rust_guests/witguest/Cargo.lock index 573a444ee..2c5eb9d16 100644 --- a/src/tests/rust_guests/witguest/Cargo.lock +++ b/src/tests/rust_guests/witguest/Cargo.lock @@ -178,7 +178,7 @@ dependencies = [ [[package]] name = "hyperlight-common" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anyhow", "flatbuffers", @@ -188,7 +188,7 @@ dependencies = [ [[package]] name = "hyperlight-component-macro" -version = "0.6.0" +version = "0.6.1" dependencies = [ "env_logger", "hyperlight-component-util", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "hyperlight-component-util" -version = "0.6.0" +version = "0.6.1" dependencies = [ "itertools", "log", @@ -215,7 +215,7 @@ dependencies = [ [[package]] name = "hyperlight-guest" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anyhow", "hyperlight-common", @@ -224,7 +224,7 @@ dependencies = [ [[package]] name = "hyperlight-guest-bin" -version = "0.6.0" +version = "0.6.1" dependencies = [ "buddy_system_allocator", "cc", @@ -337,9 +337,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.33" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dee91521343f4c5c6a63edd65e54f31f5c92fe8978c40a4282f8372194c6a7d" +checksum = "6837b9e10d61f45f987d50808f83d1ee3d206c66acf650c3e4ae2e1f6ddedf55" dependencies = [ "proc-macro2", "syn", @@ -477,9 +477,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.100" +version = "2.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "e4307e30089d6fd6aff212f2da3a1f9e32f3223b1f010fb09b7c95f90f3ca1e8" dependencies = [ "proc-macro2", "quote",