@@ -2,140 +2,170 @@ name: CI
22
33on :
44 push :
5- branches : [ main, 'feature/v3.0.0', 'feature/**' ]
5+ branches :
6+ - ' main'
7+ - ' legacy/*' # Legacy branches: legacy/v2.x
8+ - ' feature/*' # Feature branches: feature/new-feature
9+ - ' hotfix/*' # Hotfix branches: hotfix/urgent-fix
10+ - ' release/*' # Release branches: release/v3.0.0
611 pull_request :
7- branches : [ main ]
8- workflow_dispatch :
9- inputs :
10- php_version :
11- description : ' PHP version to test (optional, tests all if empty)'
12- required : false
13- default : ' '
12+ branches :
13+ - ' main'
14+ - ' legacy/*' # PRs to legacy branches
15+ workflow_dispatch : # Allows manual triggering via GitHub UI
1416
1517jobs :
16- tests :
18+ test :
1719 runs-on : ubuntu-latest
18-
20+
1921 strategy :
2022 fail-fast : false
2123 matrix :
22- php-version : ['8.1', '8.2', '8.3', '8.4', '8.5']
23- dependencies : ['stable']
24- include : []
25- # Lowest dependency testing removed due to compatibility issues
26- # with old package versions on modern PHP releases
27-
28- continue-on-error : ${{ matrix.php-version == '8.5' }}
29-
30- name : Tests - PHP ${{ matrix.php-version }} (${{ matrix.dependencies }})
24+ include :
25+ # Core PHP version testing
26+ - php : ' 8.1'
27+ allowed-to-fail : false
28+ - php : ' 8.2'
29+ allowed-to-fail : false
30+ - php : ' 8.3'
31+ allowed-to-fail : false
32+ - php : ' 8.4'
33+ allowed-to-fail : false
34+
35+ # Future-ready: PHP 8.5 (alpha/dev) - when available
36+ - php : ' 8.5'
37+ stability : ' dev'
38+ allowed-to-fail : true
39+
40+ # Development stability tests
41+ - php : ' 8.4'
42+ stability : ' dev'
43+ allowed-to-fail : true
44+ - php : ' 8.5'
45+ stability : ' dev'
46+ allowed-to-fail : true
47+
48+ name : " PHP ${{ matrix.php }}${{ matrix.stability && format(' | {0}', matrix.stability) || '' }}"
49+
50+ continue-on-error : ${{ matrix.allowed-to-fail }}
3151
3252 steps :
33- - name : Checkout code
34- uses : actions/checkout@v4
35-
36- - name : Setup PHP
37- uses : shivammathur/setup-php@v2
38- with :
39- php-version : ${{ matrix.php-version }}
40- extensions : dom, curl, libxml, mbstring, zip, json
41- coverage : xdebug
42- tools : composer:v2
43-
44- - name : Cache Composer packages
45- id : composer-cache
46- uses : actions/cache@v4
47- with :
48- path : ~/.composer/cache
49- key : ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }}
50- restore-keys : |
51- ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-
52-
53- - name : Install dependencies (lowest)
54- if : matrix.dependencies == 'lowest'
55- run : composer update --prefer-lowest --prefer-stable --prefer-dist --no-interaction
56-
57- - name : Install dependencies (stable)
58- if : matrix.dependencies == 'stable'
59- run : composer update --prefer-stable --prefer-dist --no-interaction
60-
61- - name : Validate composer.json
62- run : composer validate --strict --no-check-lock
63-
64- - name : Run PHPUnit tests
65- run : composer test
53+ - name : Checkout code
54+ uses : actions/checkout@v4
55+
56+ - name : Setup PHP
57+ uses : shivammathur/setup-php@v2
58+ with :
59+ php-version : ${{ matrix.php }}
60+ extensions : json, mbstring, tokenizer
61+ coverage : none
62+ tools : composer:v2
63+
64+ - name : Get composer cache directory
65+ id : composer-cache
66+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
67+
68+ - name : Cache composer dependencies
69+ uses : actions/cache@v4
70+ with :
71+ path : ${{ steps.composer-cache.outputs.dir }}
72+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
73+ restore-keys : ${{ runner.os }}-composer-
74+
75+ - name : Configure stability
76+ if : matrix.stability
77+ run : |
78+ composer config minimum-stability ${{ matrix.stability }}
79+ composer config prefer-stable true
80+
81+ - name : Remove composer.lock
82+ run : rm -f composer.lock
83+
84+ - name : Install dependencies
85+ run : composer update --prefer-dist --no-interaction --no-progress
86+
87+ - name : Validate composer.json and composer.lock
88+ run : composer validate --strict
89+
90+ - name : Run code style check
91+ run : composer cs
92+
93+ - name : Run static analysis
94+ run : composer analyse
95+
96+ - name : Run tests
97+ run : composer test
6698
6799 code-quality :
68100 runs-on : ubuntu-latest
69- name : Code Quality
101+ name : Code Quality Checks
70102
71103 steps :
72- - name : Checkout code
73- uses : actions/checkout@v4
74-
75- - name : Setup PHP
76- uses : shivammathur/setup-php@v2
77- with :
78- php-version : ' 8.4'
79- extensions : dom, curl, libxml, mbstring, zip, json
80- coverage : none
81- tools : composer:v2
82-
83- - name : Cache Composer packages
84- id : composer-cache
85- uses : actions/cache@v4
86- with :
87- path : ~/.composer/cache
88- key : ${{ runner.os }}-php-8.4-stable-${{ hashFiles('**/composer.lock') }}
89- restore-keys : |
90- ${{ runner.os }}-php-8.4-stable-
91-
92- - name : Install dependencies
93- run : composer update --prefer-stable --prefer-dist --no-interaction
94-
95- - name : Run PHPStan static analysis
96- run : composer analyse
97- continue-on-error : true
98-
99- - name : Run PHP CodeSniffer check
100- run : composer cs
101- continue-on-error : true
104+ - name : Checkout code
105+ uses : actions/checkout@v4
106+
107+ - name : Setup PHP
108+ uses : shivammathur/setup-php@v2
109+ with :
110+ php-version : ' 8.4'
111+ extensions : json, mbstring, tokenizer
112+ coverage : none
113+ tools : composer:v2
114+
115+ - name : Get composer cache directory
116+ id : composer-cache
117+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
118+
119+ - name : Cache composer dependencies
120+ uses : actions/cache@v4
121+ with :
122+ path : ${{ steps.composer-cache.outputs.dir }}
123+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
124+ restore-keys : ${{ runner.os }}-composer-
125+
126+ - name : Install dependencies
127+ run : composer install --prefer-dist --no-interaction --no-progress
128+
129+ - name : Validate composer.json and composer.lock
130+ run : composer validate --strict
102131
103132 coverage :
104133 runs-on : ubuntu-latest
105- name : Coverage Report
134+ name : Code Coverage
106135
107136 steps :
108- - name : Checkout code
109- uses : actions/checkout@v4
110-
111- - name : Setup PHP
112- uses : shivammathur/setup-php@v2
113- with :
114- php-version : ' 8.4'
115- extensions : dom, curl, libxml, mbstring, zip, json
116- coverage : xdebug
117- tools : composer:v2
118-
119- - name : Cache Composer packages
120- id : composer-cache
121- uses : actions/cache@v4
122- with :
123- path : ~/.composer/cache
124- key : ${{ runner.os }}-php-8.4-coverage-${{ hashFiles('**/composer.lock') }}
125- restore-keys : |
126- ${{ runner.os }}-php-8.4-coverage-
127-
128- - name : Install dependencies
129- run : composer update --prefer-stable --prefer-dist --no-interaction
130-
131- - name : Generate coverage report
132- run : vendor/bin/phpunit --coverage-clover coverage.xml
133-
134- - name : Upload coverage to Codecov
135- uses : codecov/codecov-action@v4
136- with :
137- files : ./coverage.xml
138- fail_ci_if_error : false
139- verbose : true
140- env :
141- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
137+ - name : Checkout code
138+ uses : actions/checkout@v4
139+
140+ - name : Setup PHP
141+ uses : shivammathur/setup-php@v2
142+ with :
143+ php-version : ' 8.4'
144+ extensions : json, mbstring, tokenizer
145+ coverage : xdebug
146+ tools : composer:v2
147+
148+ - name : Get composer cache directory
149+ id : composer-cache
150+ run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
151+
152+ - name : Cache composer dependencies
153+ uses : actions/cache@v4
154+ with :
155+ path : ${{ steps.composer-cache.outputs.dir }}
156+ key : ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
157+ restore-keys : ${{ runner.os }}-composer-
158+
159+ - name : Install dependencies
160+ run : composer install --prefer-dist --no-interaction --no-progress
161+
162+ - name : Run tests with coverage
163+ run : vendor/bin/phpunit --coverage-clover coverage.xml
164+
165+ - name : Upload coverage to Codecov
166+ uses : codecov/codecov-action@v4
167+ with :
168+ file : ./coverage.xml
169+ flags : unittests
170+ name : codecov-umbrella
171+ fail_ci_if_error : false
0 commit comments