From 1876f84d7bc209b1abc714163c45c7a098e4cb95 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Tue, 31 Aug 2021 14:47:51 -0700 Subject: [PATCH 1/3] Add specific and actionable instructions to stale lockfile errors (#12699) This changes the lockfile staleness messages to include information on how to reconfigure pants to resolve the error. Language is largely similar to that proposed in #12654, with minor changes: * Language changes to explain the need for action on the user's part (_you can fix this by_ rather than _please change_ ) Closes #12654 # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] --- .../backend/python/lint/pylint/subsystem.py | 1 + .../python/subsystems/python_tool_base.py | 19 +- .../python/typecheck/mypy/subsystem.py | 1 + .../pants/backend/python/util_rules/pex.py | 117 ++++++-- .../backend/python/util_rules/pex_test.py | 283 +++++++++++++++--- 5 files changed, 351 insertions(+), 70 deletions(-) diff --git a/src/python/pants/backend/python/lint/pylint/subsystem.py b/src/python/pants/backend/python/lint/pylint/subsystem.py index dd09aa12a13..c12716eb968 100644 --- a/src/python/pants/backend/python/lint/pylint/subsystem.py +++ b/src/python/pants/backend/python/lint/pylint/subsystem.py @@ -73,6 +73,7 @@ class Pylint(PythonToolBase): default_lockfile_resource = ("pants.backend.python.lint.pylint", "lockfile.txt") default_lockfile_path = "src/python/pants/backend/python/lint/pylint/lockfile.txt" default_lockfile_url = git_url(default_lockfile_path) + uses_requirements_from_source_plugins = True @classmethod def register_options(cls, register): diff --git a/src/python/pants/backend/python/subsystems/python_tool_base.py b/src/python/pants/backend/python/subsystems/python_tool_base.py index 65dd8ba777e..ad68a5c4e22 100644 --- a/src/python/pants/backend/python/subsystems/python_tool_base.py +++ b/src/python/pants/backend/python/subsystems/python_tool_base.py @@ -9,7 +9,13 @@ from pants.backend.python.target_types import ConsoleScript, EntryPoint, MainSpecification from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints from pants.backend.python.util_rules.lockfile_metadata import calculate_invalidation_digest -from pants.backend.python.util_rules.pex import Lockfile, LockfileContent, PexRequirements +from pants.backend.python.util_rules.pex import ( + Lockfile, + LockfileContent, + PexRequirements, + ToolCustomLockfile, + ToolDefaultLockfile, +) from pants.engine.fs import FileContent from pants.option.errors import OptionsError from pants.option.subsystem import Subsystem @@ -38,6 +44,7 @@ class PythonToolRequirementsBase(Subsystem): register_lockfile: ClassVar[bool] = False default_lockfile_resource: ClassVar[tuple[str, str] | None] = None default_lockfile_url: ClassVar[str | None] = None + uses_requirements_from_source_plugins: ClassVar[bool] = False @classmethod def register_options(cls, register): @@ -143,17 +150,23 @@ def pex_requirements( if self.lockfile == DEFAULT_TOOL_LOCKFILE: assert self.default_lockfile_resource is not None - return LockfileContent( + return ToolDefaultLockfile( file_content=FileContent( f"{self.options_scope}_default_lockfile.txt", importlib.resources.read_binary(*self.default_lockfile_resource), ), lockfile_hex_digest=hex_digest, + options_scope_name=self.options_scope, + uses_project_interpreter_constraints=(not self.register_interpreter_constraints), + uses_source_plugins=self.uses_requirements_from_source_plugins, ) - return Lockfile( + return ToolCustomLockfile( file_path=self.lockfile, file_path_description_of_origin=f"the option `[{self.options_scope}].lockfile`", lockfile_hex_digest=hex_digest, + options_scope_name=self.options_scope, + uses_project_interpreter_constraints=(not self.register_interpreter_constraints), + uses_source_plugins=self.uses_requirements_from_source_plugins, ) @property diff --git a/src/python/pants/backend/python/typecheck/mypy/subsystem.py b/src/python/pants/backend/python/typecheck/mypy/subsystem.py index 2e655006794..3b2ebf26fcf 100644 --- a/src/python/pants/backend/python/typecheck/mypy/subsystem.py +++ b/src/python/pants/backend/python/typecheck/mypy/subsystem.py @@ -71,6 +71,7 @@ class MyPy(PythonToolBase): default_lockfile_resource = ("pants.backend.python.typecheck.mypy", "lockfile.txt") default_lockfile_path = "src/python/pants/backend/python/typecheck/mypy/lockfile.txt" default_lockfile_url = git_url(default_lockfile_path) + uses_requirements_from_source_plugins = True @classmethod def register_options(cls, register): diff --git a/src/python/pants/backend/python/util_rules/pex.py b/src/python/pants/backend/python/util_rules/pex.py index fb0bc1c6c25..f1c0c363293 100644 --- a/src/python/pants/backend/python/util_rules/pex.py +++ b/src/python/pants/backend/python/util_rules/pex.py @@ -58,6 +58,7 @@ from pants.engine.rules import Get, MultiGet, collect_rules, rule from pants.python.python_repos import PythonRepos from pants.python.python_setup import InvalidLockfileBehavior, PythonSetup +from pants.util.docutil import doc_url from pants.util.frozendict import FrozenDict from pants.util.logging import LogLevel from pants.util.meta import frozen_after_init @@ -78,6 +79,23 @@ class LockfileContent: lockfile_hex_digest: str | None +@dataclass(frozen=True) +class _ToolLockfileMixin: + options_scope_name: str + uses_source_plugins: bool + uses_project_interpreter_constraints: bool + + +@dataclass(frozen=True) +class ToolDefaultLockfile(LockfileContent, _ToolLockfileMixin): + pass + + +@dataclass(frozen=True) +class ToolCustomLockfile(Lockfile, _ToolLockfileMixin): + pass + + @frozen_after_init @dataclass(unsafe_hash=True) class PexRequirements: @@ -587,37 +605,82 @@ def _validate_metadata( if validation: return - message_parts = [ - f"Invalid lockfile for PEX request `{request.output_filename}`.", - "\n", - ] + def tool_message_parts( + requirements: (ToolCustomLockfile | ToolDefaultLockfile), + ) -> Iterator[str]: - if InvalidLockfileReason.INVALIDATION_DIGEST_MISMATCH in validation.failure_reasons: - message_parts.append( - "The requirements set for this PEX request are different to the requirements set when " - "the lockfile was generated. To fix this, you will need to regenerate the lockfile. " - ) - message_parts.append( - f"(Expected requirements digest: {requirements.lockfile_hex_digest}, " - f"actual: {metadata.requirements_invalidation_digest})" - ) - message_parts.append("\n") - - if InvalidLockfileReason.INTERPRETER_CONSTRAINTS_MISMATCH in validation.failure_reasons: - message_parts.append( - "The lockfile was generated under interpreter constraints " - f"({ metadata.valid_for_interpreter_constraints }) that are incompatible with the " - f"constraints set in the project ({request.interpreter_constraints }). If you have " - "overridden your project's interpreter constraints, you can update them to specify a " - "subset of the interpreters specified in the lockfile. If not, you will need to " - "regenerate your lockfile. " + tool_name = requirements.options_scope_name + uses_source_plugins = requirements.uses_source_plugins + uses_project_interpreter_constraints = requirements.uses_project_interpreter_constraints + + yield "You are using " + + if isinstance(requirements, ToolDefaultLockfile): + yield "the `` lockfile provided by Pants " + elif isinstance(requirements, ToolCustomLockfile): + yield f"the lockfile at {requirements.file_path} " + + yield ( + f"to install the tool `{tool_name}`, but it is not compatible with your " + "configuration: " + "\n\n" ) - message_parts.append( - "To regenerate the lockfile, follow the instructions in the header of the lockfile." - ) + if InvalidLockfileReason.INVALIDATION_DIGEST_MISMATCH in validation.failure_reasons: + yield ( + "- You have set different requirements than those used to generate the lockfile. " + f"You can fix this by not setting `[{tool_name}].version`, " + ) + + if uses_source_plugins: + yield f"`[{tool_name}].source_plugins`, " + + yield ( + f"and `[{tool_name}].extra_requirements`, or by using a new " + "custom lockfile." + "\n" + ) - message = "\n".join(message_parts).strip() + if InvalidLockfileReason.INTERPRETER_CONSTRAINTS_MISMATCH in validation.failure_reasons: + yield ( + f"- You have set interpreter constraints (`{request.interpreter_constraints}`) that " + "are not compatible with those used to generate the lockfile " + f"(`{metadata.valid_for_interpreter_constraints}`). " + ) + if not uses_project_interpreter_constraints: + yield ( + f"You can fix this by not setting `[{tool_name}].interpreter_constraints`, " + "or by using a new custom lockfile. " + ) + else: + yield ( + f"`{tool_name}` determines its interpreter constraints based on your code's own " + "constraints. To fix this error, you can either change your code's constraints " + f"(see {doc_url('python-interpreter-compatibility')}) or by generating a new " + "custom lockfile. " + ) + yield "\n" + + yield "\n" + + if not isinstance(requirements, ToolCustomLockfile): + yield ( + "To generate a custom lockfile based on your current configuration, set " + f"`[{tool_name}].lockfile` to where you want to create the lockfile, then run " + f"`./pants generate-lockfiles --resolve={tool_name}`. " + ) + else: + yield ( + "To regenerate your lockfile based on your current configuration, run " + f"`./pants generate-lockfiles --resolve={tool_name}`. " + ) + + message: str + if isinstance(requirements, (ToolCustomLockfile, ToolDefaultLockfile)): + message = "".join(tool_message_parts(requirements)).strip() + else: + # TODO: Replace with an actual value once user lockfiles are supported + assert False if python_setup.invalid_lockfile_behavior == InvalidLockfileBehavior.error: raise ValueError(message) diff --git a/src/python/pants/backend/python/util_rules/pex_test.py b/src/python/pants/backend/python/util_rules/pex_test.py index 8bb394cd550..c44c45bade2 100644 --- a/src/python/pants/backend/python/util_rules/pex_test.py +++ b/src/python/pants/backend/python/util_rules/pex_test.py @@ -10,6 +10,7 @@ import zipfile from dataclasses import dataclass from typing import Dict, Iterable, Iterator, Mapping, Tuple, cast +from unittest.mock import MagicMock import pytest from packaging.specifiers import SpecifierSet @@ -18,6 +19,7 @@ from pants.backend.python.target_types import EntryPoint, MainSpecification from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints +from pants.backend.python.util_rules.lockfile_metadata import LockfileMetadata from pants.backend.python.util_rules.pex import ( Lockfile, LockfileContent, @@ -29,15 +31,19 @@ PexRequirements, PexResolveInfo, ResolvedDistributions, + ToolCustomLockfile, + ToolDefaultLockfile, VenvPex, VenvPexProcess, _build_pex_description, + _validate_metadata, ) from pants.backend.python.util_rules.pex import rules as pex_rules from pants.backend.python.util_rules.pex_cli import PexPEX from pants.engine.fs import EMPTY_DIGEST, CreateDigest, Digest, Directory, FileContent from pants.engine.internals.scheduler import ExecutionError from pants.engine.process import Process, ProcessResult +from pants.python.python_setup import InvalidLockfileBehavior from pants.testutil.rule_runner import QueryRule, RuleRunner @@ -526,7 +532,10 @@ def assert_description( ) assert_description( - LockfileContent(file_content=FileContent("lock.txt", b""), lockfile_hex_digest=None), + LockfileContent( + file_content=FileContent("lock.txt", b""), + lockfile_hex_digest=None, + ), expected="Building new.pex from lock.txt", ) @@ -538,87 +547,108 @@ def assert_description( ) +DEFAULT = "DEFAULT" +FILE = "FILE" + + def test_error_on_invalid_lockfile_with_path(rule_runner: RuleRunner) -> None: with pytest.raises(ExecutionError): _run_pex_for_lockfile_test( rule_runner, - use_file=True, + lockfile_type=FILE, behavior="error", invalid_reqs=True, ) def test_warn_on_invalid_lockfile_with_path(rule_runner: RuleRunner, caplog) -> None: - _run_pex_for_lockfile_test(rule_runner, use_file=True, behavior="warn", invalid_reqs=True) - assert "Invalid lockfile for PEX request" in caplog.text + _run_pex_for_lockfile_test(rule_runner, lockfile_type=FILE, behavior="warn", invalid_reqs=True) + assert "but it is not compatible with your configuration" in caplog.text def test_warn_on_requirements_mismatch(rule_runner: RuleRunner, caplog) -> None: - _run_pex_for_lockfile_test(rule_runner, use_file=True, behavior="warn", invalid_reqs=True) - assert "requirements set for this" in caplog.text - assert "generated under interpreter constraints" not in caplog.text + _run_pex_for_lockfile_test(rule_runner, lockfile_type=FILE, behavior="warn", invalid_reqs=True) + assert "You have set different requirements" in caplog.text + assert "You have set interpreter constraints" not in caplog.text def test_warn_on_interpreter_constraints_mismatch(rule_runner: RuleRunner, caplog) -> None: _run_pex_for_lockfile_test( - rule_runner, use_file=True, behavior="warn", invalid_constraints=True + rule_runner, lockfile_type=FILE, behavior="warn", invalid_constraints=True ) - assert "requirements set for this" not in caplog.text - assert "generated under interpreter constraints" in caplog.text + assert "You have set different requirements" not in caplog.text + assert "You have set interpreter constraints" in caplog.text def test_warn_on_mismatched_requirements_and_interpreter_constraints( rule_runner: RuleRunner, caplog ) -> None: _run_pex_for_lockfile_test( - rule_runner, use_file=True, behavior="warn", invalid_reqs=True, invalid_constraints=True + rule_runner, + lockfile_type=FILE, + behavior="warn", + invalid_reqs=True, + invalid_constraints=True, ) - assert "requirements set for this" in caplog.text - assert "generated under interpreter constraints" in caplog.text + assert "You have set different requirements" in caplog.text + assert "You have set interpreter constraints" in caplog.text def test_ignore_on_invalid_lockfile_with_path(rule_runner: RuleRunner, caplog) -> None: - _run_pex_for_lockfile_test(rule_runner, use_file=True, behavior="ignore", invalid_reqs=True) + _run_pex_for_lockfile_test( + rule_runner, lockfile_type=FILE, behavior="ignore", invalid_reqs=True + ) assert not caplog.text.strip() def test_no_warning_on_valid_lockfile_with_path(rule_runner: RuleRunner, caplog) -> None: - _run_pex_for_lockfile_test(rule_runner, use_file=True, behavior="warn") + _run_pex_for_lockfile_test(rule_runner, lockfile_type=FILE, behavior="warn") assert not caplog.text.strip() def test_error_on_invalid_lockfile_with_content(rule_runner: RuleRunner) -> None: with pytest.raises(ExecutionError): - _run_pex_for_lockfile_test(rule_runner, use_file=False, behavior="error", invalid_reqs=True) + _run_pex_for_lockfile_test( + rule_runner, lockfile_type=DEFAULT, behavior="error", invalid_reqs=True + ) def test_warn_on_invalid_lockfile_with_content(rule_runner: RuleRunner, caplog) -> None: - _run_pex_for_lockfile_test(rule_runner, use_file=False, behavior="warn", invalid_reqs=True) - assert "Invalid lockfile for PEX request" in caplog.text + _run_pex_for_lockfile_test( + rule_runner, lockfile_type=DEFAULT, behavior="warn", invalid_reqs=True + ) + assert "but it is not compatible with your configuration" in caplog.text def test_no_warning_on_valid_lockfile_with_content(rule_runner: RuleRunner, caplog) -> None: - _run_pex_for_lockfile_test(rule_runner, use_file=False, behavior="warn") + _run_pex_for_lockfile_test(rule_runner, lockfile_type=DEFAULT, behavior="warn") assert not caplog.text.strip() +LOCKFILE_TYPES = (DEFAULT, FILE) +BOOLEANS = (True, False) + + def _run_pex_for_lockfile_test( rule_runner, *, - use_file, + lockfile_type: str, behavior, invalid_reqs=False, invalid_constraints=False, + uses_source_plugins=False, + uses_project_ic=False, ) -> None: - actual_digest = "900d" - expected_digest = actual_digest - if invalid_reqs: - expected_digest = "baad" - actual_constraints = "CPython>=3.6,<3.10" - expected_constraints = actual_constraints - if invalid_constraints: - expected_constraints = "CPython>=3.9" + ( + actual_digest, + expected_digest, + actual_constraints, + expected_constraints, + options_scope_name, + ) = _metadata_validation_values( + invalid_reqs, invalid_constraints, uses_source_plugins, uses_project_ic + ) lockfile = f""" # --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE --- @@ -631,19 +661,16 @@ def _run_pex_for_lockfile_test( # --- END PANTS LOCKFILE METADATA --- ansicolors==1.1.8 """ - requirements: Lockfile | LockfileContent - if use_file: - file_path = "lockfile.txt" - rule_runner.write_files({file_path: lockfile}) - requirements = Lockfile( - file_path=file_path, - file_path_description_of_origin="iceland", - lockfile_hex_digest=expected_digest, - ) - else: - content = FileContent("lockfile.txt", lockfile.encode("utf-8")) - requirements = LockfileContent(file_content=content, lockfile_hex_digest=expected_digest) + requirements = _prepare_pex_requirements( + rule_runner, + lockfile_type, + lockfile, + expected_digest, + options_scope_name, + uses_source_plugins, + uses_project_ic, + ) create_pex_and_get_all_data( rule_runner, @@ -654,3 +681,179 @@ def _run_pex_for_lockfile_test( f"--python-setup-invalid-lockfile-behavior={behavior}", ), ) + + +@pytest.mark.parametrize( + "lockfile_type,invalid_reqs,invalid_constraints,uses_source_plugins,uses_project_ic", + [ + (lft, ir, ic, usp, upi) + for lft in LOCKFILE_TYPES + for ir in BOOLEANS + for ic in BOOLEANS + for usp in BOOLEANS + for upi in BOOLEANS + if (ir or ic) + ], +) +def test_validate_metadata( + rule_runner, + lockfile_type: str, + invalid_reqs, + invalid_constraints, + uses_source_plugins, + uses_project_ic, + caplog, +) -> None: + class M: + opening_default = "You are using the `` lockfile provided by Pants" + opening_file = "You are using the lockfile at" + + invalid_requirements = ( + "You have set different requirements than those used to generate the lockfile" + ) + invalid_requirements_source_plugins = ".source_plugins`, and" + + invalid_interpreter_constraints = "You have set interpreter constraints" + invalid_interpreter_constraints_tool_ics = ( + ".interpreter_constraints`, or by using a new custom lockfile." + ) + invalid_interpreter_constraints_project_ics = ( + "determines its interpreter constraints based on your code's own constraints." + ) + + closing_lockfile_content = ( + "To generate a custom lockfile based on your current configuration" + ) + closing_file = "To regenerate your lockfile based on your current configuration" + + ( + actual_digest, + expected_digest, + actual_constraints, + expected_constraints, + options_scope_name, + ) = _metadata_validation_values( + invalid_reqs, invalid_constraints, uses_source_plugins, uses_project_ic + ) + + metadata = LockfileMetadata(expected_digest, InterpreterConstraints([expected_constraints])) + requirements = _prepare_pex_requirements( + rule_runner, + lockfile_type, + "lockfile_data_goes_here", + actual_digest, + options_scope_name, + uses_source_plugins, + uses_project_ic, + ) + + request = MagicMock( + options_scope_name=options_scope_name, + interpreter_constraints=InterpreterConstraints([actual_constraints]), + ) + python_setup = MagicMock( + invalid_lockfile_behavior=InvalidLockfileBehavior.warn, + interpreter_universe=["3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"], + ) + + _validate_metadata(metadata, request, requirements, python_setup) + + txt = caplog.text.strip() + + expected_opening = { + DEFAULT: M.opening_default, + FILE: M.opening_file, + }[lockfile_type] + + assert expected_opening in txt + + if invalid_reqs: + assert M.invalid_requirements in txt + if uses_source_plugins: + assert M.invalid_requirements_source_plugins in txt + else: + assert M.invalid_requirements_source_plugins not in txt + else: + assert M.invalid_requirements not in txt + + if invalid_constraints: + assert M.invalid_interpreter_constraints in txt + if uses_project_ic: + assert M.invalid_interpreter_constraints_project_ics in txt + assert M.invalid_interpreter_constraints_tool_ics not in txt + else: + assert M.invalid_interpreter_constraints_project_ics not in txt + assert M.invalid_interpreter_constraints_tool_ics in txt + + else: + assert M.invalid_interpreter_constraints not in txt + + if lockfile_type == FILE: + assert M.closing_lockfile_content not in txt + assert M.closing_file in txt + + +def _metadata_validation_values( + invalid_reqs: bool, invalid_constraints: bool, uses_source_plugins: bool, uses_project_ic: bool +) -> tuple[str, str, str, str, str]: + + actual_digest = "900d" + expected_digest = actual_digest + if invalid_reqs: + expected_digest = "baad" + + actual_constraints = "CPython>=3.6,<3.10" + expected_constraints = actual_constraints + if invalid_constraints: + expected_constraints = "CPython>=3.9" + + options_scope_name: str + if uses_source_plugins and uses_project_ic: + options_scope_name = "pylint" + elif uses_source_plugins: + options_scope_name = "mypy" + elif uses_project_ic: + options_scope_name = "bandit" + else: + options_scope_name = "kevin" + + return ( + actual_digest, + expected_digest, + actual_constraints, + expected_constraints, + options_scope_name, + ) + + +def _prepare_pex_requirements( + rule_runner: RuleRunner, + lockfile_type: str, + lockfile: str, + expected_digest: str, + options_scope_name: str, + uses_source_plugins: bool, + uses_project_interpreter_constraints: bool, +) -> Lockfile | LockfileContent: + if lockfile_type == FILE: + file_path = "lockfile.txt" + rule_runner.write_files({file_path: lockfile}) + return ToolCustomLockfile( + file_path=file_path, + file_path_description_of_origin="iceland", + lockfile_hex_digest=expected_digest, + options_scope_name=options_scope_name, + uses_source_plugins=uses_source_plugins, + uses_project_interpreter_constraints=uses_project_interpreter_constraints, + ) + elif lockfile_type == DEFAULT: + content = FileContent("lockfile.txt", lockfile.encode("utf-8")) + return ToolDefaultLockfile( + file_content=content, + lockfile_hex_digest=expected_digest, + options_scope_name=options_scope_name, + uses_source_plugins=uses_source_plugins, + uses_project_interpreter_constraints=uses_project_interpreter_constraints, + ) + else: + raise Exception("incorrect lockfile_type value in test") From f8c8d5f955fb01898ab5e6f381ab7136695abd8c Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Wed, 1 Sep 2021 19:26:05 -0700 Subject: [PATCH 2/3] Bump timeouts and disable JVM tests due to flakiness # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels] --- src/python/pants/backend/awslambda/python/BUILD | 2 +- .../pants/backend/codegen/protobuf/python/BUILD | 2 +- .../pants/backend/java/compile/javac_binary_test.py | 3 +++ src/python/pants/backend/java/compile/javac_test.py | 3 +++ src/python/pants/backend/python/goals/BUILD | 12 ++++++------ src/python/pants/backend/python/lint/bandit/BUILD | 2 +- src/python/pants/backend/python/lint/black/BUILD | 2 +- .../pants/backend/python/lint/docformatter/BUILD | 2 +- src/python/pants/backend/python/lint/flake8/BUILD | 2 +- src/python/pants/backend/python/lint/isort/BUILD | 2 +- src/python/pants/backend/python/lint/pylint/BUILD | 2 +- src/python/pants/backend/python/lint/yapf/BUILD | 2 +- src/python/pants/backend/python/subsystems/BUILD | 2 +- src/python/pants/backend/python/typecheck/mypy/BUILD | 2 +- 14 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/python/pants/backend/awslambda/python/BUILD b/src/python/pants/backend/awslambda/python/BUILD index 409c775b591..a5042b010d2 100644 --- a/src/python/pants/backend/awslambda/python/BUILD +++ b/src/python/pants/backend/awslambda/python/BUILD @@ -8,7 +8,7 @@ python_tests(name='target_types_test', sources=["target_types_test.py"]) python_tests( name="rules_test", sources=["rules_test.py"], - timeout=120, + timeout=200, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/codegen/protobuf/python/BUILD b/src/python/pants/backend/codegen/protobuf/python/BUILD index cd3e8d447b4..f22649bbaf9 100644 --- a/src/python/pants/backend/codegen/protobuf/python/BUILD +++ b/src/python/pants/backend/codegen/protobuf/python/BUILD @@ -11,7 +11,7 @@ python_tests(name="python_protobuf_subsystem_test", sources=["python_protobuf_su python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=120, + timeout=210, # We want to make sure the default lockfile for MyPy Protobuf works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/java/compile/javac_binary_test.py b/src/python/pants/backend/java/compile/javac_binary_test.py index 88ea2e1fc44..b7dca20c65c 100644 --- a/src/python/pants/backend/java/compile/javac_binary_test.py +++ b/src/python/pants/backend/java/compile/javac_binary_test.py @@ -14,6 +14,9 @@ from pants.jvm.resolve.coursier_setup import rules as coursier_setup_rules from pants.testutil.rule_runner import QueryRule, RuleRunner +# TODO(#12293): Stabilize flakiness. +pytestmark = pytest.mark.skip + @pytest.fixture def rule_runner() -> RuleRunner: diff --git a/src/python/pants/backend/java/compile/javac_test.py b/src/python/pants/backend/java/compile/javac_test.py index e70036f46a3..87c31e97dd3 100644 --- a/src/python/pants/backend/java/compile/javac_test.py +++ b/src/python/pants/backend/java/compile/javac_test.py @@ -30,6 +30,9 @@ from pants.jvm.util_rules import rules as util_rules from pants.testutil.rule_runner import QueryRule, RuleRunner +# TODO(#12293): Stabilize flakiness. +pytestmark = pytest.mark.skip + @pytest.fixture def rule_runner() -> RuleRunner: diff --git a/src/python/pants/backend/python/goals/BUILD b/src/python/pants/backend/python/goals/BUILD index 83d5b3c9f64..0a048bed893 100644 --- a/src/python/pants/backend/python/goals/BUILD +++ b/src/python/pants/backend/python/goals/BUILD @@ -8,7 +8,7 @@ python_tests( sources=["coverage_py_integration_test.py"], # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], - timeout=210, + timeout=300, ) python_tests(name="coverage_py_test", sources=["coverage_py_test.py"], timeout=20) @@ -18,7 +18,7 @@ python_tests(name="lockfile_test", sources=["lockfile_test.py"]) python_tests( name="package_pex_binary_integration", sources=["package_pex_binary_integration_test.py"], - timeout=120, + timeout=150, ) python_tests( @@ -26,26 +26,26 @@ python_tests( sources=["pytest_runner_integration_test.py"], # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], - timeout=480, + timeout=510, ) python_tests( name="run_pex_binary_integration", sources=["run_pex_binary_integration_test.py"], - timeout=120, + timeout=200, ) python_tests( name="setup_py_integration", sources=["setup_py_integration_test.py"], dependencies=["testprojects/src/python:native_directory"], - timeout=180, + timeout=220, ) python_tests( name="setup_py_test", sources=["setup_py_test.py"], - timeout=150, + timeout=180, ) python_tests(name="tailor_test", sources=["tailor_test.py"]) diff --git a/src/python/pants/backend/python/lint/bandit/BUILD b/src/python/pants/backend/python/lint/bandit/BUILD index 507f9f85bdc..5a7a38adadb 100644 --- a/src/python/pants/backend/python/lint/bandit/BUILD +++ b/src/python/pants/backend/python/lint/bandit/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=240, + timeout=300, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/black/BUILD b/src/python/pants/backend/python/lint/black/BUILD index 65ee210d169..82e1c0e1fdf 100644 --- a/src/python/pants/backend/python/lint/black/BUILD +++ b/src/python/pants/backend/python/lint/black/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=240, + timeout=300, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/docformatter/BUILD b/src/python/pants/backend/python/lint/docformatter/BUILD index c227a18d48d..14a9e0e0fbe 100644 --- a/src/python/pants/backend/python/lint/docformatter/BUILD +++ b/src/python/pants/backend/python/lint/docformatter/BUILD @@ -7,7 +7,7 @@ resources(name="lockfile", sources=["lockfile.txt"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=120, + timeout=300, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/flake8/BUILD b/src/python/pants/backend/python/lint/flake8/BUILD index b74e5b007ad..82e1c0e1fdf 100644 --- a/src/python/pants/backend/python/lint/flake8/BUILD +++ b/src/python/pants/backend/python/lint/flake8/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=180, + timeout=300, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/isort/BUILD b/src/python/pants/backend/python/lint/isort/BUILD index 7c3fb2d2c6d..01882cdb9bf 100644 --- a/src/python/pants/backend/python/lint/isort/BUILD +++ b/src/python/pants/backend/python/lint/isort/BUILD @@ -7,7 +7,7 @@ resources(name="lockfile", sources=["lockfile.txt"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=120, + timeout=300, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/pylint/BUILD b/src/python/pants/backend/python/lint/pylint/BUILD index 276a3da2476..2fa173cec0f 100644 --- a/src/python/pants/backend/python/lint/pylint/BUILD +++ b/src/python/pants/backend/python/lint/pylint/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"], timeout=120) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=330, + timeout=360, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/yapf/BUILD b/src/python/pants/backend/python/lint/yapf/BUILD index 280be6b4de6..e7b44b29e36 100644 --- a/src/python/pants/backend/python/lint/yapf/BUILD +++ b/src/python/pants/backend/python/lint/yapf/BUILD @@ -7,7 +7,7 @@ resources(name="lockfile", sources=["lockfile.txt"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=120, + timeout=300, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/subsystems/BUILD b/src/python/pants/backend/python/subsystems/BUILD index b207023ab39..8ac3a3b9a27 100644 --- a/src/python/pants/backend/python/subsystems/BUILD +++ b/src/python/pants/backend/python/subsystems/BUILD @@ -4,4 +4,4 @@ python_library(dependencies=[":lockfiles"]) resources(name="lockfiles", sources=["*_lockfile.txt"]) -python_tests(name="tests") +python_tests(name="tests", timeout=120) diff --git a/src/python/pants/backend/python/typecheck/mypy/BUILD b/src/python/pants/backend/python/typecheck/mypy/BUILD index 4d2d0dc4d24..085fb041d9d 100644 --- a/src/python/pants/backend/python/typecheck/mypy/BUILD +++ b/src/python/pants/backend/python/typecheck/mypy/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=480, + timeout=520, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) From 87b29b47577c1c5e8f9520fabd50591650ac17e7 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Wed, 1 Sep 2021 20:17:03 -0700 Subject: [PATCH 3/3] Revert "Bump timeouts and disable JVM tests due to flakiness" This reverts commit f8c8d5f955fb01898ab5e6f381ab7136695abd8c. [ci skip-rust] [ci skip-build-wheels] --- src/python/pants/backend/awslambda/python/BUILD | 2 +- .../pants/backend/codegen/protobuf/python/BUILD | 2 +- .../pants/backend/java/compile/javac_binary_test.py | 3 --- src/python/pants/backend/java/compile/javac_test.py | 3 --- src/python/pants/backend/python/goals/BUILD | 12 ++++++------ src/python/pants/backend/python/lint/bandit/BUILD | 2 +- src/python/pants/backend/python/lint/black/BUILD | 2 +- .../pants/backend/python/lint/docformatter/BUILD | 2 +- src/python/pants/backend/python/lint/flake8/BUILD | 2 +- src/python/pants/backend/python/lint/isort/BUILD | 2 +- src/python/pants/backend/python/lint/pylint/BUILD | 2 +- src/python/pants/backend/python/lint/yapf/BUILD | 2 +- src/python/pants/backend/python/subsystems/BUILD | 2 +- src/python/pants/backend/python/typecheck/mypy/BUILD | 2 +- 14 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/python/pants/backend/awslambda/python/BUILD b/src/python/pants/backend/awslambda/python/BUILD index a5042b010d2..409c775b591 100644 --- a/src/python/pants/backend/awslambda/python/BUILD +++ b/src/python/pants/backend/awslambda/python/BUILD @@ -8,7 +8,7 @@ python_tests(name='target_types_test', sources=["target_types_test.py"]) python_tests( name="rules_test", sources=["rules_test.py"], - timeout=200, + timeout=120, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/codegen/protobuf/python/BUILD b/src/python/pants/backend/codegen/protobuf/python/BUILD index f22649bbaf9..cd3e8d447b4 100644 --- a/src/python/pants/backend/codegen/protobuf/python/BUILD +++ b/src/python/pants/backend/codegen/protobuf/python/BUILD @@ -11,7 +11,7 @@ python_tests(name="python_protobuf_subsystem_test", sources=["python_protobuf_su python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=210, + timeout=120, # We want to make sure the default lockfile for MyPy Protobuf works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/java/compile/javac_binary_test.py b/src/python/pants/backend/java/compile/javac_binary_test.py index b7dca20c65c..88ea2e1fc44 100644 --- a/src/python/pants/backend/java/compile/javac_binary_test.py +++ b/src/python/pants/backend/java/compile/javac_binary_test.py @@ -14,9 +14,6 @@ from pants.jvm.resolve.coursier_setup import rules as coursier_setup_rules from pants.testutil.rule_runner import QueryRule, RuleRunner -# TODO(#12293): Stabilize flakiness. -pytestmark = pytest.mark.skip - @pytest.fixture def rule_runner() -> RuleRunner: diff --git a/src/python/pants/backend/java/compile/javac_test.py b/src/python/pants/backend/java/compile/javac_test.py index 87c31e97dd3..e70036f46a3 100644 --- a/src/python/pants/backend/java/compile/javac_test.py +++ b/src/python/pants/backend/java/compile/javac_test.py @@ -30,9 +30,6 @@ from pants.jvm.util_rules import rules as util_rules from pants.testutil.rule_runner import QueryRule, RuleRunner -# TODO(#12293): Stabilize flakiness. -pytestmark = pytest.mark.skip - @pytest.fixture def rule_runner() -> RuleRunner: diff --git a/src/python/pants/backend/python/goals/BUILD b/src/python/pants/backend/python/goals/BUILD index 0a048bed893..83d5b3c9f64 100644 --- a/src/python/pants/backend/python/goals/BUILD +++ b/src/python/pants/backend/python/goals/BUILD @@ -8,7 +8,7 @@ python_tests( sources=["coverage_py_integration_test.py"], # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], - timeout=300, + timeout=210, ) python_tests(name="coverage_py_test", sources=["coverage_py_test.py"], timeout=20) @@ -18,7 +18,7 @@ python_tests(name="lockfile_test", sources=["lockfile_test.py"]) python_tests( name="package_pex_binary_integration", sources=["package_pex_binary_integration_test.py"], - timeout=150, + timeout=120, ) python_tests( @@ -26,26 +26,26 @@ python_tests( sources=["pytest_runner_integration_test.py"], # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], - timeout=510, + timeout=480, ) python_tests( name="run_pex_binary_integration", sources=["run_pex_binary_integration_test.py"], - timeout=200, + timeout=120, ) python_tests( name="setup_py_integration", sources=["setup_py_integration_test.py"], dependencies=["testprojects/src/python:native_directory"], - timeout=220, + timeout=180, ) python_tests( name="setup_py_test", sources=["setup_py_test.py"], - timeout=180, + timeout=150, ) python_tests(name="tailor_test", sources=["tailor_test.py"]) diff --git a/src/python/pants/backend/python/lint/bandit/BUILD b/src/python/pants/backend/python/lint/bandit/BUILD index 5a7a38adadb..507f9f85bdc 100644 --- a/src/python/pants/backend/python/lint/bandit/BUILD +++ b/src/python/pants/backend/python/lint/bandit/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=300, + timeout=240, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/black/BUILD b/src/python/pants/backend/python/lint/black/BUILD index 82e1c0e1fdf..65ee210d169 100644 --- a/src/python/pants/backend/python/lint/black/BUILD +++ b/src/python/pants/backend/python/lint/black/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=300, + timeout=240, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/docformatter/BUILD b/src/python/pants/backend/python/lint/docformatter/BUILD index 14a9e0e0fbe..c227a18d48d 100644 --- a/src/python/pants/backend/python/lint/docformatter/BUILD +++ b/src/python/pants/backend/python/lint/docformatter/BUILD @@ -7,7 +7,7 @@ resources(name="lockfile", sources=["lockfile.txt"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=300, + timeout=120, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/flake8/BUILD b/src/python/pants/backend/python/lint/flake8/BUILD index 82e1c0e1fdf..b74e5b007ad 100644 --- a/src/python/pants/backend/python/lint/flake8/BUILD +++ b/src/python/pants/backend/python/lint/flake8/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=300, + timeout=180, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/isort/BUILD b/src/python/pants/backend/python/lint/isort/BUILD index 01882cdb9bf..7c3fb2d2c6d 100644 --- a/src/python/pants/backend/python/lint/isort/BUILD +++ b/src/python/pants/backend/python/lint/isort/BUILD @@ -7,7 +7,7 @@ resources(name="lockfile", sources=["lockfile.txt"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=300, + timeout=120, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/pylint/BUILD b/src/python/pants/backend/python/lint/pylint/BUILD index 2fa173cec0f..276a3da2476 100644 --- a/src/python/pants/backend/python/lint/pylint/BUILD +++ b/src/python/pants/backend/python/lint/pylint/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"], timeout=120) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=360, + timeout=330, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/lint/yapf/BUILD b/src/python/pants/backend/python/lint/yapf/BUILD index e7b44b29e36..280be6b4de6 100644 --- a/src/python/pants/backend/python/lint/yapf/BUILD +++ b/src/python/pants/backend/python/lint/yapf/BUILD @@ -7,7 +7,7 @@ resources(name="lockfile", sources=["lockfile.txt"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=300, + timeout=120, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], ) diff --git a/src/python/pants/backend/python/subsystems/BUILD b/src/python/pants/backend/python/subsystems/BUILD index 8ac3a3b9a27..b207023ab39 100644 --- a/src/python/pants/backend/python/subsystems/BUILD +++ b/src/python/pants/backend/python/subsystems/BUILD @@ -4,4 +4,4 @@ python_library(dependencies=[":lockfiles"]) resources(name="lockfiles", sources=["*_lockfile.txt"]) -python_tests(name="tests", timeout=120) +python_tests(name="tests") diff --git a/src/python/pants/backend/python/typecheck/mypy/BUILD b/src/python/pants/backend/python/typecheck/mypy/BUILD index 085fb041d9d..4d2d0dc4d24 100644 --- a/src/python/pants/backend/python/typecheck/mypy/BUILD +++ b/src/python/pants/backend/python/typecheck/mypy/BUILD @@ -8,7 +8,7 @@ python_tests(name="subsystem_test", sources=["subsystem_test.py"]) python_tests( name="rules_integration_test", sources=["rules_integration_test.py"], - timeout=520, + timeout=480, # We want to make sure the default lockfile works for both macOS and Linux. tags=["platform_specific_behavior"], )