From eed3ffc38e1dbfee5e03e218b16d0b946b1340bc Mon Sep 17 00:00:00 2001 From: Konstantinos Smanis Date: Tue, 31 Oct 2023 17:09:11 +0200 Subject: [PATCH] ci: parallelize tests --- .github/workflows/build.yml | 2 +- poetry.lock | 36 +++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + tests/test_git.py | 6 +++--- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 691bff4..f2ee21f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,7 +105,7 @@ jobs: - name: Install root package run: poetry install --no-interaction --only-root -v - name: Run pytest - run: poetry run pytest --color=yes --cov-config=pyproject.toml --with-functional + run: poetry run pytest --color=yes --cov-config=pyproject.toml --numprocesses=8 --with-functional - name: Upload coverage report uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 - name: Run SonarCloud scanner diff --git a/poetry.lock b/poetry.lock index d7e9f0f..2b44139 100644 --- a/poetry.lock +++ b/poetry.lock @@ -365,6 +365,20 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "2.0.2" +description = "execnet: rapid multi-Python deployment" +optional = false +python-versions = ">=3.7" +files = [ + {file = "execnet-2.0.2-py3-none-any.whl", hash = "sha256:88256416ae766bc9e8895c76a87928c0012183da3cc4fc18016e6f050e025f41"}, + {file = "execnet-2.0.2.tar.gz", hash = "sha256:cc59bc4423742fd71ad227122eb0dd44db51efb3dc4095b45ac9a08c770096af"}, +] + +[package.extras] +testing = ["hatch", "pre-commit", "pytest", "tox"] + [[package]] name = "filelock" version = "3.13.1" @@ -1025,6 +1039,26 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +[[package]] +name = "pytest-xdist" +version = "3.3.1" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-xdist-3.3.1.tar.gz", hash = "sha256:d5ee0520eb1b7bcca50a60a518ab7a7707992812c578198f8b44fdfac78e8c93"}, + {file = "pytest_xdist-3.3.1-py3-none-any.whl", hash = "sha256:ff9daa7793569e6a68544850fd3927cd257cc03a7ef76c95e86915355e82b5f2"}, +] + +[package.dependencies] +execnet = ">=1.1" +pytest = ">=6.2.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-gitlab" version = "3.15.0" @@ -1389,4 +1423,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "9d6319ba9f07177ba078c31265fffb471be6193dcff3d7c53edf4446b6a87a70" +content-hash = "1f8c36149db58885d903733ce9bd9604b482e9b69adf1e9e827a7dd1d1c5e0fb" diff --git a/pyproject.toml b/pyproject.toml index 9e24ae9..ef45342 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,6 +68,7 @@ python-semantic-release = "^8.3.0" [tool.poetry.group.test.dependencies] pip-tools = "^7.3.0" pytest-cov = "^4.1.0" +pytest-xdist = "^3.3.1" [tool.poetry.scripts] pip-autocompile = "pipautocompile.main:cli" diff --git a/tests/test_git.py b/tests/test_git.py index 5a8f70d..bd6881f 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -26,11 +26,11 @@ def test_working_tree_bare(tmp_path: Path) -> None: argvalues=( ( "git_repo_factory", - {"."}, + ["."], ), ( "git_superproject_factory", - {"superproject", "submodule", "superproject/submodule"}, + ["superproject", "submodule", "superproject/submodule"], ), ), ids=lambda argvalue: repr(argvalue), @@ -39,7 +39,7 @@ def test_working_tree( request: pytest.FixtureRequest, tmp_path: Path, repo_factory_fixture: str, - working_trees: set[str], + working_trees: list[str], ) -> None: repo_factory = request.getfixturevalue(repo_factory_fixture) repo_factory(tmp_path)