Skip to content

Commit ce9e976

Browse files
committed
Add nightly for GitHub actions
1 parent 1364945 commit ce9e976

File tree

7 files changed

+212
-196
lines changed

7 files changed

+212
-196
lines changed

.github/nightly_matrix.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
const BRANCHES = ['master', 'PHP-8.1', 'PHP-8.0', 'PHP-7.4'];
4+
5+
function get_changed_branches() {
6+
$branch_commit_cache_file = dirname(__DIR__) . '/branch-commit-cache.json';
7+
$branch_commit_map = [];
8+
if (file_exists($branch_commit_cache_file)) {
9+
$branch_commit_map = json_decode(file_get_contents($branch_commit_cache_file), JSON_THROW_ON_ERROR);
10+
}
11+
12+
$changed_branches = [];
13+
foreach (BRANCHES as $branch) {
14+
$previous_commit_hash = $branch_commit_map[$branch] ?? null;
15+
$current_commit_hash = trim(shell_exec('git rev-parse origin/' . $branch));
16+
17+
if ($previous_commit_hash !== $current_commit_hash) {
18+
$changed_branches[] = $branch;
19+
}
20+
21+
$branch_commit_map[$branch] = $current_commit_hash;
22+
}
23+
24+
file_put_contents($branch_commit_cache_file, json_encode($branch_commit_map));
25+
26+
return $changed_branches;
27+
}
28+
29+
function get_branch_matrix(array $branches) {
30+
$result = array_map(function ($branch) {
31+
$branch_key = strtoupper(str_replace('.', '', $branch));
32+
return [
33+
'name' => $branch_key,
34+
'ref' => $branch,
35+
];
36+
}, $branches);
37+
38+
return $result;
39+
}
40+
41+
function get_asan_matrix(array $branches) {
42+
$jobs = [];
43+
foreach (get_branch_matrix($branches) as $branch) {
44+
$jobs[] = [
45+
'name' => '_ASAN_UBSAN',
46+
'branch' => $branch,
47+
'debug' => true,
48+
'zts' => true,
49+
'configuration_parameters' => "CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address'",
50+
'run_tests_parameters' => '--asan',
51+
];
52+
}
53+
return $jobs;
54+
}
55+
56+
$changed_branches = get_changed_branches();
57+
// FIXME: Change to run only for changed branches before merging
58+
$changed_branches = BRANCHES;
59+
$asan_matrix = get_asan_matrix($changed_branches);
60+
61+
echo '::set-output name=branches::' . json_encode(get_branch_matrix($changed_branches), JSON_UNESCAPED_SLASHES) . "\n";
62+
echo '::set-output name=asan-matrix::' . json_encode($asan_matrix, JSON_UNESCAPED_SLASHES) . "\n";

.github/workflows/nightly.yml

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