From 8059775857a3b179d70df4d53b484905913b7dbc Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:03:17 +0200 Subject: [PATCH 01/10] Issue-Bot: Emit GitHub Action annotation when issues are affected --- .github/workflows/issue-bot.yml | 23 +++++++++++++++++++++-- issue-bot/src/Console/EvaluateCommand.php | 10 ++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 2366222087..393f55a3c5 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -160,7 +160,17 @@ jobs: if: github.event_name == 'pull_request' env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - run: ./console.php evaluate >> $GITHUB_STEP_SUMMARY + run: | + set +e + ./console.php evaluate >> $GITHUB_STEP_SUMMARY + exit_code="$?" + + if [[ "$exit_code" == "2" ]]; then + echo "##[info]Issue bot detected open issues which are affected by this pull request - see Issue bot job summary." + exit 0 + fi + + exit $exit_code - name: "Evaluate results - push" working-directory: "issue-bot" @@ -169,4 +179,13 @@ jobs: GITHUB_PAT: ${{ secrets.PHPSTAN_BOT_TOKEN }} PHPSTAN_SRC_COMMIT_BEFORE: ${{ github.event.before }} PHPSTAN_SRC_COMMIT_AFTER: ${{ github.event.after }} - run: ./console.php evaluate --post-comments >> $GITHUB_STEP_SUMMARY + run: | + set +e + ./console.php evaluate --post-comments >> $GITHUB_STEP_SUMMARY + + # its fine when issue-bot found affected issues + if [[ "$exit_code" == "2" ]]; then + exit 0 + fi + + exit $exit_code diff --git a/issue-bot/src/Console/EvaluateCommand.php b/issue-bot/src/Console/EvaluateCommand.php index 9836d85bb0..e3a3b10066 100644 --- a/issue-bot/src/Console/EvaluateCommand.php +++ b/issue-bot/src/Console/EvaluateCommand.php @@ -33,6 +33,10 @@ class EvaluateCommand extends Command { + const EXIT_ERROR = 1; + const EXIT_AFFECTS_ISSUES = 2; + const EXIT_NO_AFFECTED_ISSUES = 0; + public function __construct( private TabCreator $tabCreator, private PostGenerator $postGenerator, @@ -133,7 +137,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } + $exitCode = self::EXIT_AFFECTS_ISSUES; if (count($toPost) === 0) { + $exitCode = self::EXIT_NO_AFFECTED_ISSUES; $output->writeln(sprintf('No changes in results in %d code snippets from %d GitHub issues. :tada:', $totalCodeSnippets, count($issueCache->getIssues()))); } @@ -163,7 +169,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($postComments) { if (count($toPost) > 20) { $output->writeln('Too many comments to post, something is probably wrong.'); - return 1; + return self::EXIT_ERROR; } foreach ($toPost as ['issue' => $issue, 'hash' => $hash, 'users' => $users, 'diff' => $diff, 'details' => $details]) { $text = sprintf( @@ -191,7 +197,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - return 0; + return $exitCode; } /** From feb5c69c855702178f6cb48c64128d96b716f73f Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:09:04 +0200 Subject: [PATCH 02/10] Update EvaluateCommand.php --- issue-bot/src/Console/EvaluateCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/issue-bot/src/Console/EvaluateCommand.php b/issue-bot/src/Console/EvaluateCommand.php index e3a3b10066..c735591014 100644 --- a/issue-bot/src/Console/EvaluateCommand.php +++ b/issue-bot/src/Console/EvaluateCommand.php @@ -142,6 +142,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $exitCode = self::EXIT_NO_AFFECTED_ISSUES; $output->writeln(sprintf('No changes in results in %d code snippets from %d GitHub issues. :tada:', $totalCodeSnippets, count($issueCache->getIssues()))); } + // XXX debug test + $exitCode = self::EXIT_AFFECTS_ISSUES; foreach ($toPost as ['issue' => $issue, 'hash' => $hash, 'users' => $users, 'diff' => $diff, 'details' => $details]) { $text = sprintf( From 4288b6199694c36fc3d35a25cb17df91e2673ba9 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:27:48 +0200 Subject: [PATCH 03/10] Update issue-bot.yml --- .github/workflows/issue-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 393f55a3c5..1974a6633b 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -166,7 +166,7 @@ jobs: exit_code="$?" if [[ "$exit_code" == "2" ]]; then - echo "##[info]Issue bot detected open issues which are affected by this pull request - see Issue bot job summary." + echo "::notice::Issue bot detected open issues which are affected by this pull request - see Issue bot job summary." exit 0 fi From 46dda409c35883cae7a0fdaee3963f59b21b8d3b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:34:20 +0200 Subject: [PATCH 04/10] Update issue-bot.yml --- .github/workflows/issue-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 1974a6633b..c120a21e1a 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -166,7 +166,7 @@ jobs: exit_code="$?" if [[ "$exit_code" == "2" ]]; then - echo "::notice::Issue bot detected open issues which are affected by this pull request - see Issue bot job summary." + echo "::notice file=.github/workflows/issue-bot.yml ::Issue bot detected open issues which are affected by this pull request - see [Issue bot job summary(https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)]." exit 0 fi From a52a7ee26de719b78bca5e5a9c97f2659a6eb5cd Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:40:52 +0200 Subject: [PATCH 05/10] Update issue-bot.yml --- .github/workflows/issue-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index c120a21e1a..78e2c25db7 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -166,7 +166,7 @@ jobs: exit_code="$?" if [[ "$exit_code" == "2" ]]; then - echo "::notice file=.github/workflows/issue-bot.yml ::Issue bot detected open issues which are affected by this pull request - see [Issue bot job summary(https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)]." + echo "::notice file=.github/workflows/issue-bot.yml,line=1 ::Issue bot detected open issues which are affected by this pull request - see [Issue bot job summary](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." exit 0 fi From c330e59dc084b438d64808a00d02f917a55edb63 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:46:18 +0200 Subject: [PATCH 06/10] Update issue-bot.yml --- .github/workflows/issue-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 78e2c25db7..1189f12a02 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -166,7 +166,7 @@ jobs: exit_code="$?" if [[ "$exit_code" == "2" ]]; then - echo "::notice file=.github/workflows/issue-bot.yml,line=1 ::Issue bot detected open issues which are affected by this pull request - see [Issue bot job summary](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." + echo "::notice file=.github/workflows/issue-bot.yml,line=1 ::Issue bot detected open issues which are affected by this pull request - see https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" exit 0 fi From 64f306bbd7b742dac949b9772e489e2ef1bf895d Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:50:41 +0200 Subject: [PATCH 07/10] try without path --- .github/workflows/issue-bot.yml | 2 +- issue-bot/src/Console/EvaluateCommand.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 1189f12a02..e03055f3ff 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -166,7 +166,7 @@ jobs: exit_code="$?" if [[ "$exit_code" == "2" ]]; then - echo "::notice file=.github/workflows/issue-bot.yml,line=1 ::Issue bot detected open issues which are affected by this pull request - see https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + echo "::notice ::Issue bot detected open issues which are affected by this pull request - see https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" exit 0 fi diff --git a/issue-bot/src/Console/EvaluateCommand.php b/issue-bot/src/Console/EvaluateCommand.php index c735591014..1ae56f9e26 100644 --- a/issue-bot/src/Console/EvaluateCommand.php +++ b/issue-bot/src/Console/EvaluateCommand.php @@ -33,9 +33,9 @@ class EvaluateCommand extends Command { - const EXIT_ERROR = 1; - const EXIT_AFFECTS_ISSUES = 2; - const EXIT_NO_AFFECTED_ISSUES = 0; + private const EXIT_ERROR = 1; + private const EXIT_AFFECTS_ISSUES = 2; + private const EXIT_NO_AFFECTED_ISSUES = 0; public function __construct( private TabCreator $tabCreator, From 1bce8e751291accf252e5aa224d02fe60c5c43c6 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 15:56:30 +0200 Subject: [PATCH 08/10] Update issue-bot.yml --- .github/workflows/issue-bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index e03055f3ff..2507c0cefc 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -166,7 +166,7 @@ jobs: exit_code="$?" if [[ "$exit_code" == "2" ]]; then - echo "::notice ::Issue bot detected open issues which are affected by this pull request - see https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + echo "::notice file=.github/workflows/issue-bot.yml,line=3 ::Issue bot detected open issues which are affected by this pull request - see https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" exit 0 fi From 714c461318b6a34fd357757a956cf4e37d584c72 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 16:18:25 +0200 Subject: [PATCH 09/10] remove debug code --- issue-bot/src/Console/EvaluateCommand.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/issue-bot/src/Console/EvaluateCommand.php b/issue-bot/src/Console/EvaluateCommand.php index 1ae56f9e26..cc417f6b34 100644 --- a/issue-bot/src/Console/EvaluateCommand.php +++ b/issue-bot/src/Console/EvaluateCommand.php @@ -142,8 +142,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $exitCode = self::EXIT_NO_AFFECTED_ISSUES; $output->writeln(sprintf('No changes in results in %d code snippets from %d GitHub issues. :tada:', $totalCodeSnippets, count($issueCache->getIssues()))); } - // XXX debug test - $exitCode = self::EXIT_AFFECTS_ISSUES; foreach ($toPost as ['issue' => $issue, 'hash' => $hash, 'users' => $users, 'diff' => $diff, 'details' => $details]) { $text = sprintf( From 3d1e787cfe5346c8c3e39409cfde12c1a62f28be Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 12 Sep 2025 16:20:00 +0200 Subject: [PATCH 10/10] Update issue-bot.yml --- .github/workflows/issue-bot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 2507c0cefc..c62816c8b6 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -182,6 +182,7 @@ jobs: run: | set +e ./console.php evaluate --post-comments >> $GITHUB_STEP_SUMMARY + exit_code="$?" # its fine when issue-bot found affected issues if [[ "$exit_code" == "2" ]]; then