Google Professional Cloud Developer Question 241
Select 2Google Cloud PlatformYou are developing a cloud-native application and managing your source code using Cloud Source Repositories. Your team requires a workflow where changes are reviewed before merging into the main branch. Additionally, the team wants to enforce automated tests and linting before approving a merge. How can you achieve this using Google Cloud's capabilities?
- A
Enable branch protection rules in Cloud Source Repositories and configure required reviews before merging.
- B
Integrate Cloud Build with Cloud Source Repositories to run automated tests and linting during pull requests.
- C
Use Artifact Registry to store and enforce dependencies for the application before merging changes.
- D
Set up a pre-merge hook in Cloud Source Repositories to automatically approve changes without review.
- E
Enable detailed commit logs in Cloud Source Repositories to track all changes before merging.
Show answer and explanation
Correct answers: A, B
Explanation
To meet the requirements, you need to enforce code reviews and automated testing/linting before merging changes. Enabling branch protection rules in Cloud Source Repositories ensures that code reviews are mandatory, and integrating Cloud Build allows for automated CI/CD workflows such as running tests and linting. These features together address the team's needs for a robust development workflow.
- A. Correct.
This is correct. Cloud Source Repositories supports branch protection rules, which allow you to enforce policies such as requiring code reviews before merging changes.
- B. Correct.
This is correct. Cloud Build can be integrated with Cloud Source Repositories to automatically run tests and linting as part of a CI/CD pipeline during pull requests.
- C. Incorrect.
This is incorrect. While Artifact Registry is useful for managing dependencies, it does not directly enforce review or testing workflows in source control management.
- D. Incorrect.
This is incorrect. Pre-merge hooks that automatically approve changes without review violate the requirement for changes to be reviewed before merging.
- E. Incorrect.
This is incorrect. While detailed commit logs are helpful for tracking changes, they do not enforce reviews or automated workflows like testing and linting.