What should the DevOps engineer do to meet this requirement?
Create an Amazon EventBridge rule that reacts to the pullRequestStatusChanged event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild badge as a comment on the pull request so that developers will see the badge in their code review.
Create an Amazon EventBridge rule that reacts to the pullRequestCreated event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when the test results are complete.
Create an Amazon EventBridge rule that reacts to pullRequestCreated and pullRequestSourceBranchUpdated events. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild badge as a comment on the pull request so that developers will see the badge in their code review.
Create an Amazon EventBridge rule that reacts to the pullRequestStatusChanged event. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action that runs the tests for the application. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when the test results are complete.
Explanations:
This option triggers on thepullRequestStatusChangedevent, which occurs after a pull request has been reviewed or merged. Testing should ideally occur when a pull request is created or updated, not after its status changes. Additionally, posting only a badge does not provide detailed insights into the test results.
This option reacts to thepullRequestCreatedevent, which is useful for initiating tests on new pull requests. However, it does not account for updates to existing pull requests. Posting only the test results as a comment is informative but does not include subsequent updates or merges that may happen during the review process.
This option reacts to bothpullRequestCreatedandpullRequestSourceBranchUpdatedevents, ensuring that tests are run both when a pull request is created and whenever its source branch is updated. It also posts the CodeBuild badge, which gives an at-a-glance status, enhancing visibility during code reviews.
This option triggers on thepullRequestStatusChangedevent, which does not ensure testing happens before a pull request is reviewed. While it does provide test results as a comment, this occurs after the status changes, which is not proactive in ensuring test coverage before merging.