Which solution will meet these requirements?
Create a CodeBuild project to run the unit and integration tests. Create a CodeCommit approval rule template. Configure the template to require the successful invocation of the CodeBuild project. Attach the approval rule to the project’s CodeCommit repository.
Create an Amazon EventBridge rule to match pullRequestCreated events from CodeCommit Create a CodeBuild project to run the unit and integration tests. Configure the CodeBuild project as a target of the EventBridge rule that includes a custom event payload with the CodeCommit repository and branch information from the event.
Create an Amazon EventBridge rule to match pullRequestCreated events from CodeCommit. Modify the existing CodePipeline pipeline to not run the deploy steps if the build is started from a pull request. Configure the EventBridge rule to run the pipeline with a custom payload that contains the CodeCommit repository and branch information from the event.
Create a CodeBuild project to run the unit and integration tests. Create a CodeCommit notification rule that matches when a pull request is created or updated. Configure the notification rule to invoke the CodeBuild project.
Explanations:
While this option proposes a CodeBuild project to run tests, using a CodeCommit approval rule template to require the successful invocation of the project does not directly address the need to run tests on each pull request prior to merging. Approval rules focus on code review rather than executing builds and tests.
This option effectively sets up an EventBridge rule to trigger a CodeBuild project whenever a pull request is created, ensuring that unit and integration tests are run before merging. This addresses the requirement to run tests on each pull request, helping to prevent pipeline blockage due to failing tests.
This option modifies the existing pipeline to avoid deployment steps when triggered by pull requests, but it does not run unit and integration tests before merging. It fails to satisfy the requirement of testing before a pull request is merged, as it only alters the deployment behavior.
Although this option suggests using a notification rule to invoke a CodeBuild project when a pull request is created or updated, it does not ensure that the tests are run before merging the pull request. It may trigger builds, but the notification mechanism does not guarantee that the results must be successful before merging.