-
-
Notifications
You must be signed in to change notification settings - Fork 799
151 lines (129 loc) · 5.72 KB
/
benchmarks.yml
File metadata and controls
151 lines (129 loc) · 5.72 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
name: Benchmarks
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
- main-version-*
push:
branches:
- main
concurrency:
group: benchmarks-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
fusion-gateway:
name: "Fusion Gateway Benchmarks"
if: github.event_name == 'push' || github.event.pull_request.draft == false
runs-on: benchmarking
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- name: Checkout performance data repository
uses: actions/checkout@v4
with:
repository: ChilliCream/graphql-platform-performance-data
token: ${{ secrets.PERFORMANCE_DATA_TOKEN }}
path: performance-data-repo
fetch-depth: 0
show-progress: false
- name: Install k6
run: |
if ! command -v k6 &> /dev/null; then
echo "Installing k6..."
sudo gpg -k
sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list
sudo apt-get update
sudo apt-get install k6 -y
fi
k6 version
- name: Install jq for result parsing
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get install jq -y
fi
- name: Make scripts executable
working-directory: src/HotChocolate/Fusion-vnext/benchmarks/k6
run: chmod +x *.sh
- name: Run performance tests and collect data
working-directory: src/HotChocolate/Fusion-vnext/benchmarks/k6
run: ./run-and-collect-gateway.sh fusion-gateway-performance-data-current.json
- name: Fetch baseline performance data from external repo
if: github.event_name == 'pull_request'
run: |
if [ -f performance-data-repo/fusion-gateway-performance-data.json ]; then
echo "Baseline data fetched successfully from performance data repository"
cp performance-data-repo/fusion-gateway-performance-data.json baseline-performance.json
cat baseline-performance.json
else
echo "No baseline data found in performance data repository"
rm -f baseline-performance.json
fi
- name: Compare performance and generate report
if: github.event_name == 'pull_request'
working-directory: src/HotChocolate/Fusion-vnext/benchmarks/k6
run: |
chmod +x compare-gateway-performance.sh
./compare-gateway-performance.sh fusion-gateway-performance-data-current.json ../../../../../baseline-performance.json performance-report.md
- name: Comment PR with performance report
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const reportPath = 'src/HotChocolate/Fusion-vnext/benchmarks/k6/performance-report.md';
let report;
try {
report = fs.readFileSync(reportPath, 'utf8');
} catch (error) {
console.error('Failed to read performance report:', error);
return;
}
const timestamp = new Date().toUTCString();
const commitSha = context.sha.substring(0, 7);
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const commentBody = `${report}\n\n---\n*Run [${context.runId}](${runUrl}) • Commit ${commitSha} • ${timestamp}*`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody,
});
- name: Upload performance data as artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: fusion-gateway-performance-data
path: |
src/HotChocolate/Fusion-vnext/benchmarks/k6/fusion-gateway-performance-data-current.json
src/HotChocolate/Fusion-vnext/benchmarks/k6/performance-report.md
retention-days: 30
- name: Check for performance regression
if: github.event_name == 'pull_request'
working-directory: src/HotChocolate/Fusion-vnext/benchmarks/k6
run: |
if grep -q "⚠️ \*\*Performance regression detected" performance-report.md; then
echo "::warning::Performance regression detected! Please review the performance report."
fi
- name: Store performance data to external repository
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
working-directory: performance-data-repo
run: |
cp ../src/HotChocolate/Fusion-vnext/benchmarks/k6/fusion-gateway-performance-data-current.json fusion-gateway-performance-data.json
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add fusion-gateway-performance-data.json
if ! git diff --staged --quiet; then
git commit -m "Update Fusion Gateway performance data from ${{ github.sha }}"
git push
else
echo "No changes to performance data"
fi