Skip to content

Commit 9ad99bb

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Backport nightly.yml and nightly_matrix.php to PHP-8.1
2 parents eeec093 + 27e8860 commit 9ad99bb

File tree

2 files changed

+447
-110
lines changed

2 files changed

+447
-110
lines changed

.github/nightly_matrix.php

Lines changed: 108 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
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' => 5]],
5+
['name' => 'PHP-8.4', 'ref' => 'PHP-8.4', 'version' => ['major' => 8, 'minor' => 4]],
6+
['name' => 'PHP-8.3', 'ref' => 'PHP-8.3', 'version' => ['major' => 8, 'minor' => 3]],
7+
['name' => 'PHP-8.2', 'ref' => 'PHP-8.2', 'version' => ['major' => 8, 'minor' => 2]],
8+
['name' => 'PHP-8.1', 'ref' => 'PHP-8.1', 'version' => ['major' => 8, 'minor' => 1]],
9+
];
410

511
function get_branch_commit_cache_file_path(): string {
612
return dirname(__DIR__) . '/branch-commit-cache.json';
713
}
814

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-
2115
function get_branches() {
2216
$branch_commit_cache_file = get_branch_commit_cache_file_path();
2317
$branch_commit_map = [];
@@ -27,19 +21,19 @@ function get_branches() {
2721

2822
$changed_branches = [];
2923
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));
24+
$previous_commit_hash = $branch_commit_map[$branch['ref']] ?? null;
25+
$current_commit_hash = trim(shell_exec('git rev-parse origin/' . $branch['ref']));
3226

3327
if ($previous_commit_hash !== $current_commit_hash) {
3428
$changed_branches[] = $branch;
3529
}
3630

37-
$branch_commit_map[$branch] = $current_commit_hash;
31+
$branch_commit_map[$branch['ref']] = $current_commit_hash;
3832
}
3933

4034
file_put_contents($branch_commit_cache_file, json_encode($branch_commit_map));
4135

42-
return get_branch_matrix($changed_branches);
36+
return $changed_branches;
4337
}
4438

4539
function get_matrix_include(array $branches) {
@@ -53,28 +47,29 @@ function get_matrix_include(array $branches) {
5347
'configuration_parameters' => "CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address'",
5448
'run_tests_parameters' => '--asan',
5549
'test_function_jit' => false,
50+
'asan' => true,
51+
];
52+
$jobs[] = [
53+
'name' => '_REPEAT',
54+
'branch' => $branch,
55+
'debug' => true,
56+
'zts' => false,
57+
'run_tests_parameters' => '--repeat 2',
58+
'timeout_minutes' => 360,
59+
'test_function_jit' => true,
60+
'asan' => false,
5661
];
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'",
62+
$jobs[] = [
63+
'name' => '_VARIATION',
64+
'branch' => $branch,
65+
'debug' => true,
66+
'zts' => true,
67+
'configuration_parameters' => "CFLAGS='-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_VERIFY_TYPE_INFERENCE'",
7368
'run_tests_parameters' => '-d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0',
74-
'timeout_minutes' => 360,
75-
'test_function_jit' => true,
76-
];
77-
}
69+
'timeout_minutes' => 360,
70+
'test_function_jit' => true,
71+
'asan' => false,
72+
];
7873
}
7974
return $jobs;
8075
}
@@ -98,17 +93,88 @@ function get_windows_matrix_include(array $branches) {
9893
return $jobs;
9994
}
10095

96+
function get_macos_matrix_include(array $branches) {
97+
$jobs = [];
98+
foreach ($branches as $branch) {
99+
foreach([true, false] as $debug) {
100+
foreach([true, false] as $zts) {
101+
$jobs[] = [
102+
'branch' => $branch,
103+
'debug' => $debug,
104+
'zts' => $zts,
105+
'os' => '13',
106+
'arch' => 'X64',
107+
'test_jit' => true,
108+
];
109+
if ($branch['version']['minor'] >= 4 || $branch['version']['major'] >= 9) {
110+
$jobs[] = [
111+
'branch' => $branch,
112+
'debug' => $debug,
113+
'zts' => $zts,
114+
'os' => '14',
115+
'arch' => 'ARM64',
116+
'test_jit' => !$zts,
117+
];
118+
}
119+
}
120+
}
121+
}
122+
return $jobs;
123+
}
124+
125+
function get_alpine_matrix_include(array $branches) {
126+
$jobs = [];
127+
foreach ($branches as $branch) {
128+
if ([$branch['version']['major'], $branch['version']['minor']] < [8, 4]) {
129+
continue;
130+
}
131+
$jobs[] = [
132+
'name' => '_ASAN_UBSAN',
133+
'branch' => $branch,
134+
'debug' => true,
135+
'zts' => true,
136+
'asan' => true,
137+
'test_jit' => true,
138+
'configuration_parameters' => "CFLAGS='-fsanitize=undefined,address -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address -fno-sanitize=function' CC=clang-17 CXX=clang++-17",
139+
'run_tests_parameters' => '--asan -x',
140+
];
141+
}
142+
return $jobs;
143+
}
144+
145+
function get_current_version(): array {
146+
$file = dirname(__DIR__) . '/main/php_version.h';
147+
$content = file_get_contents($file);
148+
preg_match('(^#define PHP_MAJOR_VERSION (?<num>\d+)$)m', $content, $matches);
149+
$major = $matches['num'];
150+
preg_match('(^#define PHP_MINOR_VERSION (?<num>\d+)$)m', $content, $matches);
151+
$minor = $matches['num'];
152+
return ['major' => $major, 'minor' => $minor];
153+
}
154+
101155
$trigger = $argv[1] ?? 'schedule';
102156
$attempt = (int) ($argv[2] ?? 1);
103-
$discard_cache = ($trigger === 'schedule' && $attempt !== 1) || $trigger === 'workflow_dispatch';
157+
$monday = date('w', time()) === '1';
158+
$discard_cache = $monday
159+
|| ($trigger === 'schedule' && $attempt !== 1)
160+
|| $trigger === 'workflow_dispatch';
104161
if ($discard_cache) {
105162
@unlink(get_branch_commit_cache_file_path());
106163
}
164+
$branch = $argv[3] ?? 'master';
107165

108-
$branches = get_branches();
166+
$branches = $branch === 'master'
167+
? get_branches()
168+
: [['name' => strtoupper($branch), 'ref' => $branch, 'version' => get_current_version()]];
109169
$matrix_include = get_matrix_include($branches);
110170
$windows_matrix_include = get_windows_matrix_include($branches);
171+
$macos_matrix_include = get_macos_matrix_include($branches);
172+
$alpine_matrix_include = get_alpine_matrix_include($branches);
111173

112-
echo '::set-output name=branches::' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n";
113-
echo '::set-output name=matrix-include::' . json_encode($matrix_include, JSON_UNESCAPED_SLASHES) . "\n";
114-
echo '::set-output name=windows-matrix-include::' . json_encode($windows_matrix_include, JSON_UNESCAPED_SLASHES) . "\n";
174+
$f = fopen(getenv('GITHUB_OUTPUT'), 'a');
175+
fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n");
176+
fwrite($f, 'matrix-include=' . json_encode($matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
177+
fwrite($f, 'windows-matrix-include=' . json_encode($windows_matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
178+
fwrite($f, 'macos-matrix-include=' . json_encode($macos_matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
179+
fwrite($f, 'alpine-matrix-include=' . json_encode($alpine_matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
180+
fclose($f);

0 commit comments

Comments
 (0)