wasmer_argus/argus/
config.rs

1use clap::ValueEnum;
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5fn get_default_out_path() -> PathBuf {
6    let mut path = std::env::current_dir().unwrap();
7    path.push("out");
8    path
9}
10
11fn get_default_token() -> String {
12    std::env::var("WASMER_TOKEN").unwrap_or_default()
13}
14
15fn get_default_jobs() -> usize {
16    std::thread::available_parallelism()
17        .unwrap_or(std::num::NonZeroUsize::new(2).unwrap())
18        .into()
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize, ValueEnum, derive_more::Display)]
22pub enum Backend {
23    Llvm,
24    Singlepass,
25    Cranelift,
26}
27
28/// Fetch and test packages from a WebContainer registry.
29#[derive(Debug, clap::Parser, Clone, Serialize, Deserialize)]
30#[command(version, about, long_about = None)]
31pub struct ArgusConfig {
32    /// The GraphQL endpoint of the registry to test
33    #[arg(
34        short,
35        long,
36        default_value_t = String::from("http://registry.wasmer.io/graphql")
37    )]
38    pub registry_url: String,
39
40    /// The backend to test the compilation against
41    #[arg(short = 'b', long = "backend", value_enum, default_value_t = Backend::Singlepass)]
42    pub compiler_backend: Backend,
43
44    /// The output directory
45    #[arg(short = 'o', long, default_value = get_default_out_path().into_os_string())]
46    pub outdir: std::path::PathBuf,
47
48    /// The authorization token needed to see packages
49    #[arg(long, default_value_t = get_default_token())]
50    pub auth_token: String,
51
52    /// The number of concurrent tests (jobs) to perform
53    #[arg(long, default_value_t = get_default_jobs()) ]
54    pub jobs: usize,
55
56    /// The path to the CLI command to use. [default will be searched in $PATH: "wasmer"]
57    #[arg(long)]
58    pub cli_path: Option<String>,
59
60    /// Whether or not this run should use the linked [`wasmer-backend-api`] library instead of the CLI.
61    #[cfg(feature = "wasmer_lib")]
62    #[arg(long, conflicts_with = "cli_path")]
63    pub use_lib: bool,
64
65    /// The webhook to use when sending the test outcome.
66    #[arg(long)]
67    pub webhook_url: Option<String>,
68}