66 lines
2.3 KiB
PHP
66 lines
2.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Наборы примеров Preland должны копироваться с Index без переложения:
|
|
* images/demo/<пример>/ и images/demo-N/<пример>/.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
$root = dirname(__DIR__);
|
|
$failures = [];
|
|
|
|
foreach ([
|
|
'images/demo/1/source.avif',
|
|
'images/demo/1/result.avif',
|
|
'images/demo/1/thumb.avif',
|
|
'images/demo/5/source_mob.avif',
|
|
'images/demo-2/1/source.avif',
|
|
'images/demo-2/5/result_mob.avif',
|
|
] as $relativePath) {
|
|
if (!is_file($root . '/' . $relativePath)) {
|
|
$failures[] = "Отсутствует Index-совместимый asset {$relativePath}.";
|
|
}
|
|
}
|
|
|
|
foreach ([
|
|
'images/demo/1/1',
|
|
'images/demo/2/1',
|
|
] as $legacyPath) {
|
|
if (is_dir($root . '/' . $legacyPath)) {
|
|
$failures[] = "Не должна оставаться промежуточная группировка {$legacyPath}.";
|
|
}
|
|
}
|
|
|
|
$template = (string) file_get_contents($root . '/template.php');
|
|
$examples = (string) file_get_contents($root . '/components/examples.php');
|
|
$pathBuilder = "\$demoDirName = 'demo' . (\$indpic === '1' ? '' : '-' . \$indpic);";
|
|
if (!str_contains($template, $pathBuilder)
|
|
|| !str_contains($examples, $pathBuilder)
|
|
|| !str_contains($template, '"/images/{$demoDirName}/1"')
|
|
|| !str_contains($examples, '"/images/{$demoDirName}"')) {
|
|
$failures[] = 'Template и examples должны строить путь из Index-совместимого имени demo/demo-N.';
|
|
}
|
|
|
|
$workflow = (string) file_get_contents($root . '/.gitea/workflows/deploy.yml');
|
|
foreach ([
|
|
'"$PRELAND_URL/images/demo/1/source.avif"',
|
|
'"$PRELAND_URL/images/demo-2/1/source.avif"',
|
|
'"$PRELAND_URL/?indpic=2&nc=$(date +%s)"',
|
|
] as $requiredStageSmokeCheck) {
|
|
if (!str_contains($workflow, $requiredStageSmokeCheck)) {
|
|
$failures[] = "Stage-деплой обязан проверять публикацию {$requiredStageSmokeCheck}.";
|
|
}
|
|
}
|
|
|
|
if (substr_count($workflow, 'while [ -n "$dir" ]; do') < 2) {
|
|
$failures[] = 'SFTP-деплой должен создавать все родительские каталоги для новых наборов assets.';
|
|
}
|
|
|
|
if ($failures !== []) {
|
|
fwrite(STDERR, "FAILED\n- " . implode("\n- ", $failures) . "\n");
|
|
exit(1);
|
|
}
|
|
|
|
fwrite(STDOUT, "OK: Preland demo layout matches Index\n");
|