From 70129e2aabb16576791ebceae8dd71a330ef00f9 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 10 Nov 2023 20:44:42 +0100 Subject: [PATCH] Run nightly on single branch with workflow_dispatch and explicit branch --- .github/nightly_matrix.php | 14 +++++++++++++- .github/workflows/nightly.yml | 15 ++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/nightly_matrix.php b/.github/nightly_matrix.php index 33a50c55e0271..3e77f9186ca86 100644 --- a/.github/nightly_matrix.php +++ b/.github/nightly_matrix.php @@ -100,14 +100,25 @@ function get_windows_matrix_include(array $branches) { return $jobs; } +function get_version(): array { + $file = dirname(__DIR__) . '/main/php_version.h'; + $content = file_get_contents($file); + preg_match('(^#define PHP_MAJOR_VERSION (?\d+)$)m', $content, $matches); + $major = $matches['num']; + preg_match('(^#define PHP_MINOR_VERSION (?\d+)$)m', $content, $matches); + $minor = $matches['num']; + return ['major' => $major, 'minor' => $minor]; +} + $trigger = $argv[1] ?? 'schedule'; $attempt = (int) ($argv[2] ?? 1); $discard_cache = ($trigger === 'schedule' && $attempt !== 1) || $trigger === 'workflow_dispatch'; if ($discard_cache) { @unlink(get_branch_commit_cache_file_path()); } +$branch = $argv[3] ?? 'master'; -$branches = get_branches(); +$branches = $branch === 'master' ? get_branches() : get_branch_matrix([$branch]); $matrix_include = get_matrix_include($branches); $windows_matrix_include = get_windows_matrix_include($branches); @@ -115,4 +126,5 @@ function get_windows_matrix_include(array $branches) { 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); diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 13153e89c2c16..0d588a7db6b83 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,6 +14,7 @@ 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: @@ -32,7 +33,7 @@ jobs: nightly- - name: Generate Matrix id: set-matrix - run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" + run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.head_ref || github.ref_name }}" - name: Notify Slack if: failure() uses: ./.github/actions/notify-slack @@ -60,7 +61,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-${{ ((matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && !matrix.asan) && '22.04' || '20.04' }} + runs-on: ubuntu-${{ (needs.GENERATE_MATRIX.outputs.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }} steps: - name: git checkout uses: actions/checkout@v4 @@ -147,7 +148,7 @@ jobs: name: "${{ matrix.branch.name }}_LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" runs-on: ubuntu-latest container: - image: ubuntu:${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }} + image: ubuntu:${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }} services: mysql: image: mysql:8 @@ -331,7 +332,7 @@ jobs: matrix: branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} name: "${{ matrix.branch.name }}_COMMUNITY" - runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }} + runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }} env: UBSAN_OPTIONS: print_stacktrace=1 USE_ZEND_ALLOC: 0 @@ -517,7 +518,7 @@ jobs: matrix: branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} name: "${{ matrix.branch.name }}_OPCACHE_VARIATION" - runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }} + runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }} steps: - name: git checkout uses: actions/checkout@v4 @@ -593,7 +594,7 @@ jobs: matrix: branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} name: "${{ matrix.branch.name }}_MSAN" - runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }} + runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }} steps: - name: git checkout uses: actions/checkout@v4 @@ -693,7 +694,7 @@ jobs: exclude: - branch: { name: 'PHP-80', ref: 'PHP-8.0' } name: "${{ matrix.branch.name }}_LIBMYSQLCLIENT" - runs-on: ubuntu-${{ (matrix.branch.ref == 'PHP-8.3' || matrix.branch.ref == 'master') && '22.04' || '20.04' }} + runs-on: ubuntu-${{ needs.GENERATE_MATRIX.outputs.version.minor >= 3 && '22.04' || '20.04' }} steps: - name: git checkout uses: actions/checkout@v4