diff --git a/Cargo.lock b/Cargo.lock index a34af53..8080da8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1412,7 +1412,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "stylus-trace-core" -version = "0.1.7" +version = "0.1.10" dependencies = [ "addr2line", "anyhow", @@ -1433,7 +1433,7 @@ dependencies = [ [[package]] name = "stylus-trace-studio" -version = "0.1.7" +version = "0.1.10" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 2751707..e769867 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ ] [workspace.package] -version = "0.1.7" +version = "0.1.10" edition = "2021" authors = ["CreativesOnchain"] license = "MIT" @@ -17,7 +17,7 @@ keywords = ["arbitrum", "stylus", "profiling", "gas", "flamegraph"] categories = ["development-tools::profiling", "wasm"] [workspace.dependencies] -stylus-trace-core = { version = "0.1.7", path = "crates/stylus-trace-core" } +stylus-trace-core = { version = "0.1.10", path = "crates/stylus-trace-core" } clap = { version = "4.5", features = ["derive", "env"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/README.md b/README.md index 467f57b..aebffa0 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ This feature will be enabled automatically once upstream tracer support is avail ### `capture` | Flag | Description | Default | |------|-------------|---------| -| `--tx` | **(Required)** Transaction hash to profile | - | +| `--tx` | Transaction hash to profile | - | | `--rpc` | RPC endpoint URL | `http://localhost:8547` | | `--flamegraph` | Generate an SVG flamegraph | `artifacts/capture/flamegraph.svg` | | `--output` | Save JSON profile to path | `artifacts/capture/profile.json` | @@ -143,7 +143,7 @@ This feature will be enabled automatically once upstream tracer support is avail ### `ci init` | Flag | Description | Default | |------|-------------|---------| -| `--tx` | **(Required)** Transaction hash to profile in CI | - | +| `--tx` | Transaction hash to profile in CI (optional) | - | | `--rpc` | RPC endpoint URL | `http://localhost:8547` | | `--threshold` | Percentage threshold for regressions | `1.0` | | `--force` | Overwrite existing workflow files | `false` | @@ -157,8 +157,9 @@ Stylus Trace is built for automated performance tracking. You can integrate it i ### Quick Setup (Zero Config) Run this in your repository to auto-generate a GitHub Actions workflow: ```bash -stylus-trace ci init --tx 0x... +stylus-trace ci init ``` +*Note: You can optionally provide `--tx 0x...` now or fill it in the generated YAML later.* ### Manual Integration You can use the [Stylus Trace Action](https://github.com/CreativesOnchain/Stylus-Trace) directly in your workflows: diff --git a/action.yml b/action.yml index 70a719e..292ae6a 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ inputs: default: 'http://localhost:8547' tx_hash: description: 'Transaction hash to profile' - required: true + required: false baseline: description: 'Path to baseline profile JSON' required: false diff --git a/bin/stylus-trace-studio/src/main.rs b/bin/stylus-trace-studio/src/main.rs index 1a06d59..8a3e0f1 100644 --- a/bin/stylus-trace-studio/src/main.rs +++ b/bin/stylus-trace-studio/src/main.rs @@ -176,12 +176,12 @@ fn main() -> Result<()> { pub enum CiSubcommands { /// Initialize CI/CD performance regression checks Init { - /// Transaction hash to profile in CI + /// Transaction hash to profile in CI (optional) #[arg(short, long)] - tx: String, + tx: Option, - /// RPC endpoint URL - #[arg(short, long, default_value = "http://localhost:8547")] + /// RPC endpoint URL (optional) + #[arg(short, long)] rpc: Option, /// Percentage threshold for regressions (e.g., 1.0) diff --git a/crates/stylus-trace-core/src/commands/ci.rs b/crates/stylus-trace-core/src/commands/ci.rs index ada4ede..995d879 100644 --- a/crates/stylus-trace-core/src/commands/ci.rs +++ b/crates/stylus-trace-core/src/commands/ci.rs @@ -26,11 +26,11 @@ pub fn execute_ci_init(args: CiInitArgs) -> Result<()> { } // 2. Generate YAML - let rpc_line = if let Some(rpc) = &args.rpc_url { - format!(" rpc_url: \"{}\"\n", rpc) - } else { - String::new() - }; + + let tx_hash = args + .transaction_hash + .as_deref() + .unwrap_or("YOUR_TRANSACTION_HASH"); let workflow_yaml = format!( r#"name: Stylus Performance Check @@ -49,13 +49,21 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 + - name: Prepare Profiles + run: | + mkdir -p artifacts/capture + # If paths exist, stage them for the check + [ -f "artifacts/capture/baseline.json" ] || echo "{{}}" > artifacts/capture/baseline.json + [ -f "artifacts/capture/current_profile.json" ] || cp artifacts/capture/baseline.json artifacts/capture/current_profile.json + - name: Run Stylus Performance Check uses: CreativesOnchain/Stylus-Trace@main with: tx_hash: "{}" -{} threshold: "{}" + threshold: "{}" + skip_capture: "true" "#, - args.transaction_hash, rpc_line, args.threshold + tx_hash, args.threshold ); // 3. Write file diff --git a/crates/stylus-trace-core/src/commands/models.rs b/crates/stylus-trace-core/src/commands/models.rs index 9471fc1..e6d94ff 100644 --- a/crates/stylus-trace-core/src/commands/models.rs +++ b/crates/stylus-trace-core/src/commands/models.rs @@ -146,8 +146,8 @@ impl Default for DiffArgs { /// Arguments for the CI init command #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CiInitArgs { - /// Transaction hash to use for performance checks - pub transaction_hash: String, + /// Transaction hash to use for performance checks (optional) + pub transaction_hash: Option, /// RPC endpoint URL (optional) pub rpc_url: Option, @@ -162,7 +162,7 @@ pub struct CiInitArgs { impl Default for CiInitArgs { fn default() -> Self { Self { - transaction_hash: String::new(), + transaction_hash: None, rpc_url: Some("http://localhost:8547".to_string()), threshold: 1.0, force: false,