-
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (85 loc) · 4.13 KB
/
Copy pathphp-ci.yml
File metadata and controls
101 lines (85 loc) · 4.13 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
name: PHP CI
on:
push:
branches: [main]
paths:
- 'packages/php/**'
- '.github/workflows/php-ci.yml'
pull_request:
branches: [main]
paths:
- 'packages/php/**'
- '.github/workflows/php-ci.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: PHP ${{ matrix.php }} (${{ matrix.deps }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3', '8.4']
deps: ['core', 'full']
defaults:
run:
working-directory: packages/php
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php }}
extensions: json, simplexml, libxml
coverage: pcov
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: php-${{ matrix.php }}-${{ matrix.deps }}-composer-${{ hashFiles('packages/php/composer.lock') }}
restore-keys: php-${{ matrix.php }}-${{ matrix.deps }}-composer-
- name: Install dependencies
run: composer install --no-interaction --prefer-dist ${{ matrix.deps == 'core' && '--no-dev' || '' }}
- name: Run tests
if: matrix.deps == 'full'
run: vendor/bin/pest --coverage --coverage-clover coverage.xml --min=95
- name: Upload coverage to Codecov
if: matrix.php == '8.4' && matrix.deps == 'full'
uses: ./.github/actions/upload-coverage
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: php
files: packages/php/coverage.xml
- name: Run PHPStan
if: matrix.deps == 'full' && matrix.php == '8.4'
run: vendor/bin/phpstan analyse
- name: Check code style
if: matrix.deps == 'full' && matrix.php == '8.4'
run: vendor/bin/php-cs-fixer fix --dry-run --diff
# Cross-parity ensures PHP and JS produce identical results
- name: Cross-parity tests
if: matrix.deps == 'full' && matrix.php == '8.4'
run: composer test:parity
- name: Mutation tests (MSI = 85%)
if: matrix.deps == 'full' && matrix.php == '8.4'
run: bash scripts/mutation.sh
- name: Update Infection MSI badge (Gist)
if: matrix.deps == 'full' && matrix.php == '8.4' && github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
working-directory: packages/php
run: |
MSI=$(python3 -c "import json,sys; d=json.load(open('build/infection/infection.json')); print(d['stats']['msi'])")
if python3 -c "import sys; sys.exit(0 if float('$MSI') >= 90 else 1)"; then COLOR="brightgreen"
elif python3 -c "import sys; sys.exit(0 if float('$MSI') >= 85 else 1)"; then COLOR="green"
elif python3 -c "import sys; sys.exit(0 if float('$MSI') >= 75 else 1)"; then COLOR="yellow"
else COLOR="red"; fi
curl -s -X PATCH \
-H "Authorization: token $GIST_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"files\":{\"infection-msi.json\":{\"content\":\"{\\\"schemaVersion\\\":1,\\\"label\\\":\\\"Infection MSI\\\",\\\"message\\\":\\\"${MSI}%\\\",\\\"color\\\":\\\"${COLOR}\\\"}\"}}}"\
"https://api.github.com/gists/80c602b17107f88fb17794d4d44c94fa"