Question 1 · choose 1
Developers open pull requests against the main branch of a GitHub repository. Unit tests and static analysis must run when a pull request is opened and again whenever new commits are pushed to it, so that reviewers see results before they merge. An existing AWS CodePipeline pipeline already deploys every push to main. The team wants the least custom code. What should the DevOps engineer do?
- AAdd a test stage with a CodeBuild action to the existing pipeline, directly after its source stage
- BCreate a CodeBuild project with a GitHub webhook whose filter group matches the PULL_REQUEST_CREATED and PULL_REQUEST_UPDATED events
- CCreate a CodeBuild project with a GitHub webhook whose filter group matches the PUSH event with a head reference of main
- DRun the CodeBuild project every 15 minutes with EventBridge Scheduler and have the build find and test the newest open pull request
Show the answer and why
AAdd a test stage with a CodeBuild action to the existing pipeline, directly after its source stage
Incorrect
The existing pipeline starts on pushes to main, so the tests would run only after a change is merged, too late for the reviewers.
BCreate a CodeBuild project with a GitHub webhook whose filter group matches the PULL_REQUEST_CREATED and PULL_REQUEST_UPDATED events
Correct
Webhook filter groups decide which GitHub events start a build, and these two events cover a new pull request and new commits pushed to it.
CCreate a CodeBuild project with a GitHub webhook whose filter group matches the PUSH event with a head reference of main
Incorrect
A push to main happens when the pull request is merged, so this also tests the code only after the merge.
DRun the CodeBuild project every 15 minutes with EventBridge Scheduler and have the build find and test the newest open pull request
Incorrect
A schedule misses pull requests and commits between runs and needs code to find them. Webhook events start a build for each one.
Tests that gate a merge have to run on pull request events. A CodeBuild webhook with a filter group for pull request creation and updates starts a build for each new pull request and for every new commit on it.
AWS documentation