From 87a4d672a8661aa61d5717fd902315d9563e33b6 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sat, 29 Apr 2023 14:11:55 -0400 Subject: Add home-assistant to primer and remove old external primer (#8612) --- .github/workflows/primer-test.yaml | 32 ---------- pylint/testutils/_primer/primer_prepare_command.py | 2 +- pyproject.toml | 1 - tests/conftest.py | 15 ----- tests/primer/packages_to_lint_batch_one.json | 7 --- tests/primer/packages_to_prime.json | 5 ++ tests/primer/test_primer_external.py | 73 ---------------------- 7 files changed, 6 insertions(+), 129 deletions(-) delete mode 100644 tests/primer/packages_to_lint_batch_one.json delete mode 100644 tests/primer/test_primer_external.py diff --git a/.github/workflows/primer-test.yaml b/.github/workflows/primer-test.yaml index 1f6848a2b..e357fe747 100644 --- a/.github/workflows/primer-test.yaml +++ b/.github/workflows/primer-test.yaml @@ -96,35 +96,3 @@ jobs: . venv/bin/activate pip install -e . pytest -m primer_stdlib --primer-stdlib -n auto -vv - - pytest-primer-external-batch-one: - name: run on batch one / ${{ matrix.python-version }} / Linux - runs-on: ubuntu-latest - timeout-minutes: 60 - needs: prepare-tests-linux - strategy: - matrix: - python-version: [3.8, 3.9, "3.10", "3.11"] - steps: - - name: Check out code from GitHub - uses: actions/checkout@v3.5.2 - - name: Set up Python ${{ matrix.python-version }} - id: python - uses: actions/setup-python@v4.6.0 - with: - python-version: ${{ matrix.python-version }} - check-latest: true - - name: Restore Python virtual environment - id: cache-venv - uses: actions/cache@v3.3.1 - with: - path: venv - fail-on-cache-miss: true - key: - ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ - needs.prepare-tests-linux.outputs.python-key }} - - name: Run pytest - run: | - . venv/bin/activate - pip install -e . - pytest -m primer_external_batch_one --primer-external -n auto -vv diff --git a/pylint/testutils/_primer/primer_prepare_command.py b/pylint/testutils/_primer/primer_prepare_command.py index 4cbc5cf17..c8c562a84 100644 --- a/pylint/testutils/_primer/primer_prepare_command.py +++ b/pylint/testutils/_primer/primer_prepare_command.py @@ -28,7 +28,7 @@ class PrepareCommand(PrimerCommand): elif self.config.make_commit_string: for package, data in self.packages.items(): remote_sha1_commit = ( - Git().ls_remote(data.url, data.branch).split("\t")[0] + Git().ls_remote(data.url, data.branch).split("\t")[0][:8] ) print(f"'{package}' remote is at commit '{remote_sha1_commit}'.") commit_string += remote_sha1_commit + "_" diff --git a/pyproject.toml b/pyproject.toml index fb3cfd0d6..a7a07619d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,7 +90,6 @@ addopts = "--strict-markers" filterwarnings = "error" markers = [ "primer_stdlib: Checks for crashes and errors when running pylint on stdlib", - "primer_external_batch_one: Checks for crashes and errors when running pylint on external libs (batch one)", "benchmark: Baseline of pylint performance, if this regress something serious happened", "timeout: Marks from pytest-timeout.", "needs_two_cores: Checks that need 2 or more cores to be meaningful", diff --git a/tests/conftest.py b/tests/conftest.py index 40b138448..a2512b414 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -84,12 +84,6 @@ def pytest_addoption(parser: pytest.Parser) -> None: default=False, help="Run primer stdlib tests", ) - parser.addoption( - "--primer-external", - action="store_true", - default=False, - help="Run primer external tests", - ) parser.addoption( "--minimal-messages-config", action="store_true", @@ -107,15 +101,6 @@ def pytest_collection_modifyitems( config: pytest.Config, items: list[pytest.Function] ) -> None: """Convert command line options to markers.""" - # Add skip_primer_external mark - if not config.getoption("--primer-external"): - skip_primer_external = pytest.mark.skip( - reason="need --primer-external option to run" - ) - for item in items: - if "primer_external_batch_one" in item.keywords: - item.add_marker(skip_primer_external) - # Add skip_primer_stdlib mark if not config.getoption("--primer-stdlib"): skip_primer_stdlib = pytest.mark.skip( diff --git a/tests/primer/packages_to_lint_batch_one.json b/tests/primer/packages_to_lint_batch_one.json deleted file mode 100644 index 6520e2bd1..000000000 --- a/tests/primer/packages_to_lint_batch_one.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "keras": { - "branch": "master", - "directories": ["keras"], - "url": "https://github.com/keras-team/keras.git" - } -} diff --git a/tests/primer/packages_to_prime.json b/tests/primer/packages_to_prime.json index 34c380ecd..a7c2796e7 100644 --- a/tests/primer/packages_to_prime.json +++ b/tests/primer/packages_to_prime.json @@ -20,6 +20,11 @@ "directories": ["src/flask"], "url": "https://github.com/pallets/flask" }, + "home-assistant": { + "branch": "dev", + "directories": ["homeassistant"], + "url": "https://github.com/home-assistant/core.git" + }, "music21": { "branch": "master", "directories": ["music21"], diff --git a/tests/primer/test_primer_external.py b/tests/primer/test_primer_external.py deleted file mode 100644 index f8afa21ca..000000000 --- a/tests/primer/test_primer_external.py +++ /dev/null @@ -1,73 +0,0 @@ -# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE -# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt - -from __future__ import annotations - -import json -import logging -import subprocess -from pathlib import Path - -import pytest -from pytest import LogCaptureFixture - -from pylint.testutils._primer import PackageToLint - -PRIMER_DIRECTORY = (Path("tests") / ".pylint_primer_tests/").resolve() - - -def get_packages_to_lint_from_json(json_path: Path | str) -> dict[str, PackageToLint]: - with open(json_path, encoding="utf8") as f: - return { - name: PackageToLint(**package_data) - for name, package_data in json.load(f).items() - } - - -PACKAGE_TO_LINT_JSON_BATCH_ONE = ( - Path(__file__).parent / "packages_to_lint_batch_one.json" -) -PACKAGES_TO_LINT_BATCH_ONE = get_packages_to_lint_from_json( - PACKAGE_TO_LINT_JSON_BATCH_ONE -) -"""Dictionary of external packages used during the primer test in batch one.""" - - -class TestPrimer: - @staticmethod - @pytest.mark.primer_external_batch_one - @pytest.mark.parametrize( - "package", PACKAGES_TO_LINT_BATCH_ONE.values(), ids=PACKAGES_TO_LINT_BATCH_ONE - ) - def test_primer_external_packages_no_crash_batch_one( - package: PackageToLint, - caplog: LogCaptureFixture, - ) -> None: - __tracebackhide__ = True # pylint: disable=unused-variable - TestPrimer._primer_test(package, caplog) - - @staticmethod - def _primer_test(package: PackageToLint, caplog: LogCaptureFixture) -> None: - """Runs pylint over external packages to check for crashes and fatal messages. - - We only check for crashes (bit-encoded exit code 32) and fatal messages - (bit-encoded exit code 1). We assume that these external repositories do not - have any fatal errors in their code so that any fatal errors are pylint false - positives - """ - caplog.set_level(logging.INFO) - package.lazy_clone() - - try: - # We want to test all the code we can - enables = ["--enable-all-extensions", "--enable=all"] - # Duplicate code takes too long and is relatively safe - disables = ["--disable=duplicate-code"] - command = ["pylint", *enables, *disables, *package.pylint_args] - logging.info("Launching primer:\n%s", " ".join(command)) - subprocess.run(command, check=True) - except subprocess.CalledProcessError as ex: - msg = f"Encountered {{}} during primer test for {package}" - assert ex.returncode != 32, msg.format("a crash") - assert ex.returncode % 2 == 0, msg.format("a message of category 'fatal'") -- cgit v1.2.1