From 725a7d9adcc29e19bdc4d403c296627214d24e11 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 16 Sep 2020 01:14:13 +0000 Subject: [PATCH] Bug 1651991 [wpt PR 24556] - [Taskcluster] Make lint create a GitHub Checks output file, a=testonly Automatic update from web-platform-tests [Taskcluster] Make lint create a GitHub Checks output file (#24556) See https://github.com/web-platform-tests/wpt/issues/15412 -- wpt-commits: 8420fdfa2c9124b1f7b1eaf64517c5b3fc3f072b wpt-pr: 24556 UltraBlame original commit: a6e4b389013941a0c67a2ed4b32796bfa59bcb23 --- .../tests/tools/ci/tc/github_checks_output.py | 164 ++++++-- .../tests/tools/ci/tc/tasks/test.yml | 20 + testing/web-platform/tests/tools/lint/lint.py | 398 +++++++++++++++++- .../tests/tools/lint/tests/test_lint.py | 4 + .../tools/wptrunner/wptrunner/stability.py | 5 + .../wptrunner/wptrunner/wptcommandline.py | 7 +- 6 files changed, 547 insertions(+), 51 deletions(-) diff --git a/testing/web-platform/tests/tools/ci/tc/github_checks_output.py b/testing/web-platform/tests/tools/ci/tc/github_checks_output.py index 172a20a322e4b..b9d8fbd4fef29 100644 --- a/testing/web-platform/tests/tools/ci/tc/github_checks_output.py +++ b/testing/web-platform/tests/tools/ci/tc/github_checks_output.py @@ -1,3 +1,36 @@ +MYPY += +False +if +MYPY +: + +# +MYPY +is +set +to +True +when +run +under +Mypy +. + +from +typing +import +Any + +from +typing +import +Optional + +from +typing +import +Text class GitHubChecksOutputter ( @@ -107,6 +140,16 @@ ) : +# +type +: +( +Text +) +- +> +None + self . path @@ -121,6 +164,68 @@ ) : +# +type +: +( +Any +) +- +> +None + +# +TODO +( +stephenmcgruer +) +: +Once +mypy +0 +. +790 +is +released +we +can +change +this + +# +to +AnyStr +as +that +release +teaches +mypy +about +the +mode +flags +of +open +. + +# +See +https +: +/ +/ +github +. +com +/ +python +/ +typeshed +/ +pull +/ +4146 + with open ( @@ -157,10 +262,26 @@ def get_gh_checks_outputter ( -kwargs +filepath ) : +# +type +: +( +Optional +[ +Text +] +) +- +> +Optional +[ +GitHubChecksOutputter +] + " " " @@ -177,23 +298,24 @@ : param -kwargs +filepath : The -arguments -passed +filepath to -the -program -( +write +GitHub +Check +output +information to -look -for -the - -github_checks_text_file -field -) + +or +None +if +not +enabled +. " " @@ -203,12 +325,7 @@ __outputter if -kwargs -[ -' -github_checks_text_file -' -] +filepath and __outputter is @@ -219,12 +336,7 @@ = GitHubChecksOutputter ( -kwargs -[ -' -github_checks_text_file -' -] +filepath ) return diff --git a/testing/web-platform/tests/tools/ci/tc/tasks/test.yml b/testing/web-platform/tests/tools/ci/tc/tasks/test.yml index ab4911aa943aa..12263fba1d8e4 100644 --- a/testing/web-platform/tests/tools/ci/tc/tasks/test.yml +++ b/testing/web-platform/tests/tools/ci/tc/tasks/test.yml @@ -1801,6 +1801,26 @@ lint - - all +- +- +github +- +checks +- +text +- +file += +/ +home +/ +test +/ +artifacts +/ +checkrun +. +md " - update diff --git a/testing/web-platform/tests/tools/lint/lint.py b/testing/web-platform/tests/tools/lint/lint.py index cf1de7a55baeb..cd433f34bde22 100644 --- a/testing/web-platform/tests/tools/lint/lint.py +++ b/testing/web-platform/tests/tools/lint/lint.py @@ -45,6 +45,17 @@ from . . +ci +. +tc +. +github_checks_output +import +get_gh_checks_outputter +GitHubChecksOutputter +from +. +. gitignore . gitignore @@ -126,6 +137,11 @@ import Any +from +typing +import +Callable + from typing import @@ -6631,6 +6647,7 @@ def output_errors_text ( +log errors ) : @@ -6639,6 +6656,13 @@ type : ( +Callable +[ +[ +Any +] +None +] List [ rules @@ -6650,12 +6674,6 @@ > None -assert -logger -is -not -None - for error_type description @@ -6684,9 +6702,7 @@ % line_number -logger -. -error +log ( " % @@ -6709,6 +6725,7 @@ def output_errors_markdown ( +log errors ) : @@ -6717,6 +6734,13 @@ type : ( +Callable +[ +[ +Any +] +None +] List [ rules @@ -6735,12 +6759,6 @@ return -assert -logger -is -not -None - heading = " @@ -6811,9 +6829,7 @@ ) : -logger -. -error +log ( line ) @@ -6846,9 +6862,7 @@ % line_number -logger -. -error +log ( " % @@ -6871,6 +6885,7 @@ def output_errors_json ( +log errors ) : @@ -6879,6 +6894,13 @@ type : ( +Callable +[ +[ +Any +] +None +] List [ rules @@ -6899,6 +6921,39 @@ errors : +# +We +use +' +print +' +rather +than +the +log +function +to +ensure +that +the +output + +# +is +valid +JSON +( +e +. +g +. +with +no +logger +preamble +) +. + print ( json @@ -6931,6 +6986,209 @@ ) ) def +output_errors_github_checks +( +outputter +errors +first_reported +) +: + +# +type +: +( +GitHubChecksOutputter +List +[ +rules +. +Error +] +bool +) +- +> +None + +" +" +" +Output +errors +to +the +GitHub +Checks +output +markdown +format +. + +: +param +outputter +: +the +GitHub +Checks +outputter + +: +param +errors +: +a +list +of +error +tuples +( +error +type +message +path +line +number +) + +: +param +first_reported +: +True +if +these +are +the +first +reported +errors + +" +" +" + +if +first_reported +: + +outputter +. +output +( + +" +\ +nChanges +in +this +PR +contain +lint +errors +listed +below +. +These +" + +" +errors +must +either +be +fixed +or +added +to +the +list +of +ignored +" + +" +errors +; +see +[ +the +documentation +] +( +" + +" +https +: +/ +/ +web +- +platform +- +tests +. +org +/ +writing +- +tests +/ +lint +- +tool +. +html +) +. +" + +" +For +help +please +tag +web +- +platform +- +tests +/ +wpt +- +core +- +team +in +a +" + +" +comment +. +\ +n +" +) + +outputter +. +output +( +" +" +) + +output_errors_text +( +outputter +. +output +errors +) +def output_error_count ( error_count @@ -7589,6 +7847,40 @@ " ) +parser +. +add_argument +( +" +- +- +github +- +checks +- +text +- +file +" +type += +ensure_text + +help += +" +Path +to +GitHub +checks +output +file +for +Taskcluster +runs +" +) + return parser def @@ -7785,6 +8077,18 @@ ] ) +github_checks_outputter += +get_gh_checks_outputter +( +kwargs +[ +" +github_checks_text_file +" +] +) + return lint ( @@ -7792,6 +8096,7 @@ paths output_format ignore_glob +github_checks_outputter ) def lint @@ -7802,6 +8107,9 @@ ignore_glob = None +github_checks_outputter += +None ) : @@ -7822,6 +8130,10 @@ Text ] ] +Optional +[ +GitHubChecksOutputter +] ) - > @@ -8022,9 +8334,39 @@ return None +assert +logger +is +not +None + output_errors ( +logger +. +error +errors +) + +if +github_checks_outputter +: + +first_output += +len +( +error_count +) += += +0 + +output_errors_github_checks +( +github_checks_outputter errors +first_output ) for @@ -8279,6 +8621,20 @@ line ) +if +error_count +and +github_checks_outputter +: + +github_checks_outputter +. +output +( +" +" +) + return sum ( diff --git a/testing/web-platform/tests/tools/lint/tests/test_lint.py b/testing/web-platform/tests/tools/lint/tests/test_lint.py index 7be5f660fdbdf..af2480b1e9d5d 100644 --- a/testing/web-platform/tests/tools/lint/tests/test_lint.py +++ b/testing/web-platform/tests/tools/lint/tests/test_lint.py @@ -4843,6 +4843,8 @@ normal " +None + None ) @@ -4949,6 +4951,7 @@ normal " None +None ) finally @@ -5059,6 +5062,7 @@ normal " None +None ) finally diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py index 33450cd71491c..c1bb5591ffc66 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/stability.py @@ -2913,6 +2913,11 @@ get_gh_checks_outputter ( kwargs +[ +" +github_checks_text_file +" +] ) for diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptcommandline.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptcommandline.py index 0161164c41e97..3718253fc3ead 100644 --- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wptcommandline.py +++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wptcommandline.py @@ -26,6 +26,7 @@ from six import +ensure_text iterkeys itervalues iteritems @@ -4571,11 +4572,9 @@ file " -dest +type = -" -github_checks_text_file -" +ensure_text help =