Repository navigation
173 lines (154 loc) · 5.37 KB
/
Copy pathci-performance.yml
File metadata and controls
173 lines (154 loc) · 5.37 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: ci-performance
on:
pull_request:
branches:
- alpha
- beta
- release
- 'release-[0-9]+.x.x'
- next-major
paths-ignore:
- '**.md'
- 'docs/**'
env:
NODE_VERSION: 24.11.0
MONGODB_VERSION: 8.0.4
permissions:
contents: read
jobs:
performance-check:
name: Benchmarks
runs-on: ubuntu-latest
# Allows flagged benchmarks to be measured again, see benchmark/compare.js
timeout-minutes: 45
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1
# The base branch is kept in a separate directory, so that both builds are available to
# measure flagged benchmarks again
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
fetch-depth: 1
path: base
- name: Use PR benchmark script for base branch
run: |
if [ -d benchmark ]; then
rm -rf base/benchmark
cp -r benchmark base/
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: |
package-lock.json
base/package-lock.json
- name: Install dependencies (base)
working-directory: base
run: npm ci
- name: Build Parse Server (base)
working-directory: base
run: npm run build
- name: Install dependencies (PR)
run: npm ci
- name: Build Parse Server (PR)
run: npm run build
- name: Run baseline benchmarks
id: baseline
working-directory: base
env:
NODE_ENV: production
run: |
set -o pipefail
echo "Running baseline benchmarks..."
if [ ! -f "benchmark/performance.js" ]; then
echo "⚠️ Benchmark script not found - this is expected for new features"
echo "Skipping baseline benchmark"
echo '[]' > ../baseline.json
echo "Baseline: N/A (no benchmark script)" > ../baseline-output.txt
exit 0
fi
taskset -c 0 npm run benchmark 2>&1 | tee ../baseline-output.txt || npm run benchmark 2>&1 | tee ../baseline-output.txt || true
# Extract JSON from output (everything between first [ and last ])
sed -n '/^\[/,/^\]/p' ../baseline-output.txt > ../baseline.json || echo '[]' > ../baseline.json
continue-on-error: true
- name: Upload baseline results
uses: actions/upload-artifact@v4
with:
name: baseline-benchmark
path: |
baseline.json
baseline-output.txt
retention-days: 7
- name: Run PR benchmarks
id: pr-bench
env:
NODE_ENV: production
run: |
set -o pipefail
echo "Running PR benchmarks..."
taskset -c 0 npm run benchmark 2>&1 | tee pr-output.txt || npm run benchmark 2>&1 | tee pr-output.txt || true
# Extract JSON from output (everything between first [ and last ])
sed -n '/^\[/,/^\]/p' pr-output.txt > pr.json || echo '[]' > pr.json
continue-on-error: true
- name: Upload PR results
uses: actions/upload-artifact@v4
with:
name: pr-benchmark
path: |
pr.json
pr-output.txt
retention-days: 7
- name: Verify benchmark files exist
run: |
echo "Checking for benchmark result files..."
if [ ! -f baseline.json ] || [ ! -s baseline.json ]; then
echo "⚠️ baseline.json is missing or empty, creating empty array"
echo '[]' > baseline.json
fi
if [ ! -f pr.json ] || [ ! -s pr.json ]; then
echo "⚠️ pr.json is missing or empty, creating empty array"
echo '[]' > pr.json
fi
echo "baseline.json size: $(wc -c < baseline.json) bytes"
echo "pr.json size: $(wc -c < pr.json) bytes"
- name: Compare benchmark results
id: compare
env:
NODE_ENV: production
BENCHMARK_BASE_DIR: base
BENCHMARK_COMMAND: taskset -c 0 npm run benchmark
run: |
set -o pipefail
# A PR branch that predates the comparison script has to be updated to be compared
if [ ! -f benchmark/compare.js ]; then
echo "⚠️ Benchmarks cannot be compared because this branch does not contain \`benchmark/compare.js\`. Update the branch with the base branch." | tee comparison.md
exit 1
fi
node benchmark/compare.js baseline.json pr.json | tee comparison.md
- name: Upload comparison
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-comparison
path: |
comparison.md
retest-output.txt
retention-days: 30
- name: Generate job summary
if: always()
run: |
if [ -f comparison.md ]; then
cat comparison.md >> $GITHUB_STEP_SUMMARY
else
echo "⚠️ Benchmark comparison not available" >> $GITHUB_STEP_SUMMARY
fi
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true