Skip to content

Commit 2bbb468

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Add nightly for GitHub actions
2 parents 2ac5948 + 6b5a31e commit 2bbb468

File tree

7 files changed

+229
-192
lines changed

7 files changed

+229
-192
lines changed

.github/nightly_matrix.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
const BRANCHES = ['master', 'PHP-8.1', 'PHP-8.0'];
4+
5+
function get_branch_commit_cache_file_path(): string {
6+
return dirname(__DIR__) . '/branch-commit-cache.json';
7+
}
8+
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+
21+
function get_branches(string $trigger, string $pr_commit_hash) {
22+
if ($trigger === 'issue_comment' && strlen($pr_commit_hash) !== 0) {
23+
return [['name' => 'PR', 'ref' => $pr_commit_hash]];
24+
}
25+
26+
$branch_commit_cache_file = get_branch_commit_cache_file_path();
27+
$branch_commit_map = [];
28+
if (file_exists($branch_commit_cache_file)) {
29+
$branch_commit_map = json_decode(file_get_contents($branch_commit_cache_file), JSON_THROW_ON_ERROR);
30+
}
31+
32+
$changed_branches = [];
33+
foreach (BRANCHES as $branch) {
34+
$previous_commit_hash = $branch_commit_map[$branch] ?? null;
35+
$current_commit_hash = trim(shell_exec('git rev-parse origin/' . $branch));
36+
37+
if ($previous_commit_hash !== $current_commit_hash) {
38+
$changed_branches[] = $branch;
39+
}
40+
41+
$branch_commit_map[$branch] = $current_commit_hash;
42+
}
43+
44+
file_put_contents($branch_commit_cache_file, json_encode($branch_commit_map));
45+
46+
return get_branch_matrix($changed_branches);
47+
}
48+
49+
function get_asan_matrix(array $branches) {
50+
$jobs = [];
51+
foreach ($branches as $branch) {
52+
$jobs[] = [
53+
'name' => '_ASAN_UBSAN',
54+
'branch' => $branch,
55+
'debug' => true,
56+
'zts' => true,
57+
'configuration_parameters' => "CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address'",
58+
'run_tests_parameters' => '--asan',
59+
];
60+
}
61+
return $jobs;
62+
}
63+
64+
$trigger = $argv[1] ?? 'schedule';
65+
$attempt = (int) ($argv[2] ?? 1);
66+
$pr_commit_hash = $argv[3] ?? '';
67+
68+
$discard_cache = ($trigger === 'schedule' && $attempt !== 1) || $trigger === 'workflow_dispatch';
69+
if ($discard_cache) {
70+
@unlink(get_branch_commit_cache_file_path());
71+
}
72+
73+
$branches = get_branches($trigger, $pr_commit_hash);
74+
$asan_matrix = get_asan_matrix($branches);
75+
76+
echo '::set-output name=branches::' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n";
77+
echo '::set-output name=asan-matrix::' . json_encode($asan_matrix, JSON_UNESCAPED_SLASHES) . "\n";

