pytest-shard-cloudc 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. pytest_shard_cloudc-0.1.2/.circleci/config.yml +17 -0
  2. pytest_shard_cloudc-0.1.2/.github/workflows/ci.yml +28 -0
  3. pytest_shard_cloudc-0.1.2/.github/workflows/publish-testpypi.yml +50 -0
  4. pytest_shard_cloudc-0.1.2/.github/workflows/publish.yml +50 -0
  5. pytest_shard_cloudc-0.1.2/.gitignore +140 -0
  6. pytest_shard_cloudc-0.1.2/LICENSE +8 -0
  7. pytest_shard_cloudc-0.1.2/PKG-INFO +162 -0
  8. pytest_shard_cloudc-0.1.2/README.md +129 -0
  9. pytest_shard_cloudc-0.1.2/README.zh-TW.md +129 -0
  10. pytest_shard_cloudc-0.1.2/demo/demo30_tests/__init__.py +0 -0
  11. pytest_shard_cloudc-0.1.2/demo/demo30_tests/conftest.py +5 -0
  12. pytest_shard_cloudc-0.1.2/demo/demo30_tests/test_group_a.py +44 -0
  13. pytest_shard_cloudc-0.1.2/demo/demo30_tests/test_group_b.py +44 -0
  14. pytest_shard_cloudc-0.1.2/demo/demo30_tests/test_group_c.py +44 -0
  15. pytest_shard_cloudc-0.1.2/demo/demo_duration_tests/__init__.py +0 -0
  16. pytest_shard_cloudc-0.1.2/demo/demo_duration_tests/conftest.py +34 -0
  17. pytest_shard_cloudc-0.1.2/demo/demo_duration_tests/test_workload.py +64 -0
  18. pytest_shard_cloudc-0.1.2/demo/demo_tests/__init__.py +0 -0
  19. pytest_shard_cloudc-0.1.2/demo/demo_tests/conftest.py +5 -0
  20. pytest_shard_cloudc-0.1.2/demo/demo_tests/test_arithmetic.py +81 -0
  21. pytest_shard_cloudc-0.1.2/demo/demo_tests/test_collections.py +102 -0
  22. pytest_shard_cloudc-0.1.2/demo/demo_tests/test_comparisons.py +86 -0
  23. pytest_shard_cloudc-0.1.2/demo/demo_tests/test_strings.py +79 -0
  24. pytest_shard_cloudc-0.1.2/demo/demo_tests/test_types.py +81 -0
  25. pytest_shard_cloudc-0.1.2/doc/allure-integration.md +476 -0
  26. pytest_shard_cloudc-0.1.2/doc/allure-integration.zh-TW.md +476 -0
  27. pytest_shard_cloudc-0.1.2/doc/demo-sessions.md +17 -0
  28. pytest_shard_cloudc-0.1.2/doc/demo-sessions.zh-TW.md +17 -0
  29. pytest_shard_cloudc-0.1.2/doc/image/local_test_with_3_shards_30_cases.png +0 -0
  30. pytest_shard_cloudc-0.1.2/doc/image/without_test_durations_file.png +0 -0
  31. pytest_shard_cloudc-0.1.2/doc/image/wtih_test_durations_file.png +0 -0
  32. pytest_shard_cloudc-0.1.2/doc/sharding-modes.md +131 -0
  33. pytest_shard_cloudc-0.1.2/doc/sharding-modes.zh-TW.md +131 -0
  34. pytest_shard_cloudc-0.1.2/noxfile.py +344 -0
  35. pytest_shard_cloudc-0.1.2/pylintrc +24 -0
  36. pytest_shard_cloudc-0.1.2/pyproject.toml +72 -0
  37. pytest_shard_cloudc-0.1.2/pytest_shard/__init__.py +3 -0
  38. pytest_shard_cloudc-0.1.2/pytest_shard/pytest_shard.py +252 -0
  39. pytest_shard_cloudc-0.1.2/tests/__init__.py +0 -0
  40. pytest_shard_cloudc-0.1.2/tests/test_allure_integration.py +98 -0
  41. pytest_shard_cloudc-0.1.2/tests/test_pytest_shard.py +324 -0
