Skip to content

Commit cce2ac8

Browse files
committed
Add nightly for GitHub actions
1 parent 7c702b7 commit cce2ac8

File tree

7 files changed

+231
-196
lines changed

7 files changed

+231
-196
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
@@ -274,6 +274,11 @@ tmp-php.ini
274274
/Zend/zend_dtrace_gen.h
275275
/Zend/zend_dtrace_gen.h.bak
276276

277+
# ------------------------------------------------------------------------------
278+
# GitHub actions cache
279+
# ------------------------------------------------------------------------------
280+
/branch-commit-cache.json
281+
277282
# ------------------------------------------------------------------------------
278283
# Special cases to invert previous ignore patterns
279284
# ------------------------------------------------------------------------------

azure-pipelines.yml

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ trigger:
44
include:
55
- PHP-7.4
66
- PHP-8.0
7+
- PHP-8.1
78
- master
89
paths:
910
exclude:
@@ -19,6 +20,7 @@ schedules:
1920
include:
2021
- PHP-7.4
2122
- PHP-8.0
23+
- PHP-8.1
2224
- master
2325

2426
jobs:
@@ -27,14 +29,6 @@ jobs:
2729
configurationName: I386_DEBUG_ZTS
2830
configurationParameters: '--enable-debug --enable-zts'
2931
- ${{ if eq(variables['Build.Reason'], 'Schedule') }}:
30-
- template: azure/job.yml
31-
parameters:
32-
configurationName: DEBUG_ZTS
33-
configurationParameters: '--enable-debug --enable-zts'
34-
- template: azure/job.yml
35-
parameters:
36-
configurationName: RELEASE_NTS
37-
configurationParameters: '--disable-debug --disable-zts'
3832
- template: azure/i386/job.yml
3933
parameters:
4034
configurationName: I386_DEBUG_NTS
@@ -47,33 +41,6 @@ jobs:
4741
parameters:
4842
configurationName: I386_RELEASE_ZTS
4943
configurationParameters: '--disable-debug --enable-zts'
50-
- template: azure/macos/job.yml
51-
parameters:
52-
configurationName: MACOS_DEBUG_ZTS
53-
configurationParameters: '--enable-debug --enable-zts'
54-
- template: azure/macos/job.yml
55-
parameters:
56-
configurationName: MACOS_RELEASE_NTS
57-
configurationParameters: '--disable-debug --disable-zts'
58-
- template: azure/macos/job.yml
59-
parameters:
60-
configurationName: MACOS_RELEASE_ZTS
61-
configurationParameters: '--disable-debug --enable-zts'
62-
- template: azure/job.yml
63-
parameters:
64-
configurationName: DEBUG_ZTS_ASAN_UBSAN
65-
configurationParameters: >-
66-
--enable-debug --enable-zts
67-
CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC'
68-
LDFLAGS='-fsanitize=undefined,address'
69-
runTestsParameters: --asan
70-
timeoutInMinutes: 360
71-
- template: azure/msan_job.yml
72-
parameters:
73-
configurationName: DEBUG_ZTS_MSAN
74-
configurationParameters: '--enable-debug --enable-zts'
75-
runTestsParameters: --msan
76-
timeoutInMinutes: 90
7744
- template: azure/community_job.yml
7845
parameters:
7946
configurationName: COMMUNITY

azure/macos/brew.yml

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

0 commit comments

Comments
 (0)