mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
[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.
This commit is contained in:
35
.github/nightly_matrix.php
vendored
35
.github/nightly_matrix.php
vendored
@@ -1,23 +1,17 @@
|
||||
<?php
|
||||
|
||||
const BRANCHES = ['master', 'PHP-8.3', 'PHP-8.2', 'PHP-8.1', 'PHP-8.0'];
|
||||
const BRANCHES = [
|
||||
['name' => 'master', 'ref' => 'master', 'version' => ['major' => 8, 'minor' => 4]],
|
||||
['name' => 'PHP-8.3', 'ref' => 'PHP-8.3', 'version' => ['major' => 8, 'minor' => 3]],
|
||||
['name' => 'PHP-8.2', 'ref' => 'PHP-8.2', 'version' => ['major' => 8, 'minor' => 2]],
|
||||
['name' => 'PHP-8.1', 'ref' => 'PHP-8.1', 'version' => ['major' => 8, 'minor' => 1]],
|
||||
['name' => 'PHP-8.0', 'ref' => 'PHP-8.0', 'version' => ['major' => 8, 'minor' => 0]],
|
||||
];
|
||||
|
||||
function get_branch_commit_cache_file_path(): string {
|
||||
return dirname(__DIR__) . '/branch-commit-cache.json';
|
||||
}
|
||||
|
||||
function get_branch_matrix(array $branches) {
|
||||
$result = array_map(function ($branch) {
|
||||
$branch_key = strtoupper(str_replace('.', '', $branch));
|
||||
return [
|
||||
'name' => $branch_key,
|
||||
'ref' => $branch,
|
||||
];
|
||||
}, $branches);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function get_branches() {
|
||||
$branch_commit_cache_file = get_branch_commit_cache_file_path();
|
||||
$branch_commit_map = [];
|
||||
@@ -27,19 +21,19 @@ function get_branches() {
|
||||
|
||||
$changed_branches = [];
|
||||
foreach (BRANCHES as $branch) {
|
||||
$previous_commit_hash = $branch_commit_map[$branch] ?? null;
|
||||
$current_commit_hash = trim(shell_exec('git rev-parse origin/' . $branch));
|
||||
$previous_commit_hash = $branch_commit_map[$branch['ref']] ?? null;
|
||||
$current_commit_hash = trim(shell_exec('git rev-parse origin/' . $branch['ref']));
|
||||
|
||||
if ($previous_commit_hash !== $current_commit_hash) {
|
||||
$changed_branches[] = $branch;
|
||||
}
|
||||
|
||||
$branch_commit_map[$branch] = $current_commit_hash;
|
||||
$branch_commit_map[$branch['ref']] = $current_commit_hash;
|
||||
}
|
||||
|
||||
file_put_contents($branch_commit_cache_file, json_encode($branch_commit_map));
|
||||
|
||||
return get_branch_matrix($changed_branches);
|
||||
return $changed_branches;
|
||||
}
|
||||
|
||||
function get_matrix_include(array $branches) {
|
||||
@@ -100,7 +94,7 @@ function get_windows_matrix_include(array $branches) {
|
||||
return $jobs;
|
||||
}
|
||||
|
||||
function get_version(): array {
|
||||
function get_current_version(): array {
|
||||
$file = dirname(__DIR__) . '/main/php_version.h';
|
||||
$content = file_get_contents($file);
|
||||
preg_match('(^#define PHP_MAJOR_VERSION (?<num>\d+)$)m', $content, $matches);
|
||||
@@ -118,7 +112,9 @@ if ($discard_cache) {
|
||||
}
|
||||
$branch = $argv[3] ?? 'master';
|
||||
|
||||
$branches = $branch === 'master' ? get_branches() : get_branch_matrix([$branch]);
|
||||
$branches = $branch === 'master'
|
||||
? get_branches()
|
||||
: [['name' => strtoupper($branch), 'ref' => $branch, 'version' => get_current_version()]];
|
||||
$matrix_include = get_matrix_include($branches);
|
||||
$windows_matrix_include = get_windows_matrix_include($branches);
|
||||
|
||||
@@ -126,5 +122,4 @@ $f = fopen(getenv('GITHUB_OUTPUT'), 'a');
|
||||
fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n");
|
||||
fwrite($f, 'matrix-include=' . json_encode($matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
|
||||
fwrite($f, 'windows-matrix-include=' . json_encode($windows_matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
|
||||
fwrite($f, 'version=' . json_encode(get_version(), JSON_UNESCAPED_SLASHES) . "\n");
|
||||
fclose($f);
|
||||
|
||||
13
.github/workflows/nightly.yml
vendored
13
.github/workflows/nightly.yml
vendored
@@ -14,7 +14,6 @@ jobs:
|
||||
branches: ${{ steps.set-matrix.outputs.branches }}
|
||||
matrix-include: ${{ steps.set-matrix.outputs.matrix-include }}
|
||||
windows-matrix-include: ${{ steps.set-matrix.outputs.windows-matrix-include }}
|
||||
version: ${{ steps.set-matrix.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -61,7 +60,7 @@ jobs:
|
||||
zts: [true, false]
|
||||
include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.matrix-include) }}
|
||||
name: "${{ matrix.branch.name }}_LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
|
||||
runs-on: ubuntu-${{ (needs.GENERATE_MATRIX.outputs.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }}
|
||||
runs-on: ubuntu-${{ (matrix.branch.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }}
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -148,7 +147,7 @@ jobs:
|
||||
name: "${{ matrix.branch.name }}_LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ubuntu:${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
image: ubuntu:${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8
|
||||
@@ -332,7 +331,7 @@ jobs:
|
||||
matrix:
|
||||
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
|
||||
name: "${{ matrix.branch.name }}_COMMUNITY"
|
||||
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
USE_ZEND_ALLOC: 0
|
||||
@@ -524,7 +523,7 @@ jobs:
|
||||
matrix:
|
||||
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
|
||||
name: "${{ matrix.branch.name }}_OPCACHE_VARIATION"
|
||||
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -600,7 +599,7 @@ jobs:
|
||||
matrix:
|
||||
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
|
||||
name: "${{ matrix.branch.name }}_MSAN"
|
||||
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -700,7 +699,7 @@ jobs:
|
||||
exclude:
|
||||
- branch: { name: 'PHP-80', ref: 'PHP-8.0' }
|
||||
name: "${{ matrix.branch.name }}_LIBMYSQLCLIENT"
|
||||
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
Reference in New Issue
Block a user