Skip to content

Commit bef97fb

Browse files
committed
[skip ci] Fix nightly version check
The last attempt was incorrect for the schedule trigger, which runs multiple PHP versions. Instead, the version information should be stored in the branch object.
1 parent 2ca142e commit bef97fb

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

.github/nightly_matrix.php

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
<?php
22

3-
const BRANCHES = ['master', 'PHP-8.3', '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+
['name' => 'PHP-8.0', 'ref' => 'PHP-8.0', 'version' => ['major' => 8, 'minor' => 0]],
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) {
@@ -100,7 +94,7 @@ function get_windows_matrix_include(array $branches) {
10094
return $jobs;
10195
}
10296

103-
function get_version(): array {
97+
function get_current_version(): array {
10498
$file = dirname(__DIR__) . '/main/php_version.h';
10599
$content = file_get_contents($file);
106100
preg_match('(^#define PHP_MAJOR_VERSION (?<num>\d+)$)m', $content, $matches);
@@ -118,13 +112,14 @@ function get_version(): array {
118112
}
119113
$branch = $argv[3] ?? 'master';
120114

121-
$branches = $branch === 'master' ? get_branches() : get_branch_matrix([$branch]);
115+
$branches = $branch === 'master'
116+
? get_branches()
117+
: [['name' => strtoupper($branch), 'ref' => $branch, 'version' => get_current_version()]];
122118
$matrix_include = get_matrix_include($branches);
123119
$windows_matrix_include = get_windows_matrix_include($branches);
124120

125121
$f = fopen(getenv('GITHUB_OUTPUT'), 'a');
126122
fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n");
127123
fwrite($f, 'matrix-include=' . json_encode($matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
128124
fwrite($f, 'windows-matrix-include=' . json_encode($windows_matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
129-
fwrite($f, 'version=' . json_encode(get_version(), JSON_UNESCAPED_SLASHES) . "\n");
130125
fclose($f);

.github/workflows/nightly.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
branches: ${{ steps.set-matrix.outputs.branches }}
1515
matrix-include: ${{ steps.set-matrix.outputs.matrix-include }}
1616
windows-matrix-include: ${{ steps.set-matrix.outputs.windows-matrix-include }}
17-
version: ${{ steps.set-matrix.outputs.version }}
1817
steps:
1918
- uses: actions/checkout@v4
2019
with:
@@ -61,7 +60,7 @@ jobs:
6160
zts: [true, false]
6261
include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.matrix-include) }}
6362
name: "${{ matrix.branch.name }}_LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
64-
runs-on: ubuntu-${{ (needs.GENERATE_MATRIX.outputs.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }}
63+
runs-on: ubuntu-${{ (matrix.branch.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }}
6564
steps:
6665
- name: git checkout
6766
uses: actions/checkout@v4
@@ -148,7 +147,7 @@ jobs:
148147
name: "${{ matrix.branch.name }}_LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
149148
runs-on: ubuntu-latest
150149
container:
151-
image: ubuntu:${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
150+
image: ubuntu:${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
152151
services:
153152
mysql:
154153
image: mysql:8
@@ -332,7 +331,7 @@ jobs:
332331
matrix:
333332
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
334333
name: "${{ matrix.branch.name }}_COMMUNITY"
335-
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
334+
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
336335
env:
337336
UBSAN_OPTIONS: print_stacktrace=1
338337
USE_ZEND_ALLOC: 0
@@ -524,7 +523,7 @@ jobs:
524523
matrix:
525524
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
526525
name: "${{ matrix.branch.name }}_OPCACHE_VARIATION"
527-
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
526+
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
528527
steps:
529528
- name: git checkout
530529
uses: actions/checkout@v4
@@ -600,7 +599,7 @@ jobs:
600599
matrix:
601600
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
602601
name: "${{ matrix.branch.name }}_MSAN"
603-
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
602+
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
604603
steps:
605604
- name: git checkout
606605
uses: actions/checkout@v4
@@ -700,7 +699,7 @@ jobs:
700699
exclude:
701700
- branch: { name: 'PHP-80', ref: 'PHP-8.0' }
702701
name: "${{ matrix.branch.name }}_LIBMYSQLCLIENT"
703-
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
702+
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
704703
steps:
705704
- name: git checkout
706705
uses: actions/checkout@v4

0 commit comments

Comments
 (0)