Skip to content

Commit 1725a72

Browse files
jsturtevantsimongdaviesludfjigjprendes
authored
Cherry pick of a few commits to release/v0.6.1 (#625)
* 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 <simongdavies@users.noreply.github.com> * Make cargo publish only publish unreleased crates (#623) Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> * make socket component example work (#624) * make socket component example work Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com> * bump Cargo.lock for witguest Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com> --------- Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com> --------- Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com> Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com> Co-authored-by: Simon Davies <simongdavies@users.noreply.github.com> Co-authored-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com> Co-authored-by: Jorge Prendes <jorge.prendes@gmail.com>
1 parent 80e0e8b commit 1725a72

File tree

6 files changed

+98
-22
lines changed

6 files changed

+98
-22
lines changed

.github/workflows/CargoPublish.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,44 +44,80 @@ jobs:
4444
else
4545
VERSION="${{ github.ref }}"
4646
VERSION="${VERSION#refs/heads/release/v}"
47+
echo "VERSION=$VERSION" >> $GITHUB_ENV
4748
fi
48-
./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host
49+
./dev/verify-version.sh "$VERSION" hyperlight-common hyperlight-guest hyperlight-guest-bin hyperlight-host hyperlight-component-util hyperlight-component-macro
50+
51+
- name: Determine which crates need publishing
52+
run: |
53+
needs_publish() {
54+
local crate=$1
55+
local crate_env_var=$(echo "$crate" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
56+
57+
if [ -z "$VERSION" ]; then
58+
echo "No version set (dry run?), skipping crates.io existence checks."
59+
echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV"
60+
return
61+
fi
62+
63+
if curl -s "https://crates.io/api/v1/crates/$crate/$VERSION" | jq -e .version > /dev/null; then
64+
echo "PUBLISH_${crate_env_var}=false" >> "$GITHUB_ENV"
65+
echo "✅ $crate@$VERSION already exists."
66+
else
67+
echo "PUBLISH_${crate_env_var}=true" >> "$GITHUB_ENV"
68+
echo "🚀 $crate@$VERSION will be published."
69+
fi
70+
}
71+
72+
needs_publish hyperlight-common
73+
needs_publish hyperlight-guest
74+
needs_publish hyperlight-guest-bin
75+
needs_publish hyperlight-component-util
76+
needs_publish hyperlight-component-macro
77+
needs_publish hyperlight-host
4978
5079
- name: Publish hyperlight-common
5180
continue-on-error: ${{ inputs.dry_run }}
5281
run: cargo publish --manifest-path ./src/hyperlight_common/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
5382
env:
5483
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
84+
if: env.PUBLISH_HYPERLIGHT_COMMON != 'false'
5585

5686
- name: Publish hyperlight-guest
5787
continue-on-error: ${{ inputs.dry_run }}
5888
run: cargo publish --manifest-path ./src/hyperlight_guest/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
5989
env:
6090
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
91+
if: env.PUBLISH_HYPERLIGHT_GUEST != 'false'
6192

6293
- name: Publish hyperlight-guest-bin
6394
continue-on-error: ${{ inputs.dry_run }}
6495
run: cargo publish --manifest-path ./src/hyperlight_guest_bin/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
6596
env:
6697
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
67-
68-
- name: Publish hyperlight-host
69-
continue-on-error: ${{ inputs.dry_run }}
70-
run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
71-
env:
72-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
73-
98+
if: env.PUBLISH_HYPERLIGHT_GUEST_BIN != 'false'
99+
74100
- name: Publish hyperlight-component-util
75101
continue-on-error: ${{ inputs.dry_run }}
76102
run: cargo publish --manifest-path ./src/hyperlight_component_util/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
77103
env:
78104
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
105+
if: env.PUBLISH_HYPERLIGHT_COMPONENT_UTIL != 'false'
79106

80107
- name: Publish hyperlight-component-macro
81108
continue-on-error: ${{ inputs.dry_run }}
82109
run: cargo publish --manifest-path ./src/hyperlight_component_macro/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
83110
env:
84111
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
112+
if: env.PUBLISH_HYPERLIGHT_COMPONENT_MACRO != 'false'
113+
114+
- name: Publish hyperlight-host
115+
continue-on-error: ${{ inputs.dry_run }}
116+
run: cargo publish --manifest-path ./src/hyperlight_host/Cargo.toml ${{ inputs.dry_run && '--dry-run' || '' }}
117+
env:
118+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_PUBLISH_TOKEN }}
119+
if: env.PUBLISH_HYPERLIGHT_HOST != 'false'
120+
85121

86122
# TODO: Do we want to publish hyperlight-guest-capi to crates.io given that it's not for Rust consumption?
87123
# - name: Publish hyperlight-guest-capi

src/hyperlight_component_util/src/rtypes.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
386386
};
387387
quote! {
388388
#derives
389-
#[derive(Debug, Clone, PartialEq)]
389+
#[derive(Debug)]
390390
pub struct #id #vs { #toks }
391391
}
392392
}
@@ -444,7 +444,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
444444
};
445445
quote! {
446446
#derives
447-
#[derive(Debug, Clone, PartialEq)]
447+
#[derive(Debug)]
448448
pub enum #id #vs { #toks }
449449
}
450450
}
@@ -471,7 +471,6 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
471471
#[derive(::wasmtime::component::ComponentType)]
472472
#[derive(::wasmtime::component::Lift)]
473473
#[derive(::wasmtime::component::Lower)]
474-
#[derive(::core::marker::Copy)]
475474
#[component(enum)]
476475
#[repr(u8)] // todo: should this always be u8?
477476
}
@@ -480,7 +479,7 @@ fn emit_value_toplevel(s: &mut State, v: Option<u32>, id: Ident, vt: &Value) ->
480479
};
481480
quote! {
482481
#derives
483-
#[derive(Debug, Clone, PartialEq)]
482+
#[derive(Debug, Copy, Clone, PartialEq)]
484483
pub enum #id #vs { #toks }
485484
}
486485
}

