Skip to content

Commit 5de1cd9

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

File tree

7 files changed

+224
-196
lines changed

7 files changed

+224
-196
lines changed

.github/nightly_matrix.php

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

.github/workflows/nightly.yml

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