Skip to content

Commit e72854e

Browse files
committed
[skip ci] Fix nightly workflow dispatch
Closes phpGH-16662
1 parent 6c8a0d0 commit e72854e

File tree

2 files changed

+37
-75
lines changed

2 files changed

+37
-75
lines changed

.github/nightly_matrix.php

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<?php
22

3-
const BRANCHES = ['master', 'PHP-8.4', 'PHP-8.3', 'PHP-8.2', 'PHP-8.1'];
3+
const BRANCHES = [
4+
['ref' => 'master', 'version' => [8, 5]],
5+
['ref' => 'PHP-8.4', 'version' => [8, 4]],
6+
['ref' => 'PHP-8.3', 'version' => [8, 3]],
7+
['ref' => 'PHP-8.2', 'version' => [8, 2]],
8+
['ref' => 'PHP-8.1', 'version' => [8, 1]],
9+
];
410

511
function get_branch_commit_cache_file_path(): string {
612
return dirname(__DIR__) . '/branch-commit-cache.json';
@@ -15,21 +21,31 @@ function get_branches() {
1521

1622
$changed_branches = [];
1723
foreach (BRANCHES as $branch) {
18-
$previous_commit_hash = $branch_commit_map[$branch] ?? null;
19-
$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']));
2026

2127
if ($previous_commit_hash !== $current_commit_hash) {
2228
$changed_branches[] = $branch;
2329
}
2430

25-
$branch_commit_map[$branch] = $current_commit_hash;
31+
$branch_commit_map[$branch['ref']] = $current_commit_hash;
2632
}
2733

2834
file_put_contents($branch_commit_cache_file, json_encode($branch_commit_map));
2935

3036
return $changed_branches;
3137
}
3238

39+
function get_current_version(): array {
40+
$file = dirname(__DIR__) . '/main/php_version.h';
41+
$content = file_get_contents($file);
42+
preg_match('(^#define PHP_MAJOR_VERSION (?<num>\d+)$)m', $content, $matches);
43+
$major = (int) $matches['num'];
44+
preg_match('(^#define PHP_MINOR_VERSION (?<num>\d+)$)m', $content, $matches);
45+
$minor = (int) $matches['num'];
46+
return [$major, $minor];
47+
}
48+
3349
$trigger = $argv[1] ?? 'schedule';
3450
$attempt = (int) ($argv[2] ?? 1);
3551
$monday = date('w', time()) === '1';
@@ -40,7 +56,9 @@ function get_branches() {
4056
@unlink(get_branch_commit_cache_file_path());
4157
}
4258
$branch = $argv[3] ?? 'master';
43-
$branches = $branch === 'master' ? get_branches() : [$branch];
59+
$branches = $branch === 'master'
60+
? get_branches()
61+
: [['ref' => $branch, 'version' => get_current_version()]];
4462

4563
$f = fopen(getenv('GITHUB_OUTPUT'), 'a');
4664
fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n");

.github/workflows/root.yml

+14-70
Original file line numberDiff line numberDiff line change
@@ -36,78 +36,22 @@ jobs:
3636
uses: ./.github/actions/notify-slack
3737
with:
3838
token: ${{ secrets.ACTION_MONITORING_SLACK }}
39-
NIGHTLY_MASTER:
40-
name: master
39+
NIGHTLY:
4140
needs: GENERATE_MATRIX
42-
if: contains(needs.GENERATE_MATRIX.outputs.branches, 'master')
41+
name: ${{ matrix.branch.ref }}
42+
if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
4343
uses: ./.github/workflows/nightly.yml
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
4448
with:
4549
asan_ubuntu_version: '20.04'
46-
branch: master
47-
community_verify_type_inference: true
48-
libmysqlclient_with_mysqli: false
49-
run_alpine: true
50-
run_macos_arm64: true
51-
ubuntu_version: '22.04'
52-
windows_version: '2022'
53-
secrets: inherit
54-
NIGHTLY_84:
55-
name: PHP-8.4
56-
needs: GENERATE_MATRIX
57-
if: contains(needs.GENERATE_MATRIX.outputs.branches, 'PHP-8.4')
58-
uses: ./.github/workflows/nightly.yml
59-
with:
60-
asan_ubuntu_version: '20.04'
61-
branch: PHP-8.4
62-
community_verify_type_inference: true
63-
libmysqlclient_with_mysqli: false
64-
run_alpine: true
65-
run_macos_arm64: true
66-
ubuntu_version: '22.04'
67-
windows_version: '2022'
68-
secrets: inherit
69-
NIGHTLY_83:
70-
name: PHP-8.3
71-
needs: GENERATE_MATRIX
72-
if: contains(needs.GENERATE_MATRIX.outputs.branches, 'PHP-8.3')
73-
uses: ./.github/workflows/nightly.yml
74-
with:
75-
asan_ubuntu_version: '20.04'
76-
branch: PHP-8.3
77-
community_verify_type_inference: false
78-
libmysqlclient_with_mysqli: false
79-
run_alpine: false
80-
run_macos_arm64: false
81-
ubuntu_version: '22.04'
82-
windows_version: '2019'
83-
secrets: inherit
84-
NIGHTLY_82:
85-
name: PHP-8.2
86-
needs: GENERATE_MATRIX
87-
if: contains(needs.GENERATE_MATRIX.outputs.branches, 'PHP-8.2')
88-
uses: ./.github/workflows/nightly.yml
89-
with:
90-
asan_ubuntu_version: '20.04'
91-
branch: PHP-8.2
92-
community_verify_type_inference: false
93-
libmysqlclient_with_mysqli: false
94-
run_alpine: false
95-
run_macos_arm64: false
96-
ubuntu_version: '20.04'
97-
windows_version: '2019'
98-
secrets: inherit
99-
NIGHTLY_81:
100-
name: PHP-8.1
101-
needs: GENERATE_MATRIX
102-
if: contains(needs.GENERATE_MATRIX.outputs.branches, 'PHP-8.1')
103-
uses: ./.github/workflows/nightly.yml
104-
with:
105-
asan_ubuntu_version: '20.04'
106-
branch: PHP-8.1
107-
community_verify_type_inference: false
108-
libmysqlclient_with_mysqli: true
109-
run_alpine: false
110-
run_macos_arm64: false
111-
ubuntu_version: '20.04'
112-
windows_version: '2019'
50+
branch: ${{ matrix.branch.ref }}
51+
community_verify_type_inference: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9 }}
52+
libmysqlclient_with_mysqli: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1) }}
53+
run_alpine: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9 }}
54+
run_macos_arm64: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9 }}
55+
ubuntu_version: ${{ ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 3) || matrix.branch.version[0] >= 9) && '22.04' || '20.04' }}
56+
windows_version: ${{ ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9) && '2022' || '2019' }}
11357
secrets: inherit

0 commit comments

Comments
 (0)