-
Notifications
You must be signed in to change notification settings - Fork 5
113 lines (90 loc) · 3.32 KB
/
benchmark.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
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Benchmark"
on:
pull_request:
jobs:
phpbench:
name: "Benchmark"
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.3"
operating-system:
- "ubuntu-latest"
steps:
- name: "Install PHP"
uses: "shivammathur/[email protected]"
with:
coverage: "pcov"
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
extensions: pdo_sqlite
- name: "Checkout base"
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- uses: ramsey/[email protected]
with:
dependency-versions: ${{ matrix.dependencies }}
- name: "phpbench on base"
run: "vendor/bin/phpbench run tests/Benchmark --progress=none --report=default --tag=base"
- name: "Checkout"
uses: actions/checkout@v4
with:
clean: false
- uses: ramsey/[email protected]
with:
dependency-versions: ${{ matrix.dependencies }}
- name: "phpbench diff"
run: "vendor/bin/phpbench run tests/Benchmark --report=benchmark_compare --ref=base > bench.txt"
- name: "Get Bench Result"
id: phpbench
run: |
echo 'BENCH_RESULT<<EOF' >> $GITHUB_ENV
cat bench.txt >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- uses: actions/github-script@v7
with:
script: |
// Get the existing comments.
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
})
// Find any comment already made by the bot.
const botComment = comments.find(comment => comment.user.id === 41898282)
const commentBody = `
Hello :wave:
<details>
<summary>here is the most recent benchmark result:</summary>
<p>
\`\`\`
${{ env.BENCH_RESULT }}
\`\`\`
</p>
</details>
This comment gets update everytime a new commit comes in!
`;
if (context.payload.pull_request.head.repo.full_name !== 'patchlevel/event-sourcing') {
console.log('Not attempting to write comment on PR from fork');
} else {
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
body: commentBody
})
}
}