Skip to content

Commit 2ff9b4e

Browse files
committed
Add deployed demo
1 parent 6aaf41c commit 2ff9b4e

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/pages.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deploy Trace Viewer Demo
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: pages-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: dtolnay/rust-toolchain@stable
23+
24+
- uses: Swatinem/rust-cache@v2
25+
26+
- name: Build demo trace
27+
run: cargo run --example realistic_workload
28+
timeout-minutes: 5
29+
30+
- name: Assemble site
31+
run: |
32+
mkdir -p _site
33+
cp dial9-tokio-telemetry/trace_viewer.html _site/trace_viewer.html
34+
cp realistic_trace.bin _site/demo.bin
35+
cp demo/index.html _site/index.html
36+
37+
- name: Deploy (main)
38+
if: github.ref == 'refs/heads/main'
39+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
publish_dir: ./_site
43+
44+
- name: Deploy (PR preview)
45+
if: github.event_name == 'pull_request'
46+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
publish_dir: ./_site
50+
destination_dir: pr/${{ github.event.number }}
51+
52+
- name: Comment PR with preview link
53+
if: github.event_name == 'pull_request'
54+
uses: actions/github-script@v7
55+
with:
56+
script: |
57+
const url = `https://${context.repo.owner}.github.io/${context.repo.repo}/pr/${context.issue.number}/`;
58+
const body = `🔍 **Trace Viewer Preview:** ${url}`;
59+
const { data: comments } = await github.rest.issues.listComments({
60+
...context.repo, issue_number: context.issue.number
61+
});
62+
const existing = comments.find(c => c.body.includes('Trace Viewer Preview'));
63+
if (existing) {
64+
await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body });
65+
} else {
66+
await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body });
67+
}

demo/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!doctype html>
2+
<meta http-equiv="refresh" content="0;url=trace_viewer.html?trace=demo.bin">
3+
<a href="trace_viewer.html?trace=demo.bin">Open Trace Viewer Demo</a>

dial9-tokio-telemetry/trace_viewer.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,21 @@
15901590
if (trace) renderAll();
15911591
});
15921592

1593+
// ── Auto-load trace from ?trace=URL parameter ──
1594+
(function autoLoadFromUrl() {
1595+
const traceUrl = new URLSearchParams(location.search).get("trace");
1596+
if (!traceUrl) return;
1597+
dropZone.innerHTML = "Loading trace…";
1598+
fetch(traceUrl)
1599+
.then(r => { if (!r.ok) throw new Error(r.status); return r.arrayBuffer(); })
1600+
.then(buf => {
1601+
trace = parseTrace(buf);
1602+
processTrace();
1603+
showViewer(traceUrl.split("/").pop());
1604+
})
1605+
.catch(err => { dropZone.innerHTML = "Failed to load trace: " + err.message; });
1606+
})();
1607+
15931608
// ── Legend (inline in toolbar area) ──
15941609
(function addLegend() {
15951610
const tb = document.getElementById("toolbar");

0 commit comments

Comments
 (0)