Skip to content

Commit df79dfd

Browse files
committed
bump
1 parent 0a42e6f commit df79dfd

File tree

3 files changed

+348
-945
lines changed

3 files changed

+348
-945
lines changed

.github/jit_check.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
register_shutdown_function(function () {
4+
$status = opcache_get_status(false);
5+
var_dump($status);
6+
7+
if ($status["memory_usage"]["free_memory"] < 10*1024*1024) {
8+
fwrite(STDERR, "Not enough free opcache memory!".PHP_EOL);
9+
}
10+
if ($status["interned_strings_usage"]["free_memory"] < 1*1024*1024) {
11+
fwrite(STDERR, "Not enough free interned strings memory!".PHP_EOL);
12+
}
13+
if ($status["jit"]["buffer_free"] < 10*1024*1024) {
14+
fwrite(STDERR, "Not enough free JIT memory!".PHP_EOL);
15+
}
16+
if (!$status["jit"]["on"]) {
17+
fwrite(STDERR, "JIT is not enabled!".PHP_EOL);
18+
}
19+
20+
unset($status);
21+
while (gc_collect_cycles());
22+
});
23+
24+
$argc--;
25+
array_shift($argv);
26+
27+
$_SERVER['argc']--;
28+
array_shift($_SERVER['argv']);
29+
30+
require $argv[0];

.github/nightly.php

