From 8481283ec868a917eed1c27ffaf0d53d2d3c8111 Mon Sep 17 00:00:00 2001 From: Guilherme Branco Stracini Date: Tue, 8 Oct 2024 21:37:58 +0100 Subject: [PATCH] Enhance PR Description Validation Logic (#605) * Update pullRequests.php * style: format code with PHP CS Fixer This commit fixes the style issues introduced in 455d8f9 according to the output from PHP CS Fixer. Details: https://github.com/guibranco/gstraccini-bot/pull/605 * Update github.php --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- Src/lib/github.php | 4 ++-- Src/pullRequests.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Src/lib/github.php b/Src/lib/github.php index 322b229..e77d3f9 100644 --- a/Src/lib/github.php +++ b/Src/lib/github.php @@ -265,7 +265,7 @@ function setCheckRunFailed(array $metadata, int $checkRunId, string $type, strin * of check that was completed. It is used to customize the check run details and message based on the * specific type of check being performed. */ -function setCheckRunSucceeded(array $metadata, int $checkRunId, string $type): void +function setCheckRunSucceeded(array $metadata, int $checkRunId, string $type, string $details = null): void { $checkRunBody = array( "name" => "GStraccini Checks: " . ucwords($type), @@ -275,7 +275,7 @@ function setCheckRunSucceeded(array $metadata, int $checkRunId, string $type): v "output" => array( "title" => "Checks completed ✅", "summary" => "GStraccini checked this " . strtolower($type) . " successfully!", - "text" => "No issues found." + "text" => $details ?? "No issues found." ) ); diff --git a/Src/pullRequests.php b/Src/pullRequests.php index d623c24..b64beb0 100644 --- a/Src/pullRequests.php +++ b/Src/pullRequests.php @@ -163,6 +163,8 @@ function checkPullRequestDescription($metadata, $pullRequestUpdated) $message = $validator->generateReport($validationResult); setCheckRunFailed($metadata, $checkRunId, $type, $message); return; + } elseif ($validationResult["found"] === false || $validationResult["found"] === 0) { + setCheckRunSucceeded($metadata, $checkRunId, $type, "No groups or checkboxes found in the PR body."); } setCheckRunSucceeded($metadata, $checkRunId, $type);