-
Notifications
You must be signed in to change notification settings - Fork 35
200 lines (164 loc) · 6.03 KB
/
ci.yml
File metadata and controls
200 lines (164 loc) · 6.03 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: CI
on:
pull_request:
push:
branches: [main]
jobs:
format:
name: Checks / Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run Pint
run: |
docker run --rm -v "$PWD":/app -w /app composer:2.7 sh -c \
"composer install --profile --ignore-platform-reqs --no-interaction && composer format:check"
analyze:
name: Checks / Analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: swoole
coverage: none
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-req=ext-opentelemetry
- name: PHPStan
run: composer analyze
refactor:
name: Checks / Refactor
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: swoole
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ hashFiles('composer.lock') }}
restore-keys: composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-req=ext-opentelemetry
- name: Rector (dry run)
run: composer refactor:check
unit:
name: Tests / Unit / PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
steps:
- uses: actions/checkout@v6
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: swoole
coverage: ${{ matrix.php == '8.3' && 'pcov' || 'none' }}
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ matrix.php }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --ignore-platform-req=ext-opentelemetry
- name: Run unit tests
if: matrix.php != '8.3'
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite unit
- name: Run unit tests with coverage
if: matrix.php == '8.3'
run: vendor/bin/phpunit --configuration phpunit.xml --testsuite unit --coverage-text --coverage-clover coverage.xml
- name: Upload coverage artifact
if: matrix.php == '8.3' && always()
uses: actions/upload-artifact@v7
with:
name: coverage-clover
path: coverage.xml
if-no-files-found: ignore
e2e:
name: Tests / E2E / ${{ matrix.adapter.display }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
adapter:
- { id: fpm, display: FPM }
- { id: swoole, display: Swoole }
steps:
- uses: actions/checkout@v6
- name: Build and wait for ${{ matrix.adapter.id }} to be healthy
run: docker compose up -d --build --wait ${{ matrix.adapter.id }}
- name: Run E2E tests
run: docker compose exec -T ${{ matrix.adapter.id }} vendor/bin/phpunit --configuration phpunit.xml --testsuite e2e-${{ matrix.adapter.id }}
- name: Dump container logs on failure
if: failure()
run: docker compose logs ${{ matrix.adapter.id }}
benchmark:
name: Benchmark
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6
- name: Build and wait for swoole to be healthy
run: docker compose up -d --build --wait swoole
- name: Setup k6
uses: grafana/setup-k6-action@v1
- name: Run k6 benchmark
uses: grafana/run-k6-action@v1
with:
path: tests/bench/benchmark.js
flags: --summary-export=summary.json
env:
BASE_URL: http://localhost:9501
- name: Render PR comment body
if: always() && hashFiles('summary.json') != ''
run: |
jq -r '
.metrics as $m |
[
"### k6 benchmark",
"",
"| Throughput | Requests | Fail rate | p50 | p95 |",
"| --- | --- | --- | --- | --- |",
"| \(($m.http_reqs.rate // 0) | floor) req/s | \($m.http_reqs.count // 0) | \((($m.http_req_failed.value // 0) * 100) * 1000 | floor / 1000)% | \(($m.http_req_duration.med // 0) * 100 | floor / 100) ms | \(($m.http_req_duration["p(95)"] // 0) * 100 | floor / 100) ms |"
] | .[]
' summary.json > summary.md
- name: Upload raw k6 summary
if: always()
uses: actions/upload-artifact@v7
with:
name: k6-summary
path: summary.json
if-no-files-found: ignore
- name: Comment benchmark summary on PR
if: github.event_name == 'pull_request' && always() && hashFiles('summary.md') != ''
uses: marocchino/sticky-pull-request-comment@v3
with:
header: k6-benchmark
path: summary.md
- name: Dump swoole logs on failure
if: failure()
run: docker compose logs swoole