-
Notifications
You must be signed in to change notification settings - Fork 60
132 lines (107 loc) · 4.75 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
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
name: build
on:
- push
- pull_request
jobs:
tests:
name: PHP ${{ matrix.php }} Test on ${{ matrix.os }}
env:
extensions: bz2, dom, iconv, fileinfo, openssl, xml, zlib
key: cache-v1
PHPUNIT_COVERAGE: 0
PHP_INI: date.timezone='UTC', memory_limit=-1, opcache.enable=1, opcache.enable_cli=1
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
php:
- '7.4'
- '8.0'
- '8.1'
runs-on: ${{ matrix.os }}
steps:
-
name: Checkout
uses: actions/checkout@v1
-
name: Install linux dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install unzip p7zip-full
-
name: Install windows dependencies
if: matrix.os == 'windows-latest'
run: choco install zip unzip 7zip
-
name: Install macos dependencies
if: matrix.os == 'macos-latest'
run: brew install zip unzip p7zip
-
name: Disable JIT for PHP 8 on Linux and Mac
if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.php != '7.4'
run: echo "PHP_INI=\"${PHP_INI}, opcache.jit=0, opcache.jit_buffer_size=0\"" >> $GITHUB_ENV
-
name: Disable JIT for PHP 8 on Windows
if: matrix.os == 'windows-latest' && matrix.php != '7.4'
run: echo "PHP_INI=\"$PHP_INI, opcache.jit=0, opcache.jit_buffer_size=0\"" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
-
name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
coverage: pcov
ini-values: ${{ env.PHP_INI }}
tools: composer:v2, cs2pr
-
name: Determine composer cache directory on Linux or MacOS
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
-
name: Determine composer cache directory on Windows
if: matrix.os == 'windows-latest'
run: echo "COMPOSER_CACHE_DIR=~\AppData\Local\Composer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
-
name: Set coverage args
if: matrix.os == 'ubuntu-latest' && matrix.php == '7.4'
run: echo "PHPUNIT_COVERAGE=1" >> $GITHUB_ENV
-
name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php${{ matrix.php }}-composer-
-
name: Check PHP Version
run: php -v
-
name: Check Composer Version
run: composer -V
-
name: Check PHP Extensions
run: php -m
-
name: Validate composer.json and composer.lock
run: composer validate
-
name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
-
name: Run tests with phpunit
if: env.PHPUNIT_COVERAGE == 0
run: vendor/bin/phpunit -v --testsuite "all_tests" --group small,medium,large
-
name: Run tests with phpunit and coverage
if: env.PHPUNIT_COVERAGE == 1
run: vendor/bin/phpunit -v --coverage-clover=coverage.clover --testsuite "all_tests" --group small,medium,large
-
name: Static analysis
run: vendor/bin/psalm --shepherd --stats --output-format=checkstyle | cs2pr --graceful-warnings --colorize
-
name: Upload code coverage scrutinizer
if: env.PHPUNIT_COVERAGE == 1
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover