From 4986763e1eba69dc4249815e1c1b51ec1cf7abd0 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 29 May 2022 20:22:34 -0400 Subject: [PATCH 1/7] Fail "new primer" runs on fatal errors, like "old primer" --- tests/primer/primer_tool.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/primer/primer_tool.py b/tests/primer/primer_tool.py index def4fa3f30..0a8eedd63a 100644 --- a/tests/primer/primer_tool.py +++ b/tests/primer/primer_tool.py @@ -6,7 +6,9 @@ import argparse import json +import warnings from io import StringIO +from itertools import chain from pathlib import Path from typing import Dict, List, Union @@ -130,6 +132,23 @@ def _handle_run_command(self) -> None: ) as f: json.dump(packages, f) + # Fail loudly (and fail CI pipelines) if any fatal errors are found, + # unless they are astroid-errors, in which case just warn sotto voce. + # This is to avoid introducing a dependency on bleeding-edge astroid + # for pylint CI pipelines generally, even though we do use astroid main + # to catch vanilla (non-crash) behavior changes in pylint PRs so that + # the contributor is alerted to it in a comment. + messages = list(chain.from_iterable(packages.values())) + astroid_errors = [msg for msg in messages if msg["symbol"] == "astroid-error"] + other_fatal_msgs = [ + msg + for msg in messages + if msg["type"] == "fatal" and msg["symbol"] != "astroid-error" + ] + if astroid_errors: + warnings.warn(f"Fatal errors traced to astroid:\n{astroid_errors}") + assert not other_fatal_msgs, other_fatal_msgs + def _handle_compare_command(self) -> None: with open(self.config.base_file, encoding="utf-8") as f: main_dict: PackageMessages = json.load(f) From fba3e43349b0882a5be0e16cbaf26e7c39534357 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 29 May 2022 20:53:27 -0400 Subject: [PATCH 2/7] appease spellchecker --- tests/primer/primer_tool.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/primer/primer_tool.py b/tests/primer/primer_tool.py index 0a8eedd63a..39bc0bbda5 100644 --- a/tests/primer/primer_tool.py +++ b/tests/primer/primer_tool.py @@ -133,11 +133,10 @@ def _handle_run_command(self) -> None: json.dump(packages, f) # Fail loudly (and fail CI pipelines) if any fatal errors are found, - # unless they are astroid-errors, in which case just warn sotto voce. + # unless they are astroid-errors, in which case just warn. # This is to avoid introducing a dependency on bleeding-edge astroid - # for pylint CI pipelines generally, even though we do use astroid main - # to catch vanilla (non-crash) behavior changes in pylint PRs so that - # the contributor is alerted to it in a comment. + # for pylint CI pipelines generally, even though we want to use astroid main + # for the purpose of diffing emitted messages and generating PR comments. messages = list(chain.from_iterable(packages.values())) astroid_errors = [msg for msg in messages if msg["symbol"] == "astroid-error"] other_fatal_msgs = [ From c5a1fad2fc5eb6923758c59928cff80c6a56df46 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 30 May 2022 09:41:42 -0400 Subject: [PATCH 3/7] Attempt to emit Actions warnings --- .github/workflows/primer_run_main.yaml | 8 +++++++- .github/workflows/primer_run_pr.yaml | 8 +++++++- tests/primer/primer_tool.py | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/primer_run_main.yaml b/.github/workflows/primer_run_main.yaml index 8e70988c4b..4f195b34fe 100644 --- a/.github/workflows/primer_run_main.yaml +++ b/.github/workflows/primer_run_main.yaml @@ -96,7 +96,13 @@ jobs: run: | . venv/bin/activate pip install -e . - python tests/primer/primer_tool.py run --type=main + python tests/primer/primer_tool.py run --type=main 2>warnings.txt + WARNINGS=$(warnings.txt + WARNINGS=$( None: if msg["type"] == "fatal" and msg["symbol"] != "astroid-error" ] if astroid_errors: - warnings.warn(f"Fatal errors traced to astroid:\n{astroid_errors}") + warnings.warn(f"Fatal errors traced to astroid: {astroid_errors}") assert not other_fatal_msgs, other_fatal_msgs def _handle_compare_command(self) -> None: From 160fb3691932420fbec8521bf0c7534b3bd73c46 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 30 May 2022 10:05:31 -0400 Subject: [PATCH 4/7] do_exit is deprecated --- tests/primer/primer_tool.py | 2 +- tests/profile/test_profile_against_externals.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/primer/primer_tool.py b/tests/primer/primer_tool.py index 67997b3f7d..2cba8de82d 100644 --- a/tests/primer/primer_tool.py +++ b/tests/primer/primer_tool.py @@ -260,7 +260,7 @@ def _lint_package(self, data: PackageToLint) -> list[dict[str, str | int]]: arguments += [f"--rcfile={data.pylintrc_relpath}"] output = StringIO() reporter = JSONReporter(output) - Run(arguments, reporter=reporter, do_exit=False) + Run(arguments, reporter=reporter, exit=False) return json.loads(output.getvalue()) @staticmethod diff --git a/tests/profile/test_profile_against_externals.py b/tests/profile/test_profile_against_externals.py index 33b25efbc3..579a5bc9ca 100644 --- a/tests/profile/test_profile_against_externals.py +++ b/tests/profile/test_profile_against_externals.py @@ -46,7 +46,7 @@ def test_run(tmp_path, name, git_repo): filepaths = _get_py_files(scanpath=str(checkoutdir)) print(f"Have {len(filepaths)} files") - runner = Run(filepaths, reporter=Reporter(), do_exit=False) + runner = Run(filepaths, reporter=Reporter(), exit=False) print( f"Had {len(filepaths)} files with {len(runner.linter.reporter.messages)} messages" From 20038a20772c3850dbf0ab538b2e0666fe23643f Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 30 May 2022 11:11:45 -0400 Subject: [PATCH 5/7] merge steps --- .github/workflows/primer_run_pr.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/primer_run_pr.yaml b/.github/workflows/primer_run_pr.yaml index 35f0df8879..b9ab2fae37 100644 --- a/.github/workflows/primer_run_pr.yaml +++ b/.github/workflows/primer_run_pr.yaml @@ -169,8 +169,6 @@ jobs: pip install -e . python tests/primer/primer_tool.py run --type=pr 2>warnings.txt WARNINGS=$( Date: Mon, 30 May 2022 15:24:07 -0400 Subject: [PATCH 6/7] 65000 chars is plenty --- .github/workflows/primer_run_main.yaml | 2 +- .github/workflows/primer_run_pr.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/primer_run_main.yaml b/.github/workflows/primer_run_main.yaml index 4f195b34fe..9ed62aa62b 100644 --- a/.github/workflows/primer_run_main.yaml +++ b/.github/workflows/primer_run_main.yaml @@ -97,7 +97,7 @@ jobs: . venv/bin/activate pip install -e . python tests/primer/primer_tool.py run --type=main 2>warnings.txt - WARNINGS=$(warnings.txt - WARNINGS=$( Date: Mon, 30 May 2022 16:36:58 -0400 Subject: [PATCH 7/7] consistency --- .github/workflows/primer_run_main.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/primer_run_main.yaml b/.github/workflows/primer_run_main.yaml index be9a939ae4..cdba3f22eb 100644 --- a/.github/workflows/primer_run_main.yaml +++ b/.github/workflows/primer_run_main.yaml @@ -98,8 +98,6 @@ jobs: pip install -e . python tests/primer/primer_tool.py run --type=main 2>warnings.txt WARNINGS=$(head -c 65000 < warnings.txt) - - name: Emit Actions warnings for python warnings - run: | if [[ $WARNINGS ]] then echo "::warning ::$WARNINGS" fi