Lines changed: 297 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,297 @@
1+
<?php
2+
3+
putenv("ASAN_OPTIONS=exitcode=139");
4+
putenv("SYMFONY_DEPRECATIONS_HELPER=max[total]=999");
5+
putenv("PHPSECLIB_ALLOW_JIT=1");
6+
7+
function printMutex(string $result): void {
8+
flock(STDOUT, LOCK_EX);
9+
fwrite(STDOUT, $result.PHP_EOL);
10+
flock(STDOUT, LOCK_UN);
11+
}
12+
13+
function e(string $cmd, string $extra = ''): string {
14+
exec("bash -c ".escapeshellarg("$cmd 2>&1"), $result, $code);
15+
$result = implode("\n", $result);
16+
if ($code) {
17+
printMutex("An error occurred while executing $cmd (status $code, extra info $extra): $result");
18+
die(1);
19+
}
20+
return $result;
21+
}
22+
23+
$parallel = (int) ($argv[1] ?? 0);
24+
$parallel = $parallel ?: ((int)`nproc`);
25+
$parallel = $parallel ?: 8;
26+
27+
$repos = [];
28+
29+
$repos["psalm"] = [
30+
"https://github.com/vimeo/psalm",
31+
"master",
32+
null,
33+
function (): iterable {
34+
$it = new RecursiveDirectoryIterator("tests");
35+
/** @var SplFileInfo $file */
36+
foreach(new RecursiveIteratorIterator($it) as $file) {
37+
if ($file->getExtension() == 'php' && ctype_upper($file->getBasename()[0])) {
38+
yield [
39+
getcwd()."/vendor/bin/phpunit",
40+
$file->getRealPath(),
41+
];
42+
}
43+
}
44+
},
45+
2
46+
];
47+
48+
$repos["phpseclib"] = [
49+
"https://github.com/phpseclib/phpseclib",
50+
"master",
51+
null,
52+
function (): iterable {
53+
$it = new RecursiveDirectoryIterator("tests");
54+
/** @var SplFileInfo $file */
55+
foreach(new RecursiveIteratorIterator($it) as $file) {
56+
if ($file->getExtension() == 'php' && ctype_upper($file->getBasename()[0])) {
57+
yield [
58+
getcwd()."/vendor/bin/phpunit",
59+
'-c',
60+
getcwd()."/tests/phpunit.xml",
61+
$file->getRealPath(),
62+
];
63+
}
64+
}
65+
},
66+
2
67+
];
68+
69+
$repos["phpunit"] = [
70+
"https://github.com/sebastianbergmann/phpunit.git",
71+
"main",
72+
null,
73+
["./phpunit"],
74+
2
75+
];
76+
77+
$repos["infection"] = [
78+
"https://github.com/infection/infection",
79+
"master",
80+
null,
81+
["vendor/bin/phpunit"],
82+
2
83+
];
84+
85+
$repos["wordpress"] = [
86+
"https://github.com/WordPress/wordpress-develop.git",
87+
"",
88+
function (): void {
89+
$f = file_get_contents('wp-tests-config-sample.php');
90+
$f = str_replace('youremptytestdbnamehere', 'test', $f);
91+
$f = str_replace('yourusernamehere', 'root', $f);
92+
$f = str_replace('yourpasswordhere', 'root', $f);
93+
file_put_contents('wp-tests-config.php', $f);
94+
},
95+
["vendor/bin/phpunit"],
96+
2
97+
];
98+
99+
foreach (['amp', 'cache', 'dns', 'file', 'http', 'parallel', 'parser', 'pipeline', 'process', 'serialization', 'socket', 'sync', 'websocket-client', 'websocket-server'] as $repo) {
100+
$repos["amphp-$repo"] = ["https://github.com/amphp/$repo.git", "", null, ["vendor/bin/phpunit"], 2];
101+
}
102+
103+
$repos["laravel"] = [
104+
"https://github.com/laravel/framework.git",
105+
"master",
106+
function (): void {
107+
$c = file_get_contents("tests/Filesystem/FilesystemTest.php");
108+
$c = str_replace("public function testSharedGet()", "#[\\PHPUnit\\Framework\\Attributes\\Group('skip')]\n public function testSharedGet()", $c);
109+
file_put_contents("tests/Filesystem/FilesystemTest.php", $c);
110+
},
111+
["vendor/bin/phpunit", "--exclude-group", "skip"],
112+
2
113+
];
114+
115+
foreach (['async', 'cache', 'child-process', 'datagram', 'dns', 'event-loop', 'promise', 'promise-stream', 'promise-timer', 'stream'] as $repo) {
116+
$repos["reactphp-$repo"] = ["https://github.com/reactphp/$repo.git", "", null, ["vendor/bin/phpunit"], 2];
117+
}
118+
119+
$repos["revolt"] = ["https://github.com/revoltphp/event-loop.git", "", null, ["vendor/bin/phpunit"], 2];
120+
121+
$repos["symfony"] = [
122+
"https://github.com/symfony/symfony.git",
123+
"",
124+
function (): void {
125+
e("php ./phpunit install");
126+
},
127+
function (): iterable {
128+
$it = new RecursiveDirectoryIterator("src/Symfony");
129+
/** @var SplFileInfo $file */
130+
foreach(new RecursiveIteratorIterator($it) as $file) {
131+
if ($file->getBasename() == 'phpunit.xml.dist') {
132+
yield [
133+
getcwd()."/phpunit",
134+
dirname($file->getRealPath()),
135+
"--exclude-group",
136+
"tty,benchmark,intl-data,transient",
137+
"--exclude-group",
138+
"skip"
139+
];
140+
}
141+
}
142+
},
143+
2
144+
];
145+
146+
$finalStatus = 0;
147+
$parentPids = [];
148+
149+
$waitOne = function () use (&$finalStatus, &$parentPids): void {
150+
$res = pcntl_wait($status);
151+
if ($res === -1) {
152+
printMutex("An error occurred while waiting with waitpid!");
153+
$finalStatus = $finalStatus ?: 1;
154+
return;
155+
}
156+
if (!isset($parentPids[$res])) {
157+
printMutex("Unknown PID $res returned!");
158+
$finalStatus = $finalStatus ?: 1;
159+
return;
160+
}
161+
$desc = $parentPids[$res];
162+
unset($parentPids[$res]);
163+
if (pcntl_wifexited($status)) {
164+
$status = pcntl_wexitstatus($status);
165+
printMutex("Child task $desc exited with status $status");
166+
if ($status !== 0) {
167+
$finalStatus = $status;
168+
}
169+
} elseif (pcntl_wifstopped($status)) {
170+
$status = pcntl_wstopsig($status);
171+
printMutex("Child task $desc stopped by signal $status");
172+
$finalStatus = 1;
173+
} elseif (pcntl_wifsignaled($status)) {
174+
$status = pcntl_wtermsig($status);
175+
printMutex("Child task $desc terminated by signal $status");
176+
$finalStatus = 1;
177+
}
178+
};
179+
180+
$waitAll = function () use ($waitOne, &$parentPids): void {
181+
while ($parentPids) {
182+
$waitOne();
183+
}
184+
};
185+
186+
printMutex("Cloning repos...");
187+
188+
foreach ($repos as $dir => [$repo, $branch, $prepare, $command, $repeat]) {
189+
$pid = pcntl_fork();
190+
if ($pid) {
191+
$parentPids[$pid] = "clone $dir";
192+
continue;
193+
}
194+
195+
chdir(sys_get_temp_dir());
196+
if ($branch) {
197+
$branch = "--branch $branch";
198+
}
199+
e("git clone $repo $branch --depth 1 $dir");
200+
201+
exit(0);
202+
}
203+
204+
$waitAll();
205+
206+
printMutex("Done cloning repos!");
207+
208+
printMutex("Preparing repos (max $parallel processes)...");
209+
foreach ($repos as $dir => [$repo, $branch, $prepare, $command, $repeat]) {
210+
chdir(sys_get_temp_dir()."/$dir");
211+
$rev = e("git rev-parse HEAD", $dir);
212+
213+
$pid = pcntl_fork();
214+
if ($pid) {
215+
$parentPids[$pid] = "prepare $dir ($rev)";
216+
if (count($parentPids) >= $parallel) {
217+
$waitOne();
218+
}
219+
continue;
220+
}
221+
222+
e("composer i --ignore-platform-reqs", $dir);
223+
if ($prepare) {
224+
$prepare();
225+
}
226+
227+
exit(0);
228+
}
229+
$waitAll();
230+
231+
printMutex("Done preparing repos!");
232+
233+
printMutex("Running tests (max $parallel processes)...");
234+
foreach ($repos as $dir => [$repo, $branch, $prepare, $command, $repeat]) {
235+
chdir(sys_get_temp_dir()."/$dir");
236+
$rev = e("git rev-parse HEAD", $dir);
237+
238+
if ($command instanceof Closure) {
239+
$commands = iterator_to_array($command());
240+
} else {
241+
$commands = [$command];
242+
}
243+
244+
foreach ($commands as $idx => $cmd) {
245+
$cmd = array_merge([
246+
PHP_BINARY,
247+
'--repeat',
248+
$repeat,
249+
'-f',
250+
__DIR__.'/jit_check.php',
251+
], $cmd);
252+
253+
$cmdStr = implode(" ", $cmd);
254+
255+
$pid = pcntl_fork();
256+
if ($pid) {
257+
$parentPids[$pid] = "test $dir ($rev): $cmdStr";
258+
if (count($parentPids) >= $parallel) {
259+
$waitOne();
260+
}
261+
continue;
262+
}
263+
264+
$output = sys_get_temp_dir()."/out_{$dir}_$idx.txt";
265+
266+
$p = proc_open($cmd, [
267+
["pipe", "r"],
268+
["file", $output, "a"],
269+
["file", $output, "a"]
270+
], $pipes, sys_get_temp_dir()."/$dir");
271+
272+
if ($p === false) {
273+
printMutex("Failure starting $cmdStr");
274+
exit(1);
275+
}
276+
277+
$final = 0;
278+
$status = proc_close($p);
279+
if ($status !== 0) {
280+
if ($status > 128) {
281+
$final = $status;
282+
}
283+
printMutex(
284+
"$dir ($rev): $cmdStr terminated with status $status:".PHP_EOL
285+
.file_get_contents($output).PHP_EOL
286+
);
287+
}
288+
289+
exit($final);
290+
}
291+
}
292+
293+
$waitAll();
294+
295+
printMutex("All done!");
296+
297+
die($finalStatus);

0 commit comments

Comments
 (0)