-
Notifications
You must be signed in to change notification settings - Fork 5
132 lines (107 loc) · 3.97 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# 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 }}
services:
postgres:
# Docker Hub image
image: "postgres:17.0"
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: eventstore
options: >-
--health-cmd "pg_isready"
ports:
- "5432:5432"
strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.3"
operating-system:
- "ubuntu-latest"
env:
DB_URL: 'pdo-pgsql://postgres:postgres@localhost:5432/eventstore?charset=utf8'
steps:
- name: "Install PHP"
uses: "shivammathur/[email protected]"
with:
coverage: none
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1, opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
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"
id: bench
run: 'vendor/bin/phpbench run tests/Benchmark --progress=none --report=diff --ref=base > bench.txt'
- name: "Get Bench Result"
if: ${{ success() || (failure() && steps.bench.conclusion == 'failure') }}
id: phpbench
run: |
echo 'BENCH_RESULT<<EOF' >> $GITHUB_ENV
cat bench.txt >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- uses: actions/github-script@v7
if: ${{ success() || (failure() && steps.bench.conclusion == 'failure') }}
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
})
}
}