mirror of
https://github.com/servo/servo.git
synced 2025-06-25 17:44:33 +01:00
Mach clippy & test-tidy github inline annotation (#37294)
When the --report-ci flag is passed to ./mach clippy or ./mach test-tidy, the commands emit CI-friendly output to files in the tempy directory. These files can later be used by [GitHub Workflow Commands](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-error-message) for annotations. If the flag is not provided, the default behavior remains unchanged. Both clippy and test-tidy will limit have 10 limit annotation ⚠️ Note: For ./mach clippy --report-ci to work correctly, the Clippy command must use --message-format=json. If it's not specified, CI output will not be generated, and no warning or error will be shown. Example PR: https://github.com/jerensl/servo/pull/1/files Fixes: #37231 --------- Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This commit is contained in:
parent
18d55f4884
commit
877010c5f6
6 changed files with 175 additions and 29 deletions
|
@ -21,10 +21,10 @@ from typing import Any, Dict, List
|
|||
|
||||
import colorama
|
||||
import toml
|
||||
|
||||
import wpt.manifestupdate
|
||||
|
||||
from .licenseck import OLD_MPL, MPL, APACHE, COPYRIGHT, licenses_toml
|
||||
from .licenseck import APACHE, COPYRIGHT, MPL, OLD_MPL, licenses_toml
|
||||
from .linting_report import GitHubAnnotationManager
|
||||
|
||||
TOPDIR = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
WPT_PATH = os.path.join(".", "tests", "wpt")
|
||||
|
@ -982,7 +982,8 @@ def collect_errors_for_files(files_to_check, checking_functions, line_checking_f
|
|||
yield (filename,) + error
|
||||
|
||||
|
||||
def scan(only_changed_files=False, progress=False):
|
||||
def scan(only_changed_files=False, progress=False, github_annotations=False):
|
||||
github_annotation_manager = GitHubAnnotationManager("test-tidy")
|
||||
# check config file for errors
|
||||
config_errors = check_config_file(CONFIG_FILE_PATH)
|
||||
# check directories contain expected files
|
||||
|
@ -1018,6 +1019,9 @@ def scan(only_changed_files=False, progress=False):
|
|||
+ f"{colorama.Fore.RED}{error[2]}{colorama.Style.RESET_ALL}"
|
||||
)
|
||||
|
||||
if github_annotations:
|
||||
github_annotation_manager.emit_annotation(error[2], error[2], error[0], error[1])
|
||||
|
||||
return int(error is not None)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue