Skip to content

Commit 90fda03

Browse files
authored
Run nightly on single branch with workflow_dispatch and explicit branch (#12649)
1 parent 74a7b79 commit 90fda03

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

.github/nightly_matrix.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,31 @@ function get_windows_matrix_include(array $branches) {
100100
return $jobs;
101101
}
102102

103+
function get_version(): array {
104+
$file = dirname(__DIR__) . '/main/php_version.h';
105+
$content = file_get_contents($file);
106+
preg_match('(^#define PHP_MAJOR_VERSION (?<num>\d+)$)m', $content, $matches);
107+
$major = $matches['num'];
108+
preg_match('(^#define PHP_MINOR_VERSION (?<num>\d+)$)m', $content, $matches);
109+
$minor = $matches['num'];
110+
return ['major' => $major, 'minor' => $minor];
111+
}
112+
103113
$trigger = $argv[1] ?? 'schedule';
104114
$attempt = (int) ($argv[2] ?? 1);
105115
$discard_cache = ($trigger === 'schedule' && $attempt !== 1) || $trigger === 'workflow_dispatch';
106116
if ($discard_cache) {
107117
@unlink(get_branch_commit_cache_file_path());
108118
}
119+
$branch = $argv[3] ?? 'master';
109120

110-
$branches = get_branches();
121+
$branches = $branch === 'master' ? get_branches() : get_branch_matrix([$branch]);
111122
$matrix_include = get_matrix_include($branches);
112123
$windows_matrix_include = get_windows_matrix_include($branches);
113124

114125
$f = fopen(getenv('GITHUB_OUTPUT'), 'a');
115126
fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n");
116127
fwrite($f, 'matrix-include=' . json_encode($matrix_include, JSON_UNESCAPED_SLASHES) . "\n");
117128
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");
118130
fclose($f);

.github/workflows/nightly.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ 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 }}
1718
steps:
1819
- uses: actions/checkout@v4
1920
with:
@@ -32,7 +33,7 @@ jobs:
3233
nightly-
3334
- name: Generate Matrix
3435
id: set-matrix
35-
run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}"
36+
run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.head_ref || github.ref_name }}"
3637
- name: Notify Slack
3738
if: failure()
3839
uses: ./.github/actions/notify-slack
@@ -60,7 +61,7 @@ jobs:
6061
zts: [true, false]
6162
include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.matrix-include) }}
6263
name: "${{ matrix.branch.name }}_LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
63-
runs-on: ubuntu-${{ ((matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && !matrix.asan) && '22.04' || '20.04' }}
64+
runs-on: ubuntu-${{ (needs.GENERATE_MATRIX.outputs.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }}
6465
steps:
6566
- name: git checkout
6667
uses: actions/checkout@v4
@@ -147,7 +148,7 @@ jobs:
147148
name: "${{ matrix.branch.name }}_LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
148149
runs-on: ubuntu-latest
149150
container:
150-
image: ubuntu:${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }}
151+
image: ubuntu:${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
151152
services:
152153
mysql:
153154
image: mysql:8
@@ -331,7 +332,7 @@ jobs:
331332
matrix:
332333
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
333334
name: "${{ matrix.branch.name }}_COMMUNITY"
334-
runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }}
335+
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
335336
env:
336337
UBSAN_OPTIONS: print_stacktrace=1
337338
USE_ZEND_ALLOC: 0
@@ -517,7 +518,7 @@ jobs:
517518
matrix:
518519
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
519520
name: "${{ matrix.branch.name }}_OPCACHE_VARIATION"
520-
runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }}
521+
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
521522
steps:
522523
- name: git checkout
523524
uses: actions/checkout@v4
@@ -593,7 +594,7 @@ jobs:
593594
matrix:
594595
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
595596
name: "${{ matrix.branch.name }}_MSAN"
596-
runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }}
597+
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
597598
steps:
598599
- name: git checkout
599600
uses: actions/checkout@v4
@@ -693,7 +694,7 @@ jobs:
693694
exclude:
694695
- branch: { name: 'PHP-80', ref: 'PHP-8.0' }
695696
name: "${{ matrix.branch.name }}_LIBMYSQLCLIENT"
696-
runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }}
697+
runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }}
697698
steps:
698699
- name: git checkout
699700
uses: actions/checkout@v4

0 commit comments

Comments
 (0)