This commit is contained in:
nuno maduro
2026-05-01 20:42:14 +01:00
parent a725e774c0
commit a349f53964
7 changed files with 60 additions and 93 deletions

View File

@ -67,7 +67,7 @@ final readonly class BaselineSync
if (! $force && ($remaining = $this->cooldownRemaining()) !== null) {
$this->renderBadge('WARN', sprintf(
'TIA last fetch found no baseline — next auto-retry in %s. Override with --refetch.',
'Last fetch found no baseline — next auto-retry in %s. Override with --refetch.',
$this->formatDuration($remaining),
));
@ -102,7 +102,7 @@ final readonly class BaselineSync
$this->clearCooldown();
$this->renderBadge('SUCCESS', sprintf(
'TIA baseline ready (%s).',
'Baseline ready (%s).',
$this->formatSize(strlen($payload['graph']) + strlen($payload['coverage'] ?? '')),
));
@ -156,7 +156,7 @@ final readonly class BaselineSync
private function emitPublishInstructions(string $repo): void
{
if ($this->isCi()) {
$this->renderBadge('INFO', 'TIA no baseline yet — this run will produce one.');
$this->renderBadge('INFO', 'No baseline yet — this run will produce one.');
return;
}
@ -165,7 +165,7 @@ final readonly class BaselineSync
? $this->laravelWorkflowYaml()
: $this->genericWorkflowYaml();
$this->renderBadge('WARN', 'TIA no baseline published yet — recording locally.');
$this->renderBadge('WARN', 'No baseline published yet — recording locally.');
$this->renderDetail('To share the baseline with your team, add this workflow to the repo:');
$this->renderDetail('.github/workflows/tia-baseline.yml');
@ -339,7 +339,7 @@ YAML;
// Tier 2 — transient (network, rate-limit, unknown). Surface
// the diagnostic but let the suite fall through to record mode.
$this->renderBadge('WARN', sprintf(
'TIA failed to query baseline runs — %s',
'Failed to query baseline runs — %s',
$listError['message'],
));
@ -364,7 +364,7 @@ YAML;
@touch($runCacheDir);
$this->renderBadge('INFO', sprintf(
'TIA using cached baseline from %s (run %s).',
'Using cached baseline from %s (run %s).',
$repo,
$runId,
));
@ -380,12 +380,12 @@ YAML;
$this->renderBadge('INFO', $artifactSize !== null
? sprintf(
'TIA fetching baseline (%s) from %s…',
'Fetching baseline (%s) from %s…',
$this->formatSize($artifactSize),
$repo,
)
: sprintf(
'TIA fetching baseline from %s…',
'Fetching baseline from %s…',
$repo,
));
@ -424,7 +424,7 @@ YAML;
// Tier 2 — transient. Diagnostic + fall through to record mode.
$this->renderBadge('WARN', sprintf(
'TIA baseline download failed — %s',
'Baseline download failed — %s',
$diagnosis['message'],
));
@ -491,7 +491,7 @@ YAML;
// "100%" message naturally.
$percent = min(99, (int) floor(($current / $totalBytes) * 100));
$message = sprintf(
' <fg=cyan>TIA</> downloading %s / %s (%d%%, %s/s)',
' <fg=cyan>Downloading</> %s / %s (%d%%, %s/s)',
$this->formatSize($current),
$this->formatSize($totalBytes),
$percent,
@ -499,7 +499,7 @@ YAML;
);
} else {
$message = sprintf(
' <fg=cyan>TIA</> downloading %s (%s/s)',
' <fg=cyan>Downloading</> %s (%s/s)',
$this->formatSize($current),
$this->formatSize($speed),
);
@ -723,8 +723,7 @@ YAML;
// Unknown — surface the first informative line so the user has
// *something* to act on.
$first = strtok($output, "\n");
$message = is_string($first) ? trim($first) : 'unknown error';
$message = trim(strtok($output, "\n"));
return ['kind' => 'unknown', 'message' => $message];
}

View File

@ -234,7 +234,7 @@ final class Graph
View::render('components.badge', [
'type' => 'WARN',
'content' => sprintf(
'TIA Vite resolver unavailable — falling back to watch pattern for %d new JS file(s).',
'Vite resolver unavailable — falling back to watch pattern for %d new JS file(s).',
count($newJsFiles),
),
]);
@ -469,7 +469,8 @@ final class Graph
public function setResult(string $branch, string $testId, int $status, string $message, float $time, int $assertions = 0, ?string $file = null): void
{
$this->ensureBaseline($branch);
$this->baselines[$branch]['results'][$testId] = [
$entry = [
'status' => $status,
'message' => $message,
'time' => $time,
@ -480,9 +481,11 @@ final class Graph
$rel = $this->relative($file);
if ($rel !== null) {
$this->baselines[$branch]['results'][$testId]['file'] = $rel;
$entry['file'] = $rel;
}
}
$this->baselines[$branch]['results'][$testId] = $entry;
}
public function getAssertions(string $branch, string $testId, string $fallbackBranch = 'main'): ?int
@ -532,17 +535,12 @@ final class Graph
$files = [];
foreach ($baseline['results'] as $result) {
$status = $result['status'] ?? null;
if ($status !== 7 && $status !== 8) {
if ($result['status'] !== 7 && $result['status'] !== 8) {
continue;
}
$file = $result['file'] ?? null;
if (! is_string($file)) {
continue;
}
if ($file === '') {
if ($file === null || $file === '') {
continue;
}
@ -561,15 +559,13 @@ final class Graph
$baseline = $this->baselineFor($branch, $fallbackBranch);
foreach ($baseline['results'] as $result) {
$status = $result['status'] ?? null;
if ($status !== 7 && $status !== 8) {
if ($result['status'] !== 7 && $result['status'] !== 8) {
continue;
}
$file = $result['file'] ?? null;
if (! is_string($file) || $file === '' || $this->relative($file) === null) {
if ($file === null || $file === '' || $this->relative($file) === null) {
return true;
}
}

View File

@ -473,7 +473,7 @@ final class Recorder
}
$parts = preg_split('/\s+as\s+/i', $import);
if ($parts === false || $parts === []) {
if ($parts === false) {
return null;
}
@ -488,9 +488,6 @@ final class Recorder
if (! is_array($loader)) {
continue;
}
if (! isset($loader[0])) {
continue;
}
if (! is_object($loader[0])) {
continue;
}
@ -689,9 +686,6 @@ final class Recorder
$out = [];
foreach ($data as $file => $lines) {
if (! is_string($file)) {
continue;
}
if (! is_array($lines)) {
continue;
}
@ -709,7 +703,8 @@ final class Recorder
// Skip files where the only "executed" line is the implicit
// ZEND_RETURN at end-of-file (pcov artifact from being included
// but never actually run).
if (count($covered) === 1 && max($covered) === max(array_keys($lines))) {
$lineKeys = array_keys($lines);
if ($lineKeys !== [] && count($covered) === 1 && $covered[0] === max($lineKeys)) {
continue;
}

View File

@ -77,7 +77,7 @@ final readonly class SourceScope
$includes = [self::normalise($projectRoot)];
}
return new self($projectRoot, $includes, $excludes);
return new self($includes, $excludes);
}
/**
@ -152,13 +152,7 @@ final readonly class SourceScope
continue;
}
$absolute = self::resolveRelative($value, $configDir);
if ($absolute === null) {
continue;
}
$out[] = $absolute;
$out[] = self::resolveRelative($value, $configDir);
}
return array_values(array_unique($out));