Skip to content

Commit f7b58d3

Browse files
committed
Unify push & nightly workflows
Also introduce label-based opt-in and opt-out mechanism for jobs. Closes GH-21172
1 parent 4be0d5e commit f7b58d3

File tree

5 files changed

+351
-371
lines changed

5 files changed

+351
-371
lines changed

.github/actions/ccache/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: ccache
2+
inputs:
3+
name:
4+
required: true
5+
runs:
6+
using: composite
7+
steps:
8+
- name: ccache
9+
uses: hendrikmuhs/ccache-action@v1.2
10+
with:
11+
key: "${{ inputs.name }}-${{ hashFiles('main/php_version.h') }}"
12+
append-timestamp: false
13+
save: ${{ github.event_name != 'pull_request' }}

.github/nightly_matrix.php

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,101 @@ function get_current_version(): array {
4646
return [$major, $minor];
4747
}
4848

49+
function select_jobs($trigger, $labels, $php_version, $ref, $all_variations) {
50+
$no_jobs = in_array('CI: No jobs', $labels, true);
51+
$all_jobs = in_array('CI: All jobs', $labels, true);
52+
$test_alpine = in_array('CI: Alpine', $labels, true);
53+
$test_community = in_array('CI: Community', $labels, true);
54+
$test_freebsd = in_array('CI: FreeBSD', $labels, true);
55+
$test_libmysqlclient = in_array('CI: libmysqlclient', $labels, true);
56+
$test_linux_ppc64 = in_array('CI: Linux PPC64', $labels, true);
57+
$test_linux_x32 = in_array('CI: Linux X32', $labels, true);
58+
$test_linux_x64 = in_array('CI: Linux X64', $labels, true);
59+
$test_macos = in_array('CI: macOS', $labels, true);
60+
$test_msan = in_array('CI: MSAN', $labels, true);
61+
$test_opcache_variation = in_array('CI: Opcache Variation', $labels, true);
62+
$test_windows = in_array('CI: Windows', $labels, true);
63+
64+
$jobs = [];
65+
if (version_compare($php_version, '8.4', '>=') && ($all_jobs || !$no_jobs || $test_alpine)) {
66+
$jobs['ALPINE'] = true;
67+
}
68+
if ($all_jobs || $test_community) {
69+
$jobs['COMMUNITY']['matrix'] = version_compare($php_version, '8.4', '>=')
70+
? ['type' => ['asan', 'verify_type_inference']]
71+
: ['type' => ['asan']];
72+
$jobs['COMMUNITY']['config']['symfony_version'] = version_compare($php_version, '8.4', '>=') ? '8.1' : '7.4';
73+
}
74+
if ($trigger === 'schedule' && $ref === 'master') {
75+
$jobs['COVERAGE'] = true;
76+
}
77+
if ($all_jobs || $test_libmysqlclient) {
78+
$jobs['LIBMYSQLCLIENT'] = true;
79+
}
80+
if (version_compare($php_version, '8.4', '>=') && ($all_jobs || $test_linux_ppc64)) {
81+
$jobs['LINUX_PPC64'] = true;
82+
}
83+
if ($all_jobs || !$no_jobs || $test_linux_x64) {
84+
$jobs['LINUX_X64']['matrix'] = $all_variations
85+
? [
86+
'name' => [''],
87+
'asan' => [false],
88+
'debug' => [true, false],
89+
'repeat' => [false],
90+
'variation' => [false],
91+
'zts' => [true, false],
92+
'include' => [
93+
['name' => '_ASAN', 'asan' => true, 'debug' => true, 'repeat' => false, 'variation' => false, 'zts' => true],
94+
['name' => '_REPEAT', 'asan' => false, 'debug' => true, 'repeat' => true, 'variation' => false, 'zts' => false],
95+
['name' => '_VARIATION', 'asan' => false, 'debug' => true, 'repeat' => false, 'variation' => true, 'zts' => true],
96+
],
97+
]
98+
: ['include' => [
99+
['name' => '', 'asan' => false, 'debug' => false, 'repeat' => false, 'variation' => false, 'zts' => false],
100+
['name' => '_ASAN', 'asan' => true, 'debug' => true, 'repeat' => false, 'variation' => false, 'zts' => true],
101+
]];
102+
$jobs['LINUX_X64']['config']['variation_enable_zend_max_execution_timers'] = version_compare($php_version, '8.3', '>=');
103+
}
104+
if ($all_jobs || !$no_jobs || $test_linux_x32) {
105+
$jobs['LINUX_X32']['matrix'] = $all_variations
106+
? ['debug' => [true, false], 'zts' => [true, false]]
107+
: ['debug' => [true], 'zts' => [true]];
108+
}
109+
if ($all_jobs || !$no_jobs || $test_macos) {
110+
$test_arm = version_compare($php_version, '8.4', '>=');
111+
$jobs['MACOS']['matrix'] = $all_variations
112+
? ['arch' => $test_arm ? ['X64', 'ARM64'] : ['X64'], 'debug' => [true, false], 'zts' => [true, false]]
113+
: ['include' => [['arch' => $test_arm ? 'ARM64' : 'X64', 'debug' => true, 'zts' => false]]];
114+
$jobs['MACOS']['config']['arm64_version'] = version_compare($php_version, '8.4', '>=') ? '15' : '14';
115+
}
116+
if ($all_jobs || $test_msan) {
117+
$jobs['MSAN'] = true;
118+
}
119+
if ($all_jobs || $test_opcache_variation) {
120+
$jobs['OPCACHE_VARIATION'] = true;
121+
}
122+
if ($trigger === 'schedule' && $ref === 'master') {
123+
$jobs['PECL'] = true;
124+
}
125+
if ($all_jobs || !$no_jobs || $test_windows) {
126+
$jobs['WINDOWS']['matrix'] = $all_variations
127+
? ['include' => [
128+
['asan' => true, 'opcache' => true, 'x64' => true, 'zts' => true],
129+
['asan' => false, 'opcache' => false, 'x64' => false, 'zts' => false],
130+
]]
131+
: ['include' => [['asan' => false, 'opcache' => true, 'x64' => true, 'zts' => true]]];
132+
$jobs['WINDOWS']['config'] = version_compare($php_version, '8.4', '>=')
133+
? ['vs_crt_version' => 'vs17']
134+
: ['vs_crt_version' => 'vs16'];
135+
}
136+
if ($all_jobs || !$no_jobs || $test_freebsd) {
137+
$jobs['FREEBSD']['matrix'] = $all_variations && version_compare($php_version, '8.3', '>=')
138+
? ['zts' => [true, false]]
139+
: ['zts' => [false]];
140+
}
141+
return $jobs;
142+
}
143+
49144
$trigger = $argv[1] ?? 'schedule';
50145
$attempt = (int) ($argv[2] ?? 1);
51146
$sunday = date('w', time()) === '0';
@@ -60,6 +155,25 @@ function get_current_version(): array {
60155
? get_branches()
61156
: [['ref' => $branch, 'version' => get_current_version()]];
62157

63-
$f = fopen(getenv('GITHUB_OUTPUT'), 'a');
64-
fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n");
65-
fclose($f);
158+
$labels = json_decode($argv[4] ?? '[]', true);
159+
$labels = array_column($labels, 'name');
160+
$all_variations = $trigger === 'schedule' || $trigger === 'workflow_dispatch' || in_array('CI: All variations', $labels, true);
161+
162+
foreach ($branches as &$branch) {
163+
$php_version = $branch['version'][0] . '.' . $branch['version'][1];
164+
$branch['jobs'] = select_jobs($trigger, $labels, $php_version, $branch['ref'], $all_variations);
165+
$branch['config']['ubuntu_version'] = version_compare($php_version, '8.5', '>=') ? '24.04' : '22.04';
166+
}
167+
168+
echo "All variations:";
169+
echo json_encode($all_variations, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
170+
echo "\n\nBranches:\n";
171+
echo json_encode($branches, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
172+
echo "\n";
173+
174+
if (false !== ($github_output = getenv('GITHUB_OUTPUT'))) {
175+
$f = fopen($github_output, 'a');
176+
fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n");
177+
fwrite($f, 'all_variations=' . json_encode($all_variations, JSON_UNESCAPED_SLASHES) . "\n");
178+
fclose($f);
179+
}

0 commit comments

Comments
 (0)