1- ---
21name : build
32on :
43 push : ~
54 pull_request : ~
65
76jobs :
8- linux_tests :
9- name : PHP on ${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.composer-flags }}
7+ tests :
8+ name : Tests • PHP ${{ matrix.php }} • ${{ matrix.stability }}
109 runs-on : ubuntu-22.04
10+
1111 strategy :
1212 matrix :
13- php : ['8.1', '8.2', '8.3', '8.4']
13+ php : ['8.1', '8.2', '8.3', '8.4', '8.5' ]
1414 stability : [prefer-lowest, prefer-stable]
15- include :
16- - php : ' 8.5'
17- flags : " --ignore-platform-req=php"
18- stability : prefer-stable
15+
1916 steps :
2017 - name : Checkout code
2118 uses : actions/checkout@v4
@@ -26,39 +23,111 @@ jobs:
2623 php-version : ${{ matrix.php }}
2724 coverage : xdebug
2825 tools : composer:v2
29- - name : Check PHP Version
30- run : php -v
3126
3227 - name : Validate composer files
3328 run : composer validate --strict
3429
30+ # -----------------------
31+ # Composer cache
32+ # -----------------------
3533 - name : Get Composer Cache Directory
3634 id : composer-cache
37- run : |
38- echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
39- - uses : actions/cache@v3
35+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
36+
37+ - name : Cache Composer Files
38+ uses : actions/cache@v3
4039 with :
4140 path : ${{ steps.composer-cache.outputs.dir }}
42- key : ${{ runner.os }}-composer- ${{ matrix.stability }}-${{ matrix.flags }}-${{ hashFiles('**/ composer.lock') }}
41+ key : ${{ runner.os }}-php ${{ matrix.php }}-${{ matrix.stability }}-composer- ${{ hashFiles('composer.lock') }}
4342 restore-keys : |
44- ${{ runner.os }}-composer-${{ matrix.stability }}-${{ matrix.flags }}-
43+ ${{ runner.os }}-php${{ matrix.php }}-${{ matrix.stability }}-composer-
44+ ${{ runner.os }}-php${{ matrix.php }}-composer-
4545 ${{ runner.os }}-composer-
4646
47+ # -----------------------
48+ # vendor/ cache
49+ # -----------------------
50+ - name : Cache vendor directory
51+ id : vendor-cache
52+ uses : actions/cache@v3
53+ with :
54+ path : vendor
55+ key : vendor-${{ runner.os }}-php${{ matrix.php }}-${{ matrix.stability }}-${{ hashFiles('composer.lock') }}
56+
4757 - name : Install dependencies
48- run : composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress ${{ matrix.flags }}
58+ if : steps.vendor-cache.outputs.cache-hit != 'true'
59+ run : composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
60+
61+ # -----------------------
62+ # PHPUnit coverage cache
63+ # -----------------------
64+ - name : Cache PHPUnit coverage
65+ uses : actions/cache@v3
66+ with :
67+ path : build/coverage
68+ key : coverage-${{ runner.os }}-php${{ matrix.php }}-${{ github.sha }}
69+
70+ - name : Run Unit tests
71+ run : composer phpunit
72+
73+ # -----------------------------------------------------------
74+
75+ static_analysis :
76+ name : Static Analysis (PHP 8.4, prefer-stable)
77+ runs-on : ubuntu-22.04
78+ needs : tests
79+
80+ steps :
81+ - name : Checkout code
82+ uses : actions/checkout@v4
83+
84+ - name : Setup PHP 8.4
85+ uses : shivammathur/setup-php@v2
86+ with :
87+ php-version : 8.4
88+ tools : composer:v2
4989
50- - name : Run Unit tests with coverage
51- run : composer phpunit -- ${{ matrix.phpunit-flags }}
52- if : ${{ matrix.php != '8.5' }}
90+ # Restore vendor cache
91+ - name : Restore vendor cache
92+ uses : actions/cache@v3
93+ with :
94+ path : vendor
95+ key : vendor-${{ runner.os }}-php8.4-prefer-stable-${{ hashFiles('composer.lock') }}
5396
54- - name : Run Unit tests without coverage
55- run : vendor/bin/phpunit -- no-coverage
56- if : ${{ matrix.php == '8.5' }}
97+ - name : Install dependencies if needed
98+ run : composer update --prefer-stable -- no-interaction --no-progress
99+ if : always() && !exists('vendor/autoload.php')
57100
58- - name : Run static analysis
101+ - name : Run PHPStan
59102 run : composer phpstan
60- if : ${{ matrix.php == '8.4' && matrix.stability == 'prefer-stable'}}
61103
62- - name : Run Coding style rules
104+ # -----------------------------------------------------------
105+
106+ coding_style :
107+ name : Coding Style (PHP 8.4, prefer-stable)
108+ runs-on : ubuntu-22.04
109+ needs : tests
110+
111+ steps :
112+ - name : Checkout code
113+ uses : actions/checkout@v4
114+
115+ - name : Setup PHP 8.4
116+ uses : shivammathur/setup-php@v2
117+ with :
118+ php-version : 8.4
119+ tools : composer:v2
120+
121+ # Restore vendor cache
122+ - name : Restore vendor cache
123+ uses : actions/cache@v3
124+ with :
125+ path : vendor
126+ key : vendor-${{ runner.os }}-php8.4-prefer-stable-${{ hashFiles('composer.lock') }}
127+
128+ - name : Install dependencies if needed
129+ run : composer update --prefer-stable --no-interaction --no-progress
130+ if : always() && !exists('vendor/autoload.php')
131+
132+ - name : Run PHPCS
63133 run : composer phpcs:fix
64- if : ${{ matrix.php == '8.4' && matrix.stability == 'prefer-stable'}}
0 commit comments