11<?php
22
3- const BRANCHES = ['master ' , 'PHP-8.2 ' , 'PHP-8.1 ' , 'PHP-8.0 ' ];
3+ const BRANCHES = [
4+ ['name ' => 'master ' , 'ref ' => 'master ' , 'version ' => ['major ' => 8 , 'minor ' => 4 ]],
5+ ['name ' => 'PHP-8.3 ' , 'ref ' => 'PHP-8.3 ' , 'version ' => ['major ' => 8 , 'minor ' => 3 ]],
6+ ['name ' => 'PHP-8.2 ' , 'ref ' => 'PHP-8.2 ' , 'version ' => ['major ' => 8 , 'minor ' => 2 ]],
7+ ['name ' => 'PHP-8.1 ' , 'ref ' => 'PHP-8.1 ' , 'version ' => ['major ' => 8 , 'minor ' => 1 ]],
8+ ];
49
510function get_branch_commit_cache_file_path (): string {
611 return dirname (__DIR__ ) . '/branch-commit-cache.json ' ;
712}
813
9- function get_branch_matrix (array $ branches ) {
10- $ result = array_map (function ($ branch ) {
11- $ branch_key = strtoupper (str_replace ('. ' , '' , $ branch ));
12- return [
13- 'name ' => $ branch_key ,
14- 'ref ' => $ branch ,
15- ];
16- }, $ branches );
17-
18- return $ result ;
19- }
20-
2114function get_branches () {
2215 $ branch_commit_cache_file = get_branch_commit_cache_file_path ();
2316 $ branch_commit_map = [];
@@ -27,19 +20,19 @@ function get_branches() {
2720
2821 $ changed_branches = [];
2922 foreach (BRANCHES as $ branch ) {
30- $ previous_commit_hash = $ branch_commit_map [$ branch ] ?? null ;
31- $ current_commit_hash = trim (shell_exec ('git rev-parse origin/ ' . $ branch ));
23+ $ previous_commit_hash = $ branch_commit_map [$ branch[ ' ref ' ] ] ?? null ;
24+ $ current_commit_hash = trim (shell_exec ('git rev-parse origin/ ' . $ branch[ ' ref ' ] ));
3225
3326 if ($ previous_commit_hash !== $ current_commit_hash ) {
3427 $ changed_branches [] = $ branch ;
3528 }
3629
37- $ branch_commit_map [$ branch ] = $ current_commit_hash ;
30+ $ branch_commit_map [$ branch[ ' ref ' ] ] = $ current_commit_hash ;
3831 }
3932
4033 file_put_contents ($ branch_commit_cache_file , json_encode ($ branch_commit_map ));
4134
42- return get_branch_matrix ( $ changed_branches) ;
35+ return $ changed_branches ;
4336}
4437
4538function get_matrix_include (array $ branches ) {
@@ -53,27 +46,28 @@ function get_matrix_include(array $branches) {
5346 'configuration_parameters ' => "CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address' " ,
5447 'run_tests_parameters ' => '--asan ' ,
5548 'test_function_jit ' => false ,
49+ 'asan ' => true ,
50+ ];
51+ $ jobs [] = [
52+ 'name ' => '_REPEAT ' ,
53+ 'branch ' => $ branch ,
54+ 'debug ' => true ,
55+ 'zts ' => false ,
56+ 'run_tests_parameters ' => '--repeat 2 ' ,
57+ 'timeout_minutes ' => 360 ,
58+ 'test_function_jit ' => true ,
59+ 'asan ' => false ,
60+ ];
61+ $ jobs [] = [
62+ 'name ' => '_VARIATION ' ,
63+ 'branch ' => $ branch ,
64+ 'debug ' => true ,
65+ 'zts ' => true ,
66+ 'configuration_parameters ' => "CFLAGS='-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_VERIFY_TYPE_INFERENCE' " ,
67+ 'timeout_minutes ' => 360 ,
68+ 'test_function_jit ' => true ,
69+ 'asan ' => false ,
5670 ];
57- if ($ branch ['ref ' ] !== 'PHP-8.0 ' ) {
58- $ jobs [] = [
59- 'name ' => '_REPEAT ' ,
60- 'branch ' => $ branch ,
61- 'debug ' => true ,
62- 'zts ' => false ,
63- 'run_tests_parameters ' => '--repeat 2 ' ,
64- 'timeout_minutes ' => 360 ,
65- 'test_function_jit ' => true ,
66- ];
67- $ jobs [] = [
68- 'name ' => '_VARIATION ' ,
69- 'branch ' => $ branch ,
70- 'debug ' => true ,
71- 'zts ' => true ,
72- 'configuration_parameters ' => "CFLAGS='-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1' " ,
73- 'timeout_minutes ' => 360 ,
74- 'test_function_jit ' => true ,
75- ];
76- }
7771 }
7872 return $ jobs ;
7973}
@@ -97,17 +91,61 @@ function get_windows_matrix_include(array $branches) {
9791 return $ jobs ;
9892}
9993
94+ function get_macos_matrix_include (array $ branches ) {
95+ $ jobs = [];
96+ foreach ($ branches as $ branch ) {
97+ foreach ([true , false ] as $ debug ) {
98+ foreach ([true , false ] as $ zts ) {
99+ $ jobs [] = [
100+ 'branch ' => $ branch ,
101+ 'debug ' => $ debug ,
102+ 'zts ' => $ zts ,
103+ 'os ' => $ branch === 'master ' ? '13 ' : '12 ' ,
104+ 'arch ' => 'X64 ' ,
105+ ];
106+ if ($ branch ['version ' ]['minor ' ] >= 4 || $ branch ['version ' ]['major ' ] >= 9 ) {
107+ $ jobs [] = [
108+ 'branch ' => $ branch ,
109+ 'debug ' => $ debug ,
110+ 'zts ' => $ zts ,
111+ 'os ' => '14 ' ,
112+ 'arch ' => 'ARM64 ' ,
113+ ];
114+ }
115+ }
116+ }
117+ }
118+ return $ jobs ;
119+ }
120+
121+ function get_current_version (): array {
122+ $ file = dirname (__DIR__ ) . '/main/php_version.h ' ;
123+ $ content = file_get_contents ($ file );
124+ preg_match ('(^#define PHP_MAJOR_VERSION (?<num>\d+)$)m ' , $ content , $ matches );
125+ $ major = $ matches ['num ' ];
126+ preg_match ('(^#define PHP_MINOR_VERSION (?<num>\d+)$)m ' , $ content , $ matches );
127+ $ minor = $ matches ['num ' ];
128+ return ['major ' => $ major , 'minor ' => $ minor ];
129+ }
130+
100131$ trigger = $ argv [1 ] ?? 'schedule ' ;
101132$ attempt = (int ) ($ argv [2 ] ?? 1 );
102133$ discard_cache = ($ trigger === 'schedule ' && $ attempt !== 1 ) || $ trigger === 'workflow_dispatch ' ;
103134if ($ discard_cache ) {
104135 @unlink (get_branch_commit_cache_file_path ());
105136}
137+ $ branch = $ argv [3 ] ?? 'master ' ;
106138
107- $ branches = get_branches ();
139+ $ branches = $ branch === 'master '
140+ ? get_branches ()
141+ : [['name ' => strtoupper ($ branch ), 'ref ' => $ branch , 'version ' => get_current_version ()]];
108142$ matrix_include = get_matrix_include ($ branches );
109143$ windows_matrix_include = get_windows_matrix_include ($ branches );
144+ $ macos_matrix_include = get_macos_matrix_include ($ branches );
110145
111- echo '::set-output name=branches:: ' . json_encode ($ branches , JSON_UNESCAPED_SLASHES ) . "\n" ;
112- echo '::set-output name=matrix-include:: ' . json_encode ($ matrix_include , JSON_UNESCAPED_SLASHES ) . "\n" ;
113- echo '::set-output name=windows-matrix-include:: ' . json_encode ($ windows_matrix_include , JSON_UNESCAPED_SLASHES ) . "\n" ;
146+ $ f = fopen (getenv ('GITHUB_OUTPUT ' ), 'a ' );
147+ fwrite ($ f , 'branches= ' . json_encode ($ branches , JSON_UNESCAPED_SLASHES ) . "\n" );
148+ fwrite ($ f , 'matrix-include= ' . json_encode ($ matrix_include , JSON_UNESCAPED_SLASHES ) . "\n" );
149+ fwrite ($ f , 'windows-matrix-include= ' . json_encode ($ windows_matrix_include , JSON_UNESCAPED_SLASHES ) . "\n" );
150+ fwrite ($ f , 'macos-matrix-include= ' . json_encode ($ macos_matrix_include , JSON_UNESCAPED_SLASHES ) . "\n" );
151+ fclose ($ f );
0 commit comments