Repository navigation
152 lines (134 loc) · 6.33 KB
/
Copy pathnode-benchmarks.yml
File metadata and controls
152 lines (134 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Node SDK benchmarks
on: [pull_request]
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
benchmark:
runs-on: ubuntu-24.04
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
shard: [flags-single, flags-scaling, flags-memory, capture]
permissions:
contents: read
env:
CI: 'true'
TURBO_TELEMETRY_DISABLED: '1'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '24.13.0'
package-manager-cache: false
- uses: pnpm/setup@a0881977cd8ea73b1ed212236c99ca10dcc80cf4 # v3.1.1
with:
cache: false
install: false
- name: Prepare pinned baseline
env:
TARGET_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
BASE_WORKTREE="$RUNNER_TEMP/node-benchmark-base"
export RESULTS="$RUNNER_TEMP/node-benchmark-results"
printf 'BASE_WORKTREE=%s\nRESULTS=%s\n' "$BASE_WORKTREE" "$RESULTS" >> "$GITHUB_ENV"
BASE_SHA=$(git merge-base "$TARGET_SHA" "$HEAD_SHA")
git worktree add --detach "$BASE_WORKTREE" "$BASE_SHA"
mkdir -p "$RESULTS"
node -e 'require("fs").writeFileSync(process.env.RESULTS + "/revisions.json", JSON.stringify({target: process.env.TARGET_SHA, head: process.env.HEAD_SHA, base: process.argv[1]}, null, 2))' "$BASE_SHA"
- name: Build head
run: |
pnpm install --frozen-lockfile --filter posthog-node...
pnpm turbo run build --filter=posthog-node
- name: Build baseline
run: |
cd "$BASE_WORKTREE"
pnpm install --frozen-lockfile --filter posthog-node...
pnpm turbo run build --filter=posthog-node
- name: Test measurement controls and fixtures
run: pnpm --filter posthog-node test:benchmarks
- name: Measure paired base and head
id: measure
timeout-minutes: 12
run: |
node packages/node/benchmarks/run.mjs \
--base "$BASE_WORKTREE/packages/node" \
--head "$GITHUB_WORKSPACE/packages/node" \
--output "$RESULTS" \
--repetitions 6 \
--shard "${{ matrix.shard }}"
- name: Upload raw shard results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: benchmark-shard-${{ matrix.shard }}
path: |
${{ runner.temp }}/node-benchmark-results/base.json
${{ runner.temp }}/node-benchmark-results/head.json
${{ runner.temp }}/node-benchmark-results/revisions.json
if-no-files-found: warn
retention-days: 14
aggregate:
needs: benchmark
if: ${{ !cancelled() }}
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: benchmark-shard-*
path: ${{ runner.temp }}/node-benchmark-shards
merge-multiple: false
- name: Collect and render benchmark comparison
uses: PostHog/.github/.github/actions/benchmark-report@3322f26f21f088ad5e5960d65a916971e309ac0b # SDK benchmark reporting (PostHog/.github PR #84)
with:
mode: collect
source-status: ${{ needs.benchmark.result }}
shard-manifest: packages/node/benchmarks/shards.json
shard-directory: ${{ runner.temp }}/node-benchmark-shards
output-directory: ${{ runner.temp }}/node-benchmark-report
- name: Upload rendered comparison
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: node-benchmark-report
path: |
${{ runner.temp }}/node-benchmark-report/report.md
${{ runner.temp }}/node-benchmark-report/comparison.json
if-no-files-found: ignore
retention-days: 14
- name: Upload raw benchmark results
if: always()
id: results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: node-benchmark-results
path: |
${{ runner.temp }}/node-benchmark-report/bundle.json
${{ runner.temp }}/node-benchmark-report/revisions.json
if-no-files-found: warn
retention-days: 14
- name: Link results
if: always()
env:
ARTIFACT_URL: ${{ steps.results.outputs.artifact-url }}
run: |
printf '## Node SDK benchmark data\n\n' >> "$GITHUB_STEP_SUMMARY"
if [[ -n "$ARTIFACT_URL" ]]; then
printf '[Download paired measurements and execution metadata](%s)\n\n' "$ARTIFACT_URL" >> "$GITHUB_STEP_SUMMARY"
fi
printf 'Measurements are informational. Check workload statuses before comparing values.\n' >> "$GITHUB_STEP_SUMMARY"