-
Notifications
You must be signed in to change notification settings - Fork 0
315 lines (268 loc) · 10.8 KB
/
ci.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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: ci
on:
push:
branches:
- master
- develop
- ci
pull_request:
branches:
- master
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
name: "Lint | PHP ${{ matrix.php-version }}"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
steps:
- uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: composer:v2
extensions: json, opcache
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-req=php+ --ignore-platform-req=ext-perfidious
- run: php -l perfidious.stub.php && php perfidious.stub.php
- name: phpcs
run: php vendor/bin/phpcs
- name: phpstan
run: php vendor/bin/phpstan analyze
test:
runs-on: ubuntu-latest
name: "Test | PHP ${{ matrix.php-version }} ${{ matrix.debug }}"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
debug:
- ""
include:
- php-version: "8.1"
debug: "debug"
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libcap-dev libpfm4-dev valgrind
version: 1
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: "none"
extensions: json, opcache
php-version: "${{ matrix.php-version }}"
tools: composer:v2
- run: phpize
- run: ./configure --enable-compile-warnings=error "${EXTRA_FLAGS}"
env:
EXTRA_FLAGS: ${{ matrix.debug == 'debug' && '--enable-perfidious-debug' || '' }}
- run: make
- run: sudo sysctl -w kernel.perf_event_paranoid=1
- run: make test
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
- run: make test TEST_PHP_ARGS='-m'
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
USE_ZEND_ALLOC: 0
- run: cat tests/*.log
if: failure()
coverage:
runs-on: ubuntu-latest
name: "Coverage | PHP ${{ matrix.php-version }} ${{ matrix.debug }}"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
debug:
- ""
include:
- php-version: "8.1"
debug: "debug"
steps:
- uses: actions/checkout@v4
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: lcov libcap-dev libpfm4-dev
version: 1
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: pcov
extensions: json, opcache
php-version: "${{ matrix.php-version }}"
tools: composer:v2
- run: phpize
- run: ./configure --enable-compile-warnings=error "${EXTRA_FLAGS}" CFLAGS="-fprofile-arcs -ftest-coverage ${CFLAGS}" LDFLAGS="--coverage ${LDFLAGS}"
env:
EXTRA_FLAGS: ${{ matrix.debug == 'debug' && '--enable-perfidious-debug' || '' }}
- run: lcov --directory . --zerocounters
- run: lcov --directory . --capture --compat-libtool --initial --output-file coverage.info
- run: make
- run: sudo sysctl -w kernel.perf_event_paranoid=1
- run: make test
env:
NO_INTERACTION: 1
REPORT_EXIT_STATUS: 1
- run: cat tests/*.log
if: failure()
- run: |
lcov --no-checksum --directory . --capture --compat-libtool --output-file coverage.info
lcov --remove coverage.info "/usr*" \
--remove coverage.info "*/.phpenv/*" \
--compat-libtool \
--output-file coverage.info
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
file: coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
slug: jbboehr/php-perf
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
file: coverage.info
format: lcov
parallel: true
finish:
needs: coverage
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
nix:
name: "nix (${{ matrix.name }})"
runs-on: ${{ matrix.os }}
needs: nix-matrix
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- name: Set Up Build Cache
uses: actions/cache@v4
id: nix-cache
with:
path: /tmp/nix-store.nar
key: nix-store.nar-${{ runner.os }}-${{ hashFiles('flake.lock') }}-${{ matrix.attr }}
restore-keys: |
nix-store.nar-${{ runner.os }}-${{ hashFiles('flake.lock') }}-${{ matrix.attr }}
nix-store.nar-${{ runner.os }}-${{ hashFiles('flake.lock') }}-
nix-store.nar-${{ runner.os }}-
- uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-23.11
extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm"
- name: Import Nix Store Cache
if: "steps.nix-cache.outputs.cache-hit == 'true'"
run: |
nix-store --import < /tmp/nix-store.nar
- run: sudo sysctl -w kernel.perf_event_paranoid=1
- run: nix build -L ".#${{ matrix.attr }}"
# - run: nix flake check -L
- name: Export Nix Store Cache
shell: bash
# partially based on https://github.com/NixOS/nix/issues/1245#issuecomment-282586759
run: |
drv="$(nix-store -qd "$(readlink result)")"
drvRefs="$( echo "$drv" | xargs nix-store -q --references )"
( echo "$drvRefs" | grep '[.]drv$' | xargs nix-store -q --outputs ;
echo "$drvRefs" | grep -v '[.]drv$' ) | \
xargs nix-store -r | \
xargs nix-store -qR |
xargs nix-store --export > /tmp/nix-store.nar
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
PHP_VERSION:
- "8.1"
- "8.2"
- "8.3"
DOCKER_NAME:
- debian
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- run: sudo sysctl -w kernel.perf_event_paranoid=1
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
file: .github/php-${{ matrix.DOCKER_NAME }}.Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: PHP_VERSION=${{ matrix.PHP_VERSION }}
tags: php-perfidious-${{ matrix.DOCKER_NAME }}
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
PHP_VERSION: ${{ matrix.PHP_VERSION }}
DOCKER_NAME: ${{ matrix.DOCKER_NAME }}
run: bash ./.github/scripts/docker.sh
docker-fedora:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
DOCKER_NAME:
- fedora
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- run: sudo sysctl -w kernel.perf_event_paranoid=1
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v5
with:
context: .
file: .github/php-${{ matrix.DOCKER_NAME }}.Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
tags: php-perfidious-${{ matrix.DOCKER_NAME }}
- name: I am tired of writing this shit in YAML and learning a new DSL for every CI service so I am putting everything in a FSCKING BASH SCRIPT
env:
DOCKER_NAME: ${{ matrix.DOCKER_NAME }}
TEST_PHP_EXECUTABLE: /usr/bin/php
run: bash ./.github/scripts/docker.sh