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

feat: add wasmer-argus #4506

Merged
merged 37 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3c89c0b
feat: add wasmer-argus testsuite
xdoardo Mar 6, 2024
4bd3979
add README.md
xdoardo Mar 6, 2024
f4da13f
feat: add llvm to backends
xdoardo Mar 6, 2024
8b029c5
fix: clippy warnings
xdoardo Mar 6, 2024
9f26b82
fix: formatting
xdoardo Mar 6, 2024
f994700
fix: clippy
xdoardo Mar 6, 2024
6195830
fix: clearer code
xdoardo Mar 7, 2024
9f066cc
fix: use `tokio`'s `File`
xdoardo Mar 7, 2024
53cb9e7
fix: mark non-rust codeblock as `text`
xdoardo Mar 7, 2024
edd40c2
feat(argus): feature-gate `wasmer_lib`
xdoardo Mar 15, 2024
d5b3284
feat(argus): add CLI flag for using library
xdoardo Mar 15, 2024
f8f2138
feat(argus): CLI and library testers
xdoardo Mar 15, 2024
55f3f7b
feat(argus): README with build instructions
xdoardo Mar 15, 2024
474f99c
feat(argus): remove `paw`, add `async_trait`
xdoardo Mar 18, 2024
2793f74
fix(argus): fmt
xdoardo Mar 18, 2024
82a45e9
fix(argus): lint
xdoardo Mar 18, 2024
db10a70
feat(argus): add output path to compile command
xdoardo Mar 20, 2024
9673a22
fix(argus): underscore unused parameter
xdoardo Mar 20, 2024
ccffb22
fix(argus): more logging
xdoardo Mar 20, 2024
fbd7c73
fix(argus): reasonable test indexing
xdoardo Mar 20, 2024
df806d4
fix(argus): explicit env filter
xdoardo Mar 20, 2024
e9d53d8
feat(argus): add package identifier in test serialization
xdoardo Mar 20, 2024
055d230
fix(argus): remove version for crate `wasmer-api`
xdoardo Mar 20, 2024
f4f1aa2
fix: remove version from backend crate
xdoardo Mar 20, 2024
950077b
Merge branch 'wasmerio:master' into master
xdoardo Mar 20, 2024
15bf27a
feat(argus): bump workspace version
xdoardo Mar 20, 2024
d60c561
refactor(argus): remove lib
xdoardo Mar 20, 2024
87f275f
refactor(argus): remove run flag
xdoardo Mar 20, 2024
e942000
refactor(argus): remove `wasmer_version` from `ArgusConfig`
xdoardo Mar 20, 2024
8c6f99f
refactor(argus): more autonomy to testers
xdoardo Mar 20, 2024
1221ddf
chore(argus): clippy + fmt
xdoardo Mar 20, 2024
2db889f
fix(argus): use rustls in reqwest
xdoardo Mar 21, 2024
e73190c
fix(argus): use same reqwest config as CLI
xdoardo Mar 21, 2024
1dc0afe
Merge branch 'wasmerio:master' into master
xdoardo Mar 21, 2024
6aae478
log version
xdoardo Mar 21, 2024
1e8cc56
Merge branch 'master' into master
xdoardo Mar 21, 2024
9eaea5c
Merge branch 'master' into master
theduke Mar 21, 2024
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
32 changes: 32 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ members = [
"tests/lib/compiler-test-derive",
"tests/lib/wast",
"tests/wasi-wast",
"tests/wasmer-argus",
]
resolver = "2"

Expand Down
47 changes: 47 additions & 0 deletions tests/wasmer-argus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "wasmer-argus"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[features]
wasmer_lib = ["dep:wasmer"]

[dependencies]
indicatif = "0.17.8"
anyhow = "1.0.80"
log = "0.4.21"
cynic = "3.4.3"
url = "2.5.0"
futures = "0.3.30"
tracing = "0.1.40"
tokio = { version = "1.36.0", features = ["rt-multi-thread", "sync", "time", "fs"] }
clap = {version = "4.4.11", features = ["derive", "string"]}
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
wasmer = { version = "4.2.6", path = "../../lib/api", features = ["engine", "core", "singlepass", "cranelift", "llvm"], optional = true }
derive_more = "0.99.17"
webc.workspace = true
async-trait = "0.1.77"
wasmer-api = { path = "../../lib/backend-api" }


