AZ-400 Question 6
Select 2Your development team has recently adopted GitHub Flow for a new web application. Each developer creates feature branches from the main branch, and then opens a pull request to merge their changes back into main. However, the team has experienced issues with incomplete code accidentally merging into the main branch and wants to test changes in an ephemeral environment before merging. Which two actions should you recommend to improve the team� workflow according to GitHub Flow best practices?
- A
Build a short-lived test environment for every pull request before merging
- B
Merge incomplete code into the main branch and revert it later if issues are found
- C
Enable branch protection rules requiring code reviews before merging
- D
Push directly to the main branch whenever local tests pass
Show answer and explanation
Correct answers: A, C
Explanation
GitHub Flow emphasizes keeping the main branch stable and deployable by using feature branches, pull requests, and peer reviews. By requiring at least one reviewer and building short-lived test environments for each pull request, the team can validate changes thoroughly and maintain high code quality. Refer to GitHub� official documentation on 'Branch Protection Rules' and 'Pull Requests' for more details on these best practices.
- A. Correct.
Correct. Creating ephemeral (short-lived) test environments for pull requests aligns with GitHub Flow best practices. It allows all stakeholders to test changes in isolation before merging.
- B. Incorrect.
Incorrect. Merging incomplete code and reverting later can introduce delays and confusion. GitHub Flow encourages keeping the main branch in a deployable state at all times.
- C. Correct.
Correct. Requiring code reviews aligns with GitHub Flow and helps catch issues before merging into the main branch. Branch protection rules enforce process consistency.
- D. Incorrect.
Incorrect. Pushing directly to main bypasses essential steps like code review and automated testing, increasing the risk of merging incomplete or broken code.