참고 항목
GitHub Code Quality은(는) 현재 공개 미리 보기에 있으며 변경될 수 있습니다. 공개 미리 보기에서 Code Quality은(는) 요금이 청구되지 않지만 Code Quality 스캔은 GitHub Actions 분을 소모합니다.
Introduction
You can block pull requests that don't meet your code quality standards by adding the Require code quality results branch rule to a ruleset and specifying the severity level you require. If a pull request doesn't reach this threshold, it can't be merged.
Prerequisites
- Code Quality is enabled. See Enabling GitHub Code Quality
- Code in a supported language. See Supported languages.
참고 항목
The threshold will have an impact only if the repository has code in one or more of the supported languages, see Enabling GitHub Code Quality.
Confirming Code Quality runs successfully on pull requests
Before you add or update a ruleset to include a threshold for Code Quality, confirm that the 코드 품질 workflow is running and reporting results back to pull requests. Otherwise, the ruleset could block the merging of all pull requests.
- Open a recent pull request and scroll to the "Checks" summary at the bottom of the pull request.
- Confirm that the "CodeQL - 코드 품질" check ran successfully and reported its status.
For more information, see 코드 품질에 대한 CodeQL 기반 분석.
Adding or updating a ruleset to include Code Quality
- Navigate to the "Settings" tab of your repository.
- In the left sidebar, under "Code and automation", expand Rules, then click Rulesets.
- If you don't already have a ruleset to protect your default branch, expand New ruleset and click New branch ruleset. Alternatively, open your existing ruleset for the default branch and move to step 5.
- If you are creating a new ruleset:
- Define a name for the ruleset.
- Set the "Enforcement status" to "Active."
- Under "Target branches" add a target of "Include default branch."
- Under "Branch rules", enable "Require code quality results".
- Set "Severity" to define the lowest severity of code quality results that must be resolved before a pull request can be merged into the default branch. For example:
- Set "Errors" to block pull requests with unresolved code quality errors being merged.
- Set "Warnings and higher" to block pull requests with unresolved code quality warnings or errors being merged.
- Set "Notes and higher" to block pull requests with unresolved code quality notes, warnings or errors being merged.
- Set "All" to block pull requests with any unresolved code quality results being merged.
- When you have finished defining or editing the ruleset, click Create or Save changes.
Next steps
Learn how GitHub Code Quality works on pull requests to prevent code quality issues from reaching your default branch. See Fixing code quality findings before merging your pull request.