[target.'cfg(not(target_arch = "riscv64"))'.dependencies]
reqwest = { version = "^0.11", default-features = false, features = [
"rustls-tls",
"json",
"multipart",
"gzip",
] }

[target.'cfg(target_arch = "riscv64")'.dependencies]
reqwest = { version = "^0.11", default-features = false, features = [
"native-tls",
"json",
"multipart",
] }
55 changes: 55 additions & 0 deletions tests/wasmer-argus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# wasmer-argus

Automatically test packages from the registry.

## Building
If you want to use the local `wasmer` crate, you shall
build the project with `cargo build --package wasmer-argus --features wasmer_lib`.

On macOS, you may encounter an error where the linker does not find `zstd`: a possible
solution to this problem is to install `zstd` using `brew` (`brew install zstd`) and
using the following command:

`RUSTFLAGS="-L$(brew --prefix)/lib" cargo build --package wasmer-argus --features wasmer_lib`

Another possiblity is to add the your brew prefix with `/lib` (probably = `/opt/homebrew/lib/`)
to the global Cargo config something like:
```
[target.aarch64-apple-darwin]
rustflags = ["-L/opt/homebrew/lib"]
```

## Usage
This binary fetches packages from the graphql endpoint of a registry. By
default, it uses `http://registry.wasmer.io/graphql`; and the needed
authorization token is retrieved from the environment using the `WASMER_TOKEN`.
Users can specify the token via CLI with the appropriate flag.

This testsuite is parallelised, and the degree of parallelism available can be
specified both by CLI flag or automatically using
`std::thread::available_parallelism`.

```
Fetch and test packages from a WebContainer registry

Usage: wasmer-argus [OPTIONS]

Options:
-r, --registry-url <REGISTRY_URL>
The GraphQL endpoint of the registry to test [default: http://registry.wasmer.io/graphql]
-b, --backend <COMPILER_BACKEND>
The backend to test the compilation against [default: singlepass] [possible values: llvm, singlepass, cranelift]
--run
Whether or not to run packages during tests
-o, --outdir <OUTDIR>
The output directory [default: /home/ecmm/sw/wasmer/wasmer/target/debug/out]
--auth-token <AUTH_TOKEN>
The authorization token needed to see packages [default: <env::WASMER_TOKEN>]
--jobs <JOBS>
The number of concurrent tests (jobs) to perform [default: 12]
-h, --help Print help
-V, --version Print version
```



64 changes: 64 additions & 0 deletions tests/wasmer-argus/src/argus/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
use clap::ValueEnum;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

fn get_default_out_path() -> PathBuf {
let mut path = std::env::current_dir().unwrap();
path.push("out");
path
}

fn get_default_token() -> String {
std::env::var("WASMER_TOKEN").unwrap_or_default()
}

fn get_default_jobs() -> usize {
std::thread::available_parallelism()
.unwrap_or(std::num::NonZeroUsize::new(2).unwrap())
.into()
}

#[derive(Debug, Clone, Serialize, Deserialize, ValueEnum, derive_more::Display)]
pub enum Backend {
Llvm,
Singlepass,
Cranelift,
}

/// Fetch and test packages from a WebContainer registry.
#[derive(Debug, clap::Parser, Clone, Serialize, Deserialize)]
#[command(version, about, long_about = None)]
pub struct ArgusConfig {
/// The GraphQL endpoint of the registry to test
#[arg(
short,
long,
default_value_t = String::from("http://registry.wasmer.io/graphql")
)]
pub registry_url: String,

/// The backend to test the compilation against
#[arg(short = 'b', long = "backend", value_enum, default_value_t = Backend::Singlepass)]
pub compiler_backend: Backend,

/// The output directory
#[arg(short = 'o', long, default_value = get_default_out_path().into_os_string())]
pub outdir: std::path::PathBuf,

/// The authorization token needed to see packages
#[arg(long, default_value_t = get_default_token())]
pub auth_token: String,

/// The number of concurrent tests (jobs) to perform
#[arg(long, default_value_t = get_default_jobs()) ]
pub jobs: usize,

/// The path to the CLI command to use. [default will be searched in $PATH: "wasmer"]
#[arg(long)]
pub cli_path: Option<String>,

/// Whether or not this run should use the linked [`wasmer-api`] library instead of the CLI.
#[cfg(feature = "wasmer_lib")]
#[arg(long, conflicts_with = "cli_path")]
pub use_lib: bool,
}
Loading
Loading