@@ -15,8 +15,187 @@ concurrency:
1515 cancel-in-progress : true
1616
1717jobs :
18+ fusion-gateway :
19+ name : " Fusion Gateway Benchmarks"
20+ if : github.event_name == 'push' || github.event.pull_request.draft == false
21+ runs-on : benchmarking
22+ permissions :
23+ contents : write
24+ pull-requests : write
25+
26+ steps :
27+ - name : Checkout current repository
28+ uses : actions/checkout@v4
29+ with :
30+ fetch-depth : 0
31+ show-progress : false
32+
33+ - name : Checkout performance data repository
34+ uses : actions/checkout@v4
35+ with :
36+ repository : ChilliCream/graphql-platform-performance-data
37+ token : ${{ secrets.PERFORMANCE_DATA_TOKEN }}
38+ path : performance-data-repo
39+ fetch-depth : 0
40+ show-progress : false
41+
42+ - name : Install k6
43+ run : |
44+ if ! command -v k6 &> /dev/null; then
45+ echo "Installing k6..."
46+ sudo gpg -k
47+ sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D69
48+ 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
49+ sudo apt-get update
50+ sudo apt-get install k6 -y
51+ fi
52+ k6 version
53+
54+ - name : Install jq for result parsing
55+ run : |
56+ if ! command -v jq &> /dev/null; then
57+ sudo apt-get install jq -y
58+ fi
59+
60+ - name : Make scripts executable
61+ working-directory : src/HotChocolate/Fusion-vnext/benchmarks/k6
62+ run : chmod +x *.sh
63+
64+ - name : Run Fusion benchmarks
65+ working-directory : src/HotChocolate/Fusion-vnext/benchmarks/k6
66+ run : |
67+ echo "Starting Fusion Gateway benchmarks..."
68+ ./run-benchmarks.sh 2>&1 | tee /tmp/fusion-benchmark.log
69+
70+ - name : Generate performance report
71+ if : always()
72+ working-directory : src/HotChocolate/Fusion-vnext/benchmarks/k6
73+ run : |
74+ # Create a markdown report from the results
75+ cat > fusion-performance-report.md << 'EOF'
76+ # Fusion Gateway Performance Report
77+
78+ ## Test Results
79+
80+ ### Single Fetch Test (Simple Query)
81+
82+ EOF
83+
84+ # Add single fetch results if they exist
85+ if [ -f results/summary-aot-single.json ] && [ -f results/summary-release-single.json ]; then
86+ echo "#### AOT Mode" >> fusion-performance-report.md
87+ echo '```' >> fusion-performance-report.md
88+ jq -r '.metrics.http_req_duration | "p50: \(.values."p(50)")ms, p95: \(.values."p(95)")ms, p99: \(.values."p(99)")ms"' results/summary-aot-single.json >> fusion-performance-report.md
89+ echo '```' >> fusion-performance-report.md
90+ echo "" >> fusion-performance-report.md
91+
92+ echo "#### Release Mode" >> fusion-performance-report.md
93+ echo '```' >> fusion-performance-report.md
94+ jq -r '.metrics.http_req_duration | "p50: \(.values."p(50)")ms, p95: \(.values."p(95)")ms, p99: \(.values."p(99)")ms"' results/summary-release-single.json >> fusion-performance-report.md
95+ echo '```' >> fusion-performance-report.md
96+ echo "" >> fusion-performance-report.md
97+ fi
98+
99+ echo "### No Recursion Test (Complex Query)" >> fusion-performance-report.md
100+ echo "" >> fusion-performance-report.md
101+
102+ # Add no recursion results if they exist
103+ if [ -f results/summary-aot-no-recursion.json ] && [ -f results/summary-release-no-recursion.json ]; then
104+ echo "#### AOT Mode" >> fusion-performance-report.md
105+ echo '```' >> fusion-performance-report.md
106+ jq -r '.metrics.http_req_duration | "p50: \(.values."p(50)")ms, p95: \(.values."p(95)")ms, p99: \(.values."p(99)")ms"' results/summary-aot-no-recursion.json >> fusion-performance-report.md
107+ echo '```' >> fusion-performance-report.md
108+ echo "" >> fusion-performance-report.md
109+
110+ echo "#### Release Mode" >> fusion-performance-report.md
111+ echo '```' >> fusion-performance-report.md
112+ jq -r '.metrics.http_req_duration | "p50: \(.values."p(50)")ms, p95: \(.values."p(95)")ms, p99: \(.values."p(99)")ms"' results/summary-release-no-recursion.json >> fusion-performance-report.md
113+ echo '```' >> fusion-performance-report.md
114+ echo "" >> fusion-performance-report.md
115+ fi
116+
117+ # Run the comparison script if available
118+ if [ -x compare-results.sh ]; then
119+ echo "## AOT vs Release Comparison" >> fusion-performance-report.md
120+ echo "" >> fusion-performance-report.md
121+ echo '```' >> fusion-performance-report.md
122+ ./compare-results.sh >> fusion-performance-report.md 2>&1 || true
123+ echo '```' >> fusion-performance-report.md
124+ fi
125+
126+ cat fusion-performance-report.md
127+
128+ - name : Comment PR with performance report
129+ if : github.event_name == 'pull_request'
130+ uses : actions/github-script@v7
131+ with :
132+ github-token : ${{ secrets.GITHUB_TOKEN }}
133+ script : |
134+ const fs = require('fs');
135+ const reportPath = 'src/HotChocolate/Fusion-vnext/benchmarks/k6/fusion-performance-report.md';
136+
137+ let report;
138+ try {
139+ report = fs.readFileSync(reportPath, 'utf8');
140+ } catch (error) {
141+ console.log('No performance report found, skipping comment');
142+ return;
143+ }
144+
145+ const timestamp = new Date().toUTCString();
146+ const commitSha = context.sha.substring(0, 7);
147+ const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
148+
149+ const commentBody = `${report}\n\n---\n*Run [${context.runId}](${runUrl}) • Commit ${commitSha} • ${timestamp}*`;
150+
151+ await github.rest.issues.createComment({
152+ owner: context.repo.owner,
153+ repo: context.repo.repo,
154+ issue_number: context.issue.number,
155+ body: commentBody,
156+ });
157+
158+ - name : Upload performance data as artifact
159+ uses : actions/upload-artifact@v4
160+ if : always()
161+ with :
162+ name : fusion-performance-data
163+ path : |
164+ src/HotChocolate/Fusion-vnext/benchmarks/k6/results/*.json
165+ src/HotChocolate/Fusion-vnext/benchmarks/k6/fusion-performance-report.md
166+ /tmp/fusion-benchmark.log
167+ retention-days : 30
168+
169+ - name : Store performance data to external repository
170+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
171+ working-directory : performance-data-repo
172+ run : |
173+ # Create directory for Fusion data if it doesn't exist
174+ mkdir -p fusion-gateway
175+
176+ # Copy the new performance data
177+ if [ -d ../src/HotChocolate/Fusion-vnext/benchmarks/k6/results ]; then
178+ cp -r ../src/HotChocolate/Fusion-vnext/benchmarks/k6/results/* fusion-gateway/
179+ fi
180+
181+ # Configure git
182+ git config user.name "github-actions[bot]"
183+ git config user.email "github-actions[bot]@users.noreply.github.com"
184+
185+ # Add and commit the performance data
186+ git add fusion-gateway/
187+
188+ # Only commit if there are changes
189+ if ! git diff --staged --quiet; then
190+ git commit -m "Update Fusion Gateway performance data from ${{ github.sha }}"
191+ git push
192+ else
193+ echo "No changes to Fusion performance data"
194+ fi
195+
18196 hotchocolate-core :
19197 name : " HotChocolate Core Benchmarks"
198+ needs : fusion-gateway
20199 if : github.event_name == 'push' || github.event.pull_request.draft == false
21200 runs-on : benchmarking
22201 permissions :
0 commit comments