src/hyperlight_guest/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ homepage.workspace = true
88
repository.workspace = true
99
readme.workspace = true
1010
description = """
11-
Library to build guest applications for hyperlight.
11+
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.
1212
"""
1313

1414
[dependencies]

src/hyperlight_guest_bin/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ license.workspace = true
88
homepage.workspace = true
99
repository.workspace = true
1010
readme.workspace = true
11+
description = """
12+
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,
13+
and third-party code used by our C-API needed to build a native hyperlight-guest binary.
14+
"""
1115

1216
[features]
1317
default = ["libc", "printf"]

src/hyperlight_host/tests/wit_test.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,45 @@ mod bindings {
2626
hyperlight_component_macro::host_bindgen!("../tests/rust_guests/witguest/interface.wasm");
2727
}
2828

29+
use bindings::test::wit::roundtrip::{Testrecord, Testvariant};
2930
use bindings::*;
3031

32+
impl PartialEq for Testrecord {
33+
fn eq(&self, other: &Self) -> bool {
34+
self.contents == other.contents && self.length == other.length
35+
}
36+
}
37+
38+
impl PartialEq for Testvariant {
39+
fn eq(&self, other: &Self) -> bool {
40+
match (self, other) {
41+
(Testvariant::VariantA, Testvariant::VariantA) => true,
42+
(Testvariant::VariantB(s1), Testvariant::VariantB(s2)) => s1 == s2,
43+
(Testvariant::VariantC(c1), Testvariant::VariantC(c2)) => c1 == c2,
44+
_ => false,
45+
}
46+
}
47+
}
48+
49+
impl Clone for Testrecord {
50+
fn clone(&self) -> Self {
51+
Self {
52+
contents: self.contents.clone(),
53+
length: self.length,
54+
}
55+
}
56+
}
57+
58+
impl Clone for Testvariant {
59+
fn clone(&self) -> Self {
60+
match self {
61+
Self::VariantA => Self::VariantA,
62+
Self::VariantB(s) => Self::VariantB(s.clone()),
63+
Self::VariantC(c) => Self::VariantC(*c),
64+
}
65+
}
66+
}
67+
3168
struct Host {}
3269

3370
impl test::wit::Roundtrip for Host {

src/tests/rust_guests/witguest/Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)