-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (73 loc) · 2.48 KB
/
php.yml
File metadata and controls
88 lines (73 loc) · 2.48 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
name: PHP CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.4]
steps:
- uses: actions/checkout@v4
# Setup PHP
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug
extensions: mbstring, json, pdo, pdo_sqlite, sqlite3, xdebug
# Validate composer.json and composer.lock
- name: Validate composer.json and composer.lock
run: composer validate --strict
# Cache Composer dependencies
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
# Create var/cache folder for PHP-CS-Fixer
- name: Create cache folder
run: mkdir -p var/cache
# Install dependencies
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
# Fast checks first (fail early)
# PHPCS
- name: Check coding standards
run: vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --ansi
# PHPStan
- name: Run PHPStan
run: vendor/bin/phpstan analyse --memory-limit=512M --ansi
# PHPUnit (slowest — runs last)
- name: Run PHPUnit tests with coverage
shell: bash
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --colors=always | tee var/coverage-summary.txt
# Coverage threshold
- name: Check coverage threshold
run: |
COVERAGE=$(grep -oP 'Lines:\s+\K[\d.]+' var/coverage-summary.txt | head -1)
if [ -z "$COVERAGE" ]; then
echo "::error::Could not parse coverage from PHPUnit output"
exit 1
fi
echo "Line coverage: ${COVERAGE}%"
if (( $(echo "$COVERAGE < 100" | bc -l) )); then
echo "::error::Coverage ${COVERAGE}% is below 100% threshold"
exit 1
fi
# Upload coverage to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
with:
files: var/clover.xml
fail_ci_if_error: true