Repository navigation
134 lines (114 loc) · 4.66 KB
/
Copy pathperformance.yml
File metadata and controls
134 lines (114 loc) · 4.66 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
name: Performance
on:
pull_request:
branches: [ main ]
# Cancel in-flight perf runs on the same PR to free runner capacity.
concurrency:
group: perf-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
perf-regression:
runs-on: ubuntu-latest
# Headroom for two full benchmark runs (candidate + baseline) plus npm
# installs and tarball packing. Each benchmark run is bounded by
# scenarios * (warmup + samples * duration + per-child init).
timeout-minutes: 40
env:
NODE_VERSION: '22.23.4'
PERF_SAMPLES: '3'
PERF_DURATION: '5'
PERF_WARMUP: '1'
PERF_REGRESSION_THRESHOLD: '15'
steps:
- name: Checkout PR (candidate)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: pr
- name: Checkout base branch (baseline)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.ref }}
path: baseline
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ env.NODE_VERSION }}
# ---- Build & pack BOTH versions of the package up-front ----
- name: Generate dummy TLS certs (PR)
working-directory: pr
run: openssl req -x509 -nodes -newkey rsa -keyout ./test/certs/server-key.pem -out ./test/certs/server-cert.pem -days 1 -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Root/OU=Test/CN=ca"
- name: Install + build + pack candidate
working-directory: pr
run: |
npm ci
npm run build
npm pack
mv applicationinsights-*.tgz "$GITHUB_WORKSPACE/candidate.tgz"
- name: Generate dummy TLS certs (baseline)
working-directory: baseline
run: openssl req -x509 -nodes -newkey rsa -keyout ./test/certs/server-key.pem -out ./test/certs/server-cert.pem -days 1 -subj "/C=CL/ST=RM/L=OpenTelemetryTest/O=Root/OU=Test/CN=ca"
- name: Install + build + pack baseline
working-directory: baseline
run: |
npm ci
npm run build
npm pack
mv applicationinsights-*.tgz "$GITHUB_WORKSPACE/baseline.tgz"
# ---- Use the PR's perf harness for BOTH runs (consistent code) ----
- name: Install perf harness deps (PR)
working-directory: pr/test/performanceTests
run: npm ci
- name: Install CANDIDATE applicationinsights into perf harness
working-directory: pr/test/performanceTests
run: npm install --no-save --no-package-lock "$GITHUB_WORKSPACE/candidate.tgz"
- name: Build perf harness (TS -> dist-esm)
working-directory: pr/test/performanceTests
run: npm run build
- name: Run candidate benchmarks
working-directory: pr/test/performanceTests
run: |
node runBenchmarks.mjs \
--out "$GITHUB_WORKSPACE/candidate.json" \
--samples "$PERF_SAMPLES" \
--duration "$PERF_DURATION" \
--warmup "$PERF_WARMUP"
- name: Install BASELINE applicationinsights into perf harness
working-directory: pr/test/performanceTests
run: npm install --no-save --no-package-lock "$GITHUB_WORKSPACE/baseline.tgz"
- name: Run baseline benchmarks
working-directory: pr/test/performanceTests
run: |
node runBenchmarks.mjs \
--out "$GITHUB_WORKSPACE/baseline.json" \
--samples "$PERF_SAMPLES" \
--duration "$PERF_DURATION" \
--warmup "$PERF_WARMUP"
# ---- Compare for gating; the artifact is consumed by the companion
# `performance-comment.yml` workflow which posts the PR comment under
# the base repository's trusted token. ----
- name: Compare results
id: compare
working-directory: pr/test/performanceTests
run: |
set +e
node comparePerf.mjs \
"$GITHUB_WORKSPACE/baseline.json" \
"$GITHUB_WORKSPACE/candidate.json" \
"$GITHUB_WORKSPACE/perf-comparison.md"
echo "exit=$?" >> "$GITHUB_OUTPUT"
- name: Upload perf results artifact
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: perf-results
path: |
baseline.json
candidate.json
perf-comparison.md
if-no-files-found: warn
- name: Fail job on gating regression
if: steps.compare.outputs.exit != '0'
run: |
echo "Performance regression beyond ${PERF_REGRESSION_THRESHOLD}% detected." >&2
exit 1