diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..b0099c0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,55 @@ +name: Rust + +on: [push, pull_request] + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + name: "Lint" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: "Install Rustfmt" + run: rustup component add rustfmt + - name: "Install uv" + run: curl -LsSf https://astral.sh/uv/install.sh | sh + - name: "rustfmt" + run: cargo fmt --all --check + - name: "Prettier" + run: npx prettier --check "**/*.{md,yml}" + - name: "Ruff" + run: | + uvx ruff check --diff . + uvx ruff format --diff . + + clippy: + name: "Clippy" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # > selecting a toolchain either by action or manual `rustup` calls should happen + # > before Swatinem/rust-cache, as the cache uses the current rustc version as its cache key + - name: "Install clippy" + run: | + rustup toolchain install stable --profile minimal + rustup component add clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy + - run: cargo clippy --workspace --all-features + + test: + name: "Test" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # > selecting a toolchain either by action or manual `rustup` calls should happen + # > before Swatinem/rust-cache, as the cache uses the current rustc version as its cache key + - run: rustup toolchain install stable --profile minimal + - uses: Swatinem/rust-cache@v2 + - run: cargo test + - run: cargo test --workspace --all-features diff --git a/Changelog.md b/Changelog.md index a324464..b8ef19d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,20 +2,20 @@ ## 0.3.0 -* Update svg to 0.17.0 +- Update svg to 0.17.0 ## 0.2.0 -* Show whether an active span is running on and blocking the main thread or whether it's running in a threadpool with +- Show whether an active span is running on and blocking the main thread or whether it's running in a threadpool with `tokio::task::spawn_blocking`. `--color-top`/`color_top` gets split into two colors, color top main and color top threadpool. The former is used when the task is running on the main thread, the latter is used when it's offloaded to the threadpool. -* Colorblind friendly default colors (http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/#a-colorblind-friendly-palette): - * color top blocking: #E69F0088 - * color top threadpool: #56B4E988 - * color bottom: #E69F0088 +- Colorblind friendly default colors (http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/#a-colorblind-friendly-palette): + - color top blocking: #E69F0088 + - color top threadpool: #56B4E988 + - color bottom: #E69F0088 ## 0.1.2 -* Add `--inline-field` / `inline_field` option: If the is only one field, display its value inline. Since the text is +- Add `--inline-field` / `inline_field` option: If the is only one field, display its value inline. Since the text is not limited to its box, text can overlap and become unreadable. diff --git a/Readme.md b/Readme.md index aa799fc..747c1fc 100644 --- a/Readme.md +++ b/Readme.md @@ -65,7 +65,7 @@ cargo run --bin plot --features plot --features cli -- --multi-lane examples/cac The `traces.ndjson` output file will look something like below, where each section where a span is active is one line. -```ndjson +````ndjson [...] {"id":6,"name":"read_cache","start":{"secs":0,"nanos":122457871},"end":{"secs":0,"nanos":122463135},"parents":[5],"fields":{"id":"2"}} {"id":5,"name":"cached_network_request","start":{"secs":0,"nanos":122433854},"end":{"secs":0,"nanos":122499689},"parents":[],"fields":{"id":"2","api":"https://example.net/cached"}} @@ -76,7 +76,7 @@ The `traces.ndjson` output file will look something like below, where each secti {"id":2251799813685253,"name":"cached_network_request","start":{"secs":0,"nanos":126144140},"end":{"secs":0,"nanos":126213181},"parents":[],"fields":{"api":"https://example.net/cached","id":"3"}} {"id":27021597764222977,"name":"make_network_request","start":{"secs":0,"nanos":128343009},"end":{"secs":0,"nanos":128383121},"parents":[13510798882111491],"fields":{"api":"https://example.net/cached","id":"0"}}``` [...] -``` +```` Note that 0 is the time of the first span, not the start of the process. diff --git a/src/bin/plot.py b/src/bin/plot.py index 97d0b55..510e82e 100755 --- a/src/bin/plot.py +++ b/src/bin/plot.py @@ -10,6 +10,7 @@ python plot.py traces.ndjson ``` """ + import os from argparse import ArgumentParser from collections import defaultdict