Skip to content
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

fix downstream cargo vendor usage for component adapter crate #6486

Closed
Closed
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
25 changes: 25 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}

# Ensure WIT dependencies are in-sync.
wit_deps:
name: WIT dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: ensure `crates/wasi-preview1-component-adapter/wit/deps` are in sync
working-directory: ./crates/wasi-preview1-component-adapter
run: |
curl -Lo 'wit-deps' https://github.com/bytecodealliance/wit-deps/releases/download/v0.3.2/wit-deps-x86_64-unknown-linux-musl
chmod +x ./wit-deps
rm -rf wit/deps
./wit-deps lock
git add -N wit/deps
git diff --exit-code

# common logic to cancel the entire run if this job fails
- run: gh run cancel ${{ github.run_id }}
if: failure() && github.event_name != 'pull_request'
env:
GH_TOKEN: ${{ github.token }}

# Lint dependency graph for security advisories, duplicate versions, and
# incompatible licences
cargo_deny:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ foo
publish
vendor
examples/build
deps.lock
2 changes: 0 additions & 2 deletions crates/wasi-preview1-component-adapter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use crate::descriptors::{Descriptor, Descriptors, StreamType, Streams};
pub mod bindings {
#[cfg(feature = "command")]
wit_bindgen::generate!({
path: "../wasi/wit",
world: "wasi:preview/command",
std_feature,
raw_strings,
Expand All @@ -41,7 +40,6 @@ pub mod bindings {

#[cfg(feature = "reactor")]
wit_bindgen::generate!({
path: "../wasi/wit",
world: "wasi:preview/reactor",
std_feature,
raw_strings,
Expand Down
26 changes: 0 additions & 26 deletions crates/wasi-preview1-component-adapter/wit/command.wit

This file was deleted.

1 change: 1 addition & 0 deletions crates/wasi-preview1-component-adapter/wit/deps.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wasi = "../../wasi/wit"
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package wasi:clocks

/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
/// time.
///
/// It is intended to be portable at least between Unix-family platforms and
/// Windows.
///
/// A monotonic clock is a clock which has an unspecified initial value, and
/// successive reads of the clock will produce non-decreasing values.
///
/// It is intended for measuring elapsed time.
interface monotonic-clock {
use wasi:poll/poll.{pollable}

/// A timestamp in nanoseconds.
type instant = u64

/// Read the current value of the clock.
///
/// The clock is monotonic, therefore calling this function repeatedly will
/// produce a sequence of non-decreasing values.
now: func() -> instant

/// Query the resolution of the clock.
resolution: func() -> instant

/// Create a `pollable` which will resolve once the specified time has been
/// reached.
subscribe: func(
when: instant,
absolute: bool
) -> pollable
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package wasi:clocks

interface timezone {
use wall-clock.{datetime}

/// A timezone.
///
/// In timezones that recognize daylight saving time, also known as daylight
/// time and summer time, the information returned from the functions varies
/// over time to reflect these adjustments.
///
/// This [represents a resource](https://github.com/WebAssembly/WASI/blob/main/docs/WitInWasi.md#Resources).
type timezone = u32

/// Return information needed to display the given `datetime`. This includes
/// the UTC offset, the time zone name, and a flag indicating whether
/// daylight saving time is active.
///
/// If the timezone cannot be determined for the given `datetime`, return a
/// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight
/// saving time.
display: func(this: timezone, when: datetime) -> timezone-display

/// The same as `display`, but only return the UTC offset.
utc-offset: func(this: timezone, when: datetime) -> s32

/// Dispose of the specified input-stream, after which it may no longer
/// be used.
drop-timezone: func(this: timezone)

/// Information useful for displaying the timezone of a specific `datetime`.
///
/// This information may vary within a single `timezone` to reflect daylight
/// saving time adjustments.
record timezone-display {
/// The number of seconds difference between UTC time and the local
/// time of the timezone.
///
/// The returned value will always be less than 86400 which is the
/// number of seconds in a day (24*60*60).
///
/// In implementations that do not expose an actual time zone, this
/// should return 0.
utc-offset: s32,

/// The abbreviated name of the timezone to display to a user. The name
/// `UTC` indicates Coordinated Universal Time. Otherwise, this should
/// reference local standards for the name of the time zone.
///
/// In implementations that do not expose an actual time zone, this
/// should be the string `UTC`.
///
/// In time zones that do not have an applicable name, a formatted
/// representation of the UTC offset may be returned, such as `-04:00`.
name: string,

/// Whether daylight saving time is active.
///
/// In implementations that do not expose an actual time zone, this
/// should return false.
in-daylight-saving-time: bool,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package wasi:clocks

/// WASI Wall Clock is a clock API intended to let users query the current
/// time. The name "wall" makes an analogy to a "clock on the wall", which
/// is not necessarily monotonic as it may be reset.
///
/// It is intended to be portable at least between Unix-family platforms and
/// Windows.
///
/// A wall clock is a clock which measures the date and time according to
/// some external reference.
///
/// External references may be reset, so this clock is not necessarily
/// monotonic, making it unsuitable for measuring elapsed time.
///
/// It is intended for reporting the current date and time for humans.
interface wall-clock {
/// A time and date in seconds plus nanoseconds.
record datetime {
seconds: u64,
nanoseconds: u32,
}

/// Read the current value of the clock.
///
/// This clock is not monotonic, therefore calling this function repeatedly
/// will not necessarily produce a sequence of non-decreasing values.
///
/// The returned timestamps represent the number of seconds since
/// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
/// also known as [Unix Time].
///
/// The nanoseconds field of the output is always less than 1000000000.
///
/// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
/// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
now: func() -> datetime

/// Query the resolution of the clock.
///
/// The nanoseconds field of the output is always less than 1000000000.
resolution: func() -> datetime
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package wasi:filesystem

/// WASI filesystem is a filesystem API primarily intended to let users run WASI
/// programs that access their files on their existing filesystems, without
/// significant overhead.
Expand All @@ -17,9 +19,9 @@
/// `..` and symbolic link steps, reaches a directory outside of the base
/// directory, or reaches a symlink to an absolute or rooted path in the
/// underlying filesystem, the function fails with `error-code::not-permitted`.
default interface filesystem {
use io.streams.{input-stream, output-stream}
use clocks.wall-clock.{datetime}
interface filesystem {
use wasi:io/streams.{input-stream, output-stream}
use wasi:clocks/wall-clock.{datetime}

/// File size or length of a region within a file.
type filesize = u64
Expand Down Expand Up @@ -309,30 +311,30 @@ default interface filesystem {
/// Multiple read, write, and append streams may be active on the same open
/// file and they do not interfere with each other.
///
/// Note: This allows using `read-stream`, which is similar to `read` in POSIX.
/// Note: This allows using `wasi:io/streams.read`, which is similar to `read` in POSIX.
read-via-stream: func(
this: descriptor,
/// The offset within the file at which to start reading.
offset: filesize,
) -> input-stream
) -> result<input-stream, error-code>

/// Return a stream for writing to a file.
///
/// Note: This allows using `write-stream`, which is similar to `write` in
/// Note: This allows using `wasi:io/streams.write`, which is similar to `write` in
/// POSIX.
write-via-stream: func(
this: descriptor,
/// The offset within the file at which to start writing.
offset: filesize,
) -> output-stream
) -> result<output-stream, error-code>

/// Return a stream for appending to a file.
///
/// Note: This allows using `write-stream`, which is similar to `write` with
/// Note: This allows using `wasi:io/streams.write`, which is similar to `write` with
/// `O_APPEND` in in POSIX.
append-via-stream: func(
this: descriptor,
) -> output-stream
) -> result<output-stream, error-code>

/// Provide file advisory information on a descriptor.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// The `wasi:http/incoming-handler` interface is meant to be exported by
// components and called by the host in response to a new incoming HTTP
// response.
//
// NOTE: in Preview3, this interface will be merged with
// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface
// that takes a `request` parameter and returns a `response` result.
//
interface incoming-handler {
use types.{incoming-request, response-outparam}

// The `handle` function takes an outparam instead of returning its response
// so that the component may stream its response while streaming any other
// request or response bodies. The callee MUST write a response to the
// `response-out` and then finish the response before returning. The `handle`
// function is allowed to continue execution after finishing the response's
// output stream. While this post-response execution is taken off the
// critical path, since there is no return value, there is no way to report
// its success or failure.
handle: func(
request: incoming-request,
response-out: response-outparam
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// The `wasi:http/outgoing-handler` interface is meant to be imported by
// components and implemented by the host.
//
// NOTE: in Preview3, this interface will be merged with
// `wasi:http/outgoing-handler` into a single `wasi:http/handler` interface
// that takes a `request` parameter and returns a `response` result.
//
interface outgoing-handler {
use types.{outgoing-request, request-options, future-incoming-response}

// The parameter and result types of the `handle` function allow the caller
// to concurrently stream the bodies of the outgoing request and the incoming
// response.
handle: func(
request: outgoing-request,
options: option<request-options>
) -> future-incoming-response
}
Loading