-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (76 loc) · 3.63 KB
/
build.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
name: build
on:
workflow_dispatch:
push:
schedule:
- cron: '0 12 * * 0'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.4', '8.0', '8.1', '8.2', '8.3']
composer: ['--prefer-lowest', '']
exclude:
- php: '8.0'
composer: '--prefer-lowest'
- php: '8.1'
composer: '--prefer-lowest'
- php: '8.2'
composer: '--prefer-lowest'
- php: '8.3'
composer: '--prefer-lowest'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, json, mbstring, libxml
coverage: xdebug
- name: Git checkout
uses: actions/checkout@v4
- name: Validate composer.json and composer.lock
run: composer validate
- name: Prepare Composer cache vars
id: composer
run: |
echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "cache_key=$(date +'%Y-%m-%d')-${{ runner.os }}-${{ matrix.php }}${{ matrix.composer }}-composer-" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer.outputs.cache_dir }}
key: ${{ steps.composer.outputs.cache_key }}${{ hashFiles('**/composer.json') }}
restore-keys: ${{ steps.composer.outputs.cache_key }}
- name: Update Composer dependencies
run: composer update ${{ matrix.composer }} --prefer-dist --no-progress --no-suggest --no-interaction
- name: Run PHP Code Sniffer
run: composer run-script test:phpcs
if: success()
- name: Run PHPStan
run: composer run-script test:phpstan
if: success() || failure()
# Remove after drop PHPUnit version < 9.3 support
- name: Select PHPUnit config
run: |
PHPUNIT_VERSION=$(composer show phpunit/phpunit | grep -oP "versions : \* \K.+")
PHPUNIT_VERSION_MAJOR=$(echo $PHPUNIT_VERSION | grep -oP "^\d+")
PHPUNIT_VERSION_MINOR=$(echo $PHPUNIT_VERSION | grep -oP "\d+\.\K\d+")
echo "PHPUnit version: $PHPUNIT_VERSION"
if [[ $PHPUNIT_VERSION_MAJOR -lt 9 || ( $PHPUNIT_VERSION_MAJOR -eq 9 && $PHPUNIT_VERSION_MINOR -lt 3 ) ]]; then
echo "Using deprecated config: \"phpunit.xml.deprecated\""
mv phpunit.xml.deprecated phpunit.xml
else
echo "Using regular config: \"phpunit.xml\""
fi
if: success() || failure()
- name: Run PHPUnit with coverage
run: composer run-script test:phpunit-coverage
if: success() || failure()
- name: Run Covelyzer
run: composer run-script test:covelyzer
if: success() || failure()
- name: Run PHPBench
run: composer run-script test:phpbench
if: (success() || failure()) && matrix.php != '7.1' && matrix.composer != '--prefer-lowest'
# Skip for PHP 7.1 or "prefer lowest" due to obsolete config syntax in v0.16