Preflight required extensions for API CI
This commit is contained in:
@@ -47,13 +47,31 @@ $commands = [
|
||||
'RUN_INTEGRATION_TESTS=1 vendor/bin/pest --testsuite=Integration --colors=always',
|
||||
],
|
||||
'api' => [
|
||||
'RUN_API_TESTS=1 API_TEST_BOOTSTRAP_SCHEMA=1 API_TEST_ALLOW_LIVE_DB=1 API_TEST_REQUEST_TIMEOUT=180 vendor/bin/pest --testsuite=Api --colors=always',
|
||||
'RUN_API_TESTS=1 API_TEST_FAIL_ON_SKIP=1 API_TEST_BOOTSTRAP_SCHEMA=1 API_TEST_ALLOW_LIVE_DB=1 API_TEST_REQUEST_TIMEOUT=180 vendor/bin/pest --testsuite=Api --colors=always',
|
||||
],
|
||||
'legacy' => [
|
||||
'RUN_LEGACY_TESTS=1 RUN_INTEGRATION_TESTS=1 RUN_API_TESTS=1 API_TEST_BOOTSTRAP_SCHEMA=1 API_TEST_ALLOW_LIVE_DB=1 API_TEST_REQUEST_TIMEOUT=180 vendor/bin/pest --testsuite=Legacy --colors=always',
|
||||
'RUN_LEGACY_TESTS=1 RUN_INTEGRATION_TESTS=1 RUN_API_TESTS=1 API_TEST_FAIL_ON_SKIP=1 API_TEST_BOOTSTRAP_SCHEMA=1 API_TEST_ALLOW_LIVE_DB=1 API_TEST_REQUEST_TIMEOUT=180 vendor/bin/pest --testsuite=Legacy --colors=always',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array<int, string> $extensions
|
||||
*/
|
||||
function assert_required_php_extensions(array $extensions): void
|
||||
{
|
||||
$missing = array_values(array_filter(
|
||||
$extensions,
|
||||
static fn (string $extension): bool => !extension_loaded($extension)
|
||||
));
|
||||
|
||||
if ($missing === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite(STDERR, 'Missing required PHP extension(s): ' . implode(', ', $missing) . PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function reset_ci_state(): void
|
||||
{
|
||||
$database = getenv('CONFIG_DB_DATABASE') ?: 'nnks_db_debug';
|
||||
@@ -91,6 +109,10 @@ function reset_ci_state(): void
|
||||
|
||||
if ($suite === 'all') {
|
||||
foreach (['unit', 'integration', 'api', 'legacy'] as $selectedSuite) {
|
||||
if (in_array($selectedSuite, ['api', 'legacy'], true)) {
|
||||
assert_required_php_extensions(['mysqli']);
|
||||
}
|
||||
|
||||
reset_ci_state();
|
||||
foreach ($commands[$selectedSuite] as $command) {
|
||||
passthru($command, $exitCode);
|
||||
@@ -107,6 +129,10 @@ if ($suite === 'all') {
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (in_array($suite, ['api', 'legacy'], true)) {
|
||||
assert_required_php_extensions(['mysqli']);
|
||||
}
|
||||
|
||||
foreach ($selectedCommands as $command) {
|
||||
passthru($command, $exitCode);
|
||||
if ($exitCode !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user