Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/issue-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "::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

exit $exit_code

- name: "Evaluate results - push"
working-directory: "issue-bot"
Expand All @@ -169,4 +179,14 @@ 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
exit_code="$?"

# its fine when issue-bot found affected issues
if [[ "$exit_code" == "2" ]]; then
exit 0
fi

exit $exit_code
10 changes: 8 additions & 2 deletions issue-bot/src/Console/EvaluateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
class EvaluateCommand extends Command
{

private const EXIT_ERROR = 1;
private const EXIT_AFFECTS_ISSUES = 2;
private const EXIT_NO_AFFECTED_ISSUES = 0;

public function __construct(
private TabCreator $tabCreator,
private PostGenerator $postGenerator,
Expand Down Expand Up @@ -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())));
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -191,7 +197,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

return 0;
return $exitCode;
}

/**
Expand Down
Loading