.github/workflows/nightly.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Nightly
2+
on:
3+
schedule:
4+
- cron: "0 1 * * *"
5+
workflow_dispatch: ~
6+
issue_comment:
7+
types: [created]
8+
jobs:
9+
GENERATE_MATRIX:
10+
name: Generate Matrix
11+
if: ${{ github.event_name != 'issue_comment' || (github.event.issue.pull_request && contains(github.event.comment.body, '@php run-extended-tests')) }}
12+
runs-on: ubuntu-latest
13+
outputs:
14+
branches: ${{ steps.set-matrix.outputs.branches }}
15+
asan-matrix: ${{ steps.set-matrix.outputs.asan-matrix }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
# Set fetch-depth to 0 to clone the full repository
20+
# including all branches. This is required to find
21+
# the correct commit hashes.
22+
fetch-depth: 0
23+
- name: Grab the commit mapping
24+
uses: actions/cache@v3
25+
with:
26+
path: branch-commit-cache.json
27+
# The cache key needs to change every time for the
28+
# cache to be updated after this job finishes.
29+
key: nightly-${{ github.run_id }}-${{ github.run_attempt }}
30+
restore-keys: |
31+
nightly-
32+
- name: Generate Matrix
33+
id: set-matrix
34+
run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.event.pull_request.head.sha }}"
35+
LINUX_X64:
36+
needs: GENERATE_MATRIX
37+
if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' && (github.event_name != 'issue_comment' || (github.event.issue.pull_request && contains(github.event.comment.body, '@php run-extended-tests'))) }}
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
42+
debug: [true, false]
43+
zts: [true, false]
44+
include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.asan-matrix) }}
45+
name: "${{ matrix.branch.name }}_LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
46+
runs-on: ubuntu-20.04
47+
steps:
48+
- name: git checkout
49+
uses: actions/checkout@v2
50+
with:
51+
ref: ${{ matrix.branch.ref }}
52+
- name: Create mssql container
53+
uses: ./.github/actions/mssql
54+
- name: apt
55+
uses: ./.github/actions/apt-x64
56+
- name: ./configure
57+
uses: ./.github/actions/configure-x64
58+
with:
59+
configurationParameters: >-
60+
${{ matrix.configuration_parameters }}
61+
--${{ matrix.debug && 'enable' || 'disable' }}-debug
62+
--${{ matrix.zts && 'enable' || 'disable' }}-zts
63+
- name: make
64+
run: make -j$(/usr/bin/nproc) >/dev/null
65+
- name: make install
66+
uses: ./.github/actions/install-linux
67+
- name: Setup
68+
uses: ./.github/actions/setup-x64
69+
- name: Test
70+
uses: ./.github/actions/test-linux
71+
with:
72+
runTestsParameters: >-
73+
${{ matrix.run_tests_parameters }}
74+
- name: Test Tracing JIT
75+
uses: ./.github/actions/test-linux
76+
with:
77+
runTestsParameters: >-
78+
${{ matrix.run_tests_parameters }}
79+
-d zend_extension=opcache.so
80+
-d opcache.jit_buffer_size=16M
81+
- name: Test OpCache
82+
uses: ./.github/actions/test-linux
83+
with:
84+
runTestsParameters: >-
85+
${{ matrix.run_tests_parameters }}
86+
-d zend_extension=opcache.so
87+
- name: Test Function JIT
88+
uses: ./.github/actions/test-linux
89+
with:
90+
runTestsParameters: >-
91+
${{ matrix.run_tests_parameters }}
92+
-d zend_extension=opcache.so
93+
-d opcache.jit_buffer_size=16M
94+
-d opcache.jit=1205
95+
MACOS:
96+
needs: GENERATE_MATRIX
97+
if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' && (github.event_name != 'issue_comment' || (github.event.issue.pull_request && contains(github.event.comment.body, '@php run-extended-tests'))) }}
98+
strategy:
99+
fail-fast: false
100+
matrix:
101+
branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
102+
debug: [true, false]
103+
zts: [true, false]
104+
name: "${{ matrix.branch.name }}_MACOS_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
105+
runs-on: macos-10.15
106+
steps:
107+
- name: git checkout
108+
uses: actions/checkout@v2
109+
with:
110+
ref: ${{ matrix.branch.ref }}
111+
- name: brew
112+
uses: ./.github/actions/brew
113+
- name: ./configure
114+
uses: ./.github/actions/configure-macos
115+
with:
116+
configurationParameters: >-
117+
--${{ matrix.debug && 'enable' || 'disable' }}-debug
118+
--${{ matrix.zts && 'enable' || 'disable' }}-zts
119+
- name: make
120+
run: |-
121+
export PATH="/usr/local/opt/bison/bin:$PATH"
122+
make -j$(sysctl -n hw.logicalcpu) >/dev/null
123+
- name: make install
124+
run: sudo make install
125+
- name: Test
126+
uses: ./.github/actions/test-macos
127+
- name: Test Tracing JIT
128+
uses: ./.github/actions/test-macos
129+
with:
130+
runTestsParameters: >-
131+
-d zend_extension=opcache.so
132+
-d opcache.protect_memory=1
133+
-d opcache.jit_buffer_size=16M
134+
- name: Test OpCache
135+
uses: ./.github/actions/test-macos
136+
with:
137+
runTestsParameters: >-
138+
-d zend_extension=opcache.so
139+
-d opcache.protect_memory=1
140+
- name: Test Function JIT
141+
uses: ./.github/actions/test-macos
142+
with:
143+
runTestsParameters: >-
144+
-d zend_extension=opcache.so
145+
-d opcache.protect_memory=1
146+
-d opcache.jit_buffer_size=16M
147+
-d opcache.jit=1205

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ tmp-php.ini
277277
/Zend/zend_dtrace_gen.h
278278
/Zend/zend_dtrace_gen.h.bak
279279

280+
# ------------------------------------------------------------------------------
281+
# GitHub actions cache
282+
# ------------------------------------------------------------------------------
283+
/branch-commit-cache.json
284+
280285
# ------------------------------------------------------------------------------
281286
# Special cases to invert previous ignore patterns
282287
# ------------------------------------------------------------------------------

azure-pipelines.yml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ jobs:
3232
configurationName: I386_DEBUG_ZTS
3333
configurationParameters: '--enable-debug --enable-zts'
3434
- ${{ if eq(variables['Build.Reason'], 'Schedule') }}:
35-
- template: azure/job.yml
36-
parameters:
37-
configurationName: DEBUG_ZTS
38-
configurationParameters: '--enable-debug --enable-zts'
39-
- template: azure/job.yml
40-
parameters:
41-
configurationName: RELEASE_NTS
42-
configurationParameters: '--disable-debug --disable-zts'
4335
- template: azure/i386/job.yml
4436
parameters:
4537
configurationName: I386_DEBUG_NTS
@@ -52,30 +44,6 @@ jobs:
5244
parameters:
5345
configurationName: I386_RELEASE_ZTS
5446
configurationParameters: '--disable-debug --enable-zts'
55-
- template: azure/macos/job.yml
56-
parameters:
57-
configurationName: MACOS_DEBUG_ZTS
58-
configurationParameters: '--enable-debug --enable-zts'
59-
- template: azure/macos/job.yml
60-
parameters:
61-
configurationName: MACOS_RELEASE_NTS
62-
configurationParameters: '--disable-debug --disable-zts'
63-
- template: azure/macos/job.yml
64-
parameters:
65-
configurationName: MACOS_RELEASE_ZTS
66-
configurationParameters: '--disable-debug --enable-zts'
67-
- template: azure/job.yml
68-
parameters:
69-
configurationName: DEBUG_ZTS_ASAN_UBSAN
70-
configurationParameters: '--enable-debug --enable-zts --enable-address-sanitizer --enable-undefined-sanitizer'
71-
runTestsParameters: --asan
72-
timeoutInMinutes: 360
73-
- template: azure/msan_job.yml
74-
parameters:
75-
configurationName: DEBUG_ZTS_MSAN
76-
configurationParameters: '--enable-debug --enable-zts'
77-
runTestsParameters: --msan
78-
timeoutInMinutes: 120
7947
- template: azure/community_job.yml
8048
parameters:
8149
configurationName: COMMUNITY

azure/macos/brew.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)