forked from expressjs/express
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (95 loc) · 3.5 KB
/
benchmarks.yml
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
name: Benchmark
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
permissions:
contents: read
pull-requests: write
jobs:
benchmarks:
if: contains(github.event.pull_request.labels.*.name, 'request-benchmarks')
runs-on: ubuntu-latest
steps:
- name: Install wrk
run: |
sudo apt-get update
sudo apt-get install -y wrk
- name: Checkout Source Branch
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
path: source
- name: Setup Node.js for Source Branch
uses: actions/setup-node@v3
with:
node-version: '22.x'
- name: Install Dependencies for Source Branch
run: |
cd source
npm install
- name: Run Benchmarks on Source Branch
run: |
cd source/benchmarks
make > source_results.log
- name: Save Source Results
id: save-source-results
uses: actions/upload-artifact@v2
with:
name: source-results
path: source/benchmarks/source_results.log
- name: Checkout Target Branch
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.ref }}
path: target
- name: Setup Node.js for Target Branch
uses: actions/setup-node@v3
with:
node-version: '22.x'
- name: Install Dependencies for Target Branch
run: |
cd target
npm install
- name: Run Benchmarks on Target Branch
run: |
cd target/benchmarks
make > target_results.log
- name: Save Target Results
id: save-target-results
uses: actions/upload-artifact@v2
with:
name: target-results
path: target/benchmarks/target_results.log
- name: Download Source Results
uses: actions/download-artifact@v2
with:
name: source-results
path: source-results
- name: Download Target Results
uses: actions/download-artifact@v2
with:
name: target-results
path: target-results
- name: Compare Results and Comment on PR
run: |
echo "Comparing benchmark results..."
# Compare the benchmark results and generate a summary
SOURCE_RESULTS=$(cat source-results/source_results.log)
TARGET_RESULTS=$(cat target-results/target_results.log)
DIFF=$(diff <(echo "$SOURCE_RESULTS") <(echo "$TARGET_RESULTS"))
# Create a comment body
COMMENT_BODY="### Benchmark Comparison\n\n"
COMMENT_BODY+="**Source Branch (${github.event.pull_request.head.ref}) Results:**\n\`\`\`\n$SOURCE_RESULTS\n\`\`\`\n\n"
COMMENT_BODY+="**Target Branch (${github.event.pull_request.base.ref}) Results:**\n\`\`\`\n$TARGET_RESULTS\n\`\`\`\n\n"
COMMENT_BODY+="**Differences:**\n\`\`\`\n$DIFF\n\`\`\`\n"
# Post the comment to the PR
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"body\":\"${COMMENT_BODY}\"}" \
"${{ github.event.pull_request.comments_url }}"
continue-on-error: true
- name: Remove request-benchmarks Label
run: |
curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
"${{ github.event.pull_request.issue_url }}/labels/request-benchmarks"