@@ -0,0 +1,17 @@
1
+ version: 2.1
2
+
3
+ executors:
4
+ my-executor:
5
+ docker:
6
+ - image: cimg/python:3.11
7
+ environment:
8
+ NUM_CPUS: 2 # more CPUs visible but we're throttled to 2, which breaks auto-detection of parallelism
9
+
10
+ jobs:
11
+ build:
12
+ executor: my-executor
13
+
14
+ steps:
15
+ - checkout
16
+ - run: python -m pip install -e .[dev]
17
+ - run: nox --no-venv -s tests -s shard-0 -s shard-1 -s lint -s typing
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: pip install -e ".[dev]"
26
+
27
+ - name: Run tests and lint
28
+ run: nox --no-venv -s tests -s shard-0 -s shard-1 -s lint -s typing
@@ -0,0 +1,50 @@
1
+ name: Publish to TestPyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ build:
8
+ name: Build distributions
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.11"
17
+
18
+ - name: Install build tools
19
+ run: |
20
+ python -m pip install --upgrade build
21
+
22
+ - name: Build wheel and sdist
23
+ run: |
24
+ python -m build
25
+
26
+ - name: Upload dist artifacts
27
+ uses: actions/upload-artifact@v4
28
+ with:
29
+ name: python-package-distributions
30
+ path: dist/
31
+
32
+ publish:
33
+ name: Publish to TestPyPI
34
+ needs: build
35
+ runs-on: ubuntu-latest
36
+ environment: testpypi
37
+ permissions:
38
+ id-token: write
39
+
40
+ steps:
41
+ - name: Download dist artifacts
42
+ uses: actions/download-artifact@v4
43
+ with:
44
+ name: python-package-distributions
45
+ path: dist/
46
+
47
+ - name: Publish to TestPyPI
48
+ uses: pypa/gh-action-pypi-publish@release/v1
49
+ with:
50
+ repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,50 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build:
10
+ name: Build distributions
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.11"
19
+
20
+ - name: Install build tools
21
+ run: |
22
+ python -m pip install --upgrade build
23
+
24
+ - name: Build wheel and sdist
25
+ run: |
26
+ python -m build
27
+
28
+ - name: Upload dist artifacts
29
+ uses: actions/upload-artifact@v4
30
+ with:
31
+ name: python-package-distributions
32
+ path: dist/
33
+
34
+ publish:
35
+ name: Publish to PyPI
36
+ needs: build
37
+ runs-on: ubuntu-latest
38
+ environment: pypi
39
+ permissions:
40
+ id-token: write # required for Trusted Publishing (OIDC)
41
+
42
+ steps:
43
+ - name: Download dist artifacts
44
+ uses: actions/download-artifact@v4
45
+ with:
46
+ name: python-package-distributions
47
+ path: dist/
48
+
49
+ - name: Publish to PyPI
50
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,140 @@
1
+ # Local development artifacts
2
+ REFACTOR_PLAN.md
3
+ logs/
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ pip-wheel-metadata/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py,cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # celery beat schedule file
99
+ celerybeat-schedule
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # PyCharm project settings
124
+ .idea/
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # pytype
132
+ .pytype/
133
+
134
+ # Pyre type checker
135
+ .pyre/
136
+
137
+ # Allure
138
+ allure-results/
139
+ allure-report/
140
+ allure-report-*/
@@ -0,0 +1,8 @@
1
+ Copyright 2019 Adam Gleave
2
+ Copyright 2026 Cloud Chen
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-shard-cloudc
3
+ Version: 0.1.2
4
+ Summary: Shard tests to support parallelism across multiple machines.
5
+ Project-URL: Homepage, https://github.com/wolke1007/pytest-shard-cloudc
6
+ Project-URL: Repository, https://github.com/wolke1007/pytest-shard-cloudc
7
+ Project-URL: Original Project, https://github.com/AdamGleave/pytest-shard
8
+ Author-email: Cloud Chen <wolke1007@users.noreply.github.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ci,distributed,parallel,pytest,shard,testing
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: Pytest
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Testing
23
+ Requires-Python: >=3.11
24
+ Requires-Dist: pytest
25
+ Provides-Extra: dev
26
+ Requires-Dist: allure-pytest; extra == 'dev'
27
+ Requires-Dist: build; extra == 'dev'
28
+ Requires-Dist: hypothesis; extra == 'dev'
29
+ Requires-Dist: mypy; extra == 'dev'
30
+ Requires-Dist: nox; extra == 'dev'
31
+ Requires-Dist: ruff; extra == 'dev'
32
+ Description-Content-Type: text/markdown
33
+
34
+ [![PyPI version](https://badge.fury.io/py/pytest-shard-cloudc.svg)](https://badge.fury.io/py/pytest-shard-cloudc)
35
+
36
+ [繁體中文](README.zh-TW.md) | **English**
37
+
38
+ # pytest-shard
39
+
40
+ > **This is a fork of [AdamGleave/pytest-shard](https://github.com/AdamGleave/pytest-shard) by [Cloud Chen](https://github.com/wolke1007).**
41
+ > Modifications include: Allure report integration, multi-shard result merging, nox-based tooling, and modernized packaging with `pyproject.toml`.
42
+
43
+ `pytest-shard` splits your test suite across multiple machines or CI workers at individual test-case granularity. By default it sorts tests by node ID and assigns them round-robin across shards, so parallelism works even when all tests live in a single file or a single parameterized method.
44
+
45
+ ## How It Works
46
+
47
+ See [Sharding Modes](doc/sharding-modes.md) for separate diagrams that explain how `roundrobin`, `hash`, and `duration` assign tests to shards.
48
+
49
+ ## What it does
50
+
51
+ | Capability | Description |
52
+ |------------|-------------|
53
+ | **Round-robin sharding** (default) | Sorts tests by node ID and interleaves across shards, guaranteeing shard counts differ by at most 1 |
54
+ | **Hash-based sharding** | Assigns each test deterministically via `SHA-256(node_id) % N` — per-test stable even as the suite grows |
55
+ | **Duration-based sharding** | Greedy bin-packing using a `.test_durations` file (compatible with pytest-split) to minimise the longest shard |
56
+ | **Zero configuration** | Just add `--shard-id` and `--num-shards` — no config files, no test ordering required |
57
+ | **Any granularity** | Splits at the individual test level, not at the file or class level |
58
+ | **CI-agnostic** | Works with GitHub Actions, CircleCI, Travis CI, or any system that runs parallel jobs |
59
+ | **Allure integration** | Collect results per shard, merge them, and view a unified Timeline report |
60
+
61
+ ## Documentation
62
+
63
+ | Guide | Description |
64
+ |-------|-------------|
65
+ | [Sharding Modes](doc/sharding-modes.md) | Detailed behavior of `roundrobin`, `hash`, and `duration`, including `.test_durations`, verbose shard reports, and mode selection guidance. |
66
+ | [Demo Sessions](doc/demo-sessions.md) | How contributors can run the bundled demo suites locally with `nox`. |
67
+ | [Allure Report Integration](doc/allure-integration.md) | How to collect Allure results across shards, merge them into one report, run shards in parallel locally, and integrate with GitHub Actions / CircleCI. Includes a worked example with 30 tests across 3 parallel shards and a Timeline screenshot. |
68
+
69
+ ## Quick start
70
+
71
+ ### Installation
72
+
73
+ ```bash
74
+ pip install pytest-shard-cloudc
75
+ ```
76
+
77
+ ### Split tests across N machines
78
+
79
+ ```bash
80
+ # Machine 0
81
+ pytest --shard-id=0 --num-shards=3
82
+
83
+ # Machine 1
84
+ pytest --shard-id=1 --num-shards=3
85
+
86
+ # Machine 2
87
+ pytest --shard-id=2 --num-shards=3
88
+ ```
89
+
90
+ Each machine runs roughly 1/N of the test suite. Together they cover 100% of tests.
91
+
92
+ ### Choose a sharding mode
93
+
94
+ ```bash
95
+ # Round-robin (default) — guaranteed count balance
96
+ pytest --shard-id=0 --num-shards=3 --shard-mode=roundrobin
97
+
98
+ # Hash — per-test stable assignment, stateless
99
+ pytest --shard-id=0 --num-shards=3 --shard-mode=hash
100
+
101
+ # Duration — bin-packing by recorded test times, minimises longest shard
102
+ pytest --shard-id=0 --num-shards=3 --shard-mode=duration --durations-path=.test_durations
103
+ ```
104
+
105
+ See [Sharding Modes](doc/sharding-modes.md) for detailed trade-offs, `.test_durations` generation, and mode selection guidance.
106
+
107
+ ### GitHub Actions example
108
+
109
+ ```yaml
110
+ jobs:
111
+ test:
112
+ runs-on: ubuntu-latest
113
+ strategy:
114
+ matrix:
115
+ shard_id: [0, 1, 2]
116
+ steps:
117
+ - uses: actions/checkout@v4
118
+ - uses: actions/setup-python@v5
119
+ with: { python-version: "3.11" }
120
+ - run: pip install pytest-shard-cloudc
121
+ - run: pytest --shard-id=${{ matrix.shard_id }} --num-shards=3
122
+ ```
123
+
124
+ ### CircleCI example
125
+
126
+ ```yaml
127
+ jobs:
128
+ test:
129
+ parallelism: 3
130
+ steps:
131
+ - run: pytest --shard-id=${CIRCLE_NODE_INDEX} --num-shards=${CIRCLE_NODE_TOTAL}
132
+ ```
133
+
134
+ ## More guides
135
+
136
+ - For mode behavior, `.test_durations`, verbose shard reports, and selection strategy, see [Sharding Modes](doc/sharding-modes.md).
137
+ - For contributor-facing demo commands, see [Demo Sessions](doc/demo-sessions.md).
138
+ - For report generation and parallel execution screenshots, see [Allure Report Integration](doc/allure-integration.md).
139
+
140
+ ## Alternatives
141
+
142
+ [pytest-xdist](https://github.com/pytest-dev/pytest-xdist) parallelizes tests across CPU cores on a single machine and supports remote workers. A common pattern is to combine both: use `pytest-shard` to split work across CI nodes, and `pytest-xdist` to parallelize within each node.
143
+
144
+ [pytest-circleci-parallelized](https://github.com/ryanwilsonperkin/pytest-circleci-parallelized) splits by test run time rather than test count, but only at class granularity and only for CircleCI.
145
+
146
+ ## Contributions
147
+
148
+ Contributions are welcome. The package requires Python 3.11 or newer. Install the development toolchain and run the full check suite:
149
+
150
+ ```bash
151
+ pip install -e .[dev]
152
+ nox
153
+ ```
154
+
155
+ The Allure integration test also requires the `allure` CLI to be available on `PATH`.
156
+
157
+ ## License
158
+
159
+ MIT licensed.
160
+
161
+ Original work Copyright 2019 Adam Gleave.
162
+ Modifications Copyright 2026 Cloud Chen.
@@ -0,0 +1,129 @@
1
+ [![PyPI version](https://badge.fury.io/py/pytest-shard-cloudc.svg)](https://badge.fury.io/py/pytest-shard-cloudc)
2
+
3
+ [繁體中文](README.zh-TW.md) | **English**
4
+
5
+ # pytest-shard
6
+
7
+ > **This is a fork of [AdamGleave/pytest-shard](https://github.com/AdamGleave/pytest-shard) by [Cloud Chen](https://github.com/wolke1007).**
8
+ > Modifications include: Allure report integration, multi-shard result merging, nox-based tooling, and modernized packaging with `pyproject.toml`.
9
+
10
+ `pytest-shard` splits your test suite across multiple machines or CI workers at individual test-case granularity. By default it sorts tests by node ID and assigns them round-robin across shards, so parallelism works even when all tests live in a single file or a single parameterized method.
11
+
12
+ ## How It Works
13
+
14
+ See [Sharding Modes](doc/sharding-modes.md) for separate diagrams that explain how `roundrobin`, `hash`, and `duration` assign tests to shards.
15
+
16
+ ## What it does
17
+
18
+ | Capability | Description |
19
+ |------------|-------------|
20
+ | **Round-robin sharding** (default) | Sorts tests by node ID and interleaves across shards, guaranteeing shard counts differ by at most 1 |
21
+ | **Hash-based sharding** | Assigns each test deterministically via `SHA-256(node_id) % N` — per-test stable even as the suite grows |
22
+ | **Duration-based sharding** | Greedy bin-packing using a `.test_durations` file (compatible with pytest-split) to minimise the longest shard |
23
+ | **Zero configuration** | Just add `--shard-id` and `--num-shards` — no config files, no test ordering required |
24
+ | **Any granularity** | Splits at the individual test level, not at the file or class level |
25
+ | **CI-agnostic** | Works with GitHub Actions, CircleCI, Travis CI, or any system that runs parallel jobs |
26
+ | **Allure integration** | Collect results per shard, merge them, and view a unified Timeline report |
27
+
28
+ ## Documentation
29
+
30
+ | Guide | Description |
31
+ |-------|-------------|
32
+ | [Sharding Modes](doc/sharding-modes.md) | Detailed behavior of `roundrobin`, `hash`, and `duration`, including `.test_durations`, verbose shard reports, and mode selection guidance. |
33
+ | [Demo Sessions](doc/demo-sessions.md) | How contributors can run the bundled demo suites locally with `nox`. |
34
+ | [Allure Report Integration](doc/allure-integration.md) | How to collect Allure results across shards, merge them into one report, run shards in parallel locally, and integrate with GitHub Actions / CircleCI. Includes a worked example with 30 tests across 3 parallel shards and a Timeline screenshot. |
35
+
36
+ ## Quick start
37
+
38
+ ### Installation
39
+
40
+ ```bash
41
+ pip install pytest-shard-cloudc
42
+ ```
43
+
44
+ ### Split tests across N machines
45
+
46
+ ```bash
47
+ # Machine 0
48
+ pytest --shard-id=0 --num-shards=3
49
+
50
+ # Machine 1
51
+ pytest --shard-id=1 --num-shards=3
52
+
53
+ # Machine 2
54
+ pytest --shard-id=2 --num-shards=3
55
+ ```
56
+
57
+ Each machine runs roughly 1/N of the test suite. Together they cover 100% of tests.
58
+
59
+ ### Choose a sharding mode
60
+
61
+ ```bash
62
+ # Round-robin (default) — guaranteed count balance
63
+ pytest --shard-id=0 --num-shards=3 --shard-mode=roundrobin
64
+
65
+ # Hash — per-test stable assignment, stateless
66
+ pytest --shard-id=0 --num-shards=3 --shard-mode=hash
67
+
68
+ # Duration — bin-packing by recorded test times, minimises longest shard
69
+ pytest --shard-id=0 --num-shards=3 --shard-mode=duration --durations-path=.test_durations
70
+ ```
71
+
72
+ See [Sharding Modes](doc/sharding-modes.md) for detailed trade-offs, `.test_durations` generation, and mode selection guidance.
73
+
74
+ ### GitHub Actions example
75
+
76
+ ```yaml
77
+ jobs:
78
+ test:
79
+ runs-on: ubuntu-latest
80
+ strategy:
81
+ matrix:
82
+ shard_id: [0, 1, 2]
83
+ steps:
84
+ - uses: actions/checkout@v4
85
+ - uses: actions/setup-python@v5
86
+ with: { python-version: "3.11" }
87
+ - run: pip install pytest-shard-cloudc
88
+ - run: pytest --shard-id=${{ matrix.shard_id }} --num-shards=3
89
+ ```
90
+
91
+ ### CircleCI example
92
+
93
+ ```yaml
94
+ jobs:
95
+ test:
96
+ parallelism: 3
97
+ steps:
98
+ - run: pytest --shard-id=${CIRCLE_NODE_INDEX} --num-shards=${CIRCLE_NODE_TOTAL}
99
+ ```
100
+
101
+ ## More guides
102
+
103
+ - For mode behavior, `.test_durations`, verbose shard reports, and selection strategy, see [Sharding Modes](doc/sharding-modes.md).
104
+ - For contributor-facing demo commands, see [Demo Sessions](doc/demo-sessions.md).
105
+ - For report generation and parallel execution screenshots, see [Allure Report Integration](doc/allure-integration.md).
106
+
107
+ ## Alternatives
108
+
109
+ [pytest-xdist](https://github.com/pytest-dev/pytest-xdist) parallelizes tests across CPU cores on a single machine and supports remote workers. A common pattern is to combine both: use `pytest-shard` to split work across CI nodes, and `pytest-xdist` to parallelize within each node.
110
+
111
+ [pytest-circleci-parallelized](https://github.com/ryanwilsonperkin/pytest-circleci-parallelized) splits by test run time rather than test count, but only at class granularity and only for CircleCI.
112
+
113
+ ## Contributions
114
+
115
+ Contributions are welcome. The package requires Python 3.11 or newer. Install the development toolchain and run the full check suite:
116
+
117
+ ```bash
118
+ pip install -e .[dev]
119
+ nox
120
+ ```
121
+
122
+ The Allure integration test also requires the `allure` CLI to be available on `PATH`.
123
+
124
+ ## License
125
+
126
+ MIT licensed.
127
+
128
+ Original work Copyright 2019 Adam Gleave.
129
+ Modifications Copyright 2026 Cloud Chen.