Skip to content

Cherry pick of a few commits to release/v0.6.1 #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 44 additions & 8 deletions .github/workflows/CargoPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,80 @@ 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
./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 }}

- 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_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?
# - name: Publish hyperlight-guest-capi
Expand Down
7 changes: 3 additions & 4 deletions src/hyperlight_component_util/src/rtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
};
quote! {
#derives
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug)]
pub struct #id #vs { #toks }
}
}
Expand Down Expand Up @@ -444,7 +444,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
};
quote! {
#derives
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug)]
pub enum #id #vs { #toks }
}
}
Expand All @@ -471,7 +471,6 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, 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?
}
Expand All @@ -480,7 +479,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
};
quote! {
#derives
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum #id #vs { #toks }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_guest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 4 additions & 0 deletions src/hyperlight_guest_bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
37 changes: 37 additions & 0 deletions src/hyperlight_host/tests/wit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions src/tests/rust_guests/witguest/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading