1
+ name : " PHP"
2
+ on :
3
+ push :
4
+ branches :
5
+ - " main"
6
+ pull_request :
7
+ branches :
8
+ - " main"
9
+ permissions :
10
+ contents : " read"
11
+ jobs :
12
+ # PHP lint for different PHP versions
13
+ build :
14
+ runs-on : " ubuntu-latest"
15
+ strategy :
16
+ matrix :
17
+ php-version :
18
+ - " 7.4"
19
+ - " 8.1"
20
+ env :
21
+ CC_TEST_REPORTER_ID : " a8cbf54ef2884175dc3bb747b33c826351d3a2d758f9145a5eeac97e48b36a34"
22
+ name : " PHP ${{ matrix.php-version }}"
23
+ steps :
24
+ - # git checkout
25
+ name : " git checkout"
26
+ uses : " actions/checkout@v3"
27
+ - # Setup PHP
28
+ name : " Setup PHP"
29
+ uses : " shivammathur/setup-php@v2"
30
+ with :
31
+ php-version : " ${{ matrix.php-version }}"
32
+ coverage : " xdebug"
33
+ - # Check PHP version
34
+ name : " Check PHP version"
35
+ run : " php -v"
36
+ - # Lint PHP files
37
+ name : " Lint PHP files"
38
+ run : |
39
+ for file in $(find src/ -type f -name '*.php'); do
40
+ echo -n "==> ${file}: ";
41
+ php -l "${file}";
42
+ done
43
+ - # Validate composer.json and composer.lock
44
+ name : " Validate composer.json and composer.lock"
45
+ run : " composer validate --strict"
46
+ - # Cache Composer packages
47
+ name : " Cache Composer packages"
48
+ id : " composer-cache"
49
+ uses : " actions/cache@v3"
50
+ with :
51
+ path : " vendor"
52
+ key : " ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}"
53
+ restore-keys : " ${{ runner.os }}-php-"
54
+ - # Install dependencies
55
+ name : " Install composer dependencies"
56
+ run : " composer install --prefer-dist --no-progress"
57
+ - # PHP_CodeSniffer
58
+ name : " PHP_CodeSniffer"
59
+ run : " php vendor/bin/phpcs"
60
+ - # CodeClimate Reporter Setup
61
+ name : " CodeClimate Reporter Setup"
62
+ run : |
63
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
64
+ chmod +x ./cc-test-reporter
65
+ ./cc-test-reporter before-build
66
+ - # Run phpunit
67
+ name : " Run phpunit"
68
+ run : |
69
+ php vendor/bin/phpunit --coverage-clover clover.xml --coverage-text
70
+ ./cc-test-reporter after-build -t clover --exit-code $?
0 commit comments