1
1
<?php
2
2
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
+ ];
4
9
5
10
function get_branch_commit_cache_file_path (): string {
6
11
return dirname (__DIR__ ) . '/branch-commit-cache.json ' ;
7
12
}
8
13
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
-
21
14
function get_branches () {
22
15
$ branch_commit_cache_file = get_branch_commit_cache_file_path ();
23
16
$ branch_commit_map = [];
@@ -27,19 +20,19 @@ function get_branches() {
27
20
28
21
$ changed_branches = [];
29
22
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 ' ] ));
32
25
33
26
if ($ previous_commit_hash !== $ current_commit_hash ) {
34
27
$ changed_branches [] = $ branch ;
35
28
}
36
29
37
- $ branch_commit_map [$ branch ] = $ current_commit_hash ;
30
+ $ branch_commit_map [$ branch[ ' ref ' ] ] = $ current_commit_hash ;
38
31
}
39
32
40
33
file_put_contents ($ branch_commit_cache_file , json_encode ($ branch_commit_map ));
41
34
42
- return get_branch_matrix ( $ changed_branches) ;
35
+ return $ changed_branches ;
43
36
}
44
37
45
38
function get_matrix_include (array $ branches ) {
@@ -53,27 +46,28 @@ function get_matrix_include(array $branches) {
53
46
'configuration_parameters ' => "CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address' " ,
54
47
'run_tests_parameters ' => '--asan ' ,
55
48
'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 ,
56
70
];
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
- }
77
71
}
78
72
return $ jobs ;
79
73
}
@@ -97,17 +91,61 @@ function get_windows_matrix_include(array $branches) {
97
91
return $ jobs ;
98
92
}
99
93
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
+
100
131
$ trigger = $ argv [1 ] ?? 'schedule ' ;
101
132
$ attempt = (int ) ($ argv [2 ] ?? 1 );
102
133
$ discard_cache = ($ trigger === 'schedule ' && $ attempt !== 1 ) || $ trigger === 'workflow_dispatch ' ;
103
134
if ($ discard_cache ) {
104
135
@unlink (get_branch_commit_cache_file_path ());
105
136
}
137
+ $ branch = $ argv [3 ] ?? 'master ' ;
106
138
107
- $ branches = get_branches ();
139
+ $ branches = $ branch === 'master '
140
+ ? get_branches ()
141
+ : [['name ' => strtoupper ($ branch ), 'ref ' => $ branch , 'version ' => get_current_version ()]];
108
142
$ matrix_include = get_matrix_include ($ branches );
109
143
$ windows_matrix_include = get_windows_matrix_include ($ branches );
144
+ $ macos_matrix_include = get_macos_matrix_include ($ branches );
110
145
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