Buildkite Test Engine collector
Project description
Buildkite Test Collector for Python
The official Python adapter for Buildkite Test Engine which collects information about your tests.
Supported python versions: >=3.9
⚒ Supported test frameworks: pytest.
📦 Supported CI systems: Buildkite, GitHub Actions, CircleCI, and others via the BUILDKITE_ANALYTICS_* environment variables.
👉 Installing
-
Create a test suite, and copy the API token that it gives you.
-
Add
buildkite-test-collectorto your project dependencies
Using uv:
uv add --dev buildkite-test-collector
Or add it to your pyproject.toml:
[project.optional-dependencies]
dev = [
"buildkite-test-collector"
]
- Set up your API token
Add the BUILDKITE_ANALYTICS_TOKEN environment variable to your build system's environment.
- Run your tests
Run your tests like normal. Note that we attempt to detect the presence of several common CI environments, however if this fails you can set the CI environment variable to any value and it will work.
uv run pytest
- Verify that it works
If all is well, you should see the test run in the Test Engine section of the Buildkite dashboard.
🏷️ Filtering Tests by Tags
You can filter which tests to run based on execution tags using the --tag-filters option.
First, mark your tests with execution tags:
import pytest
@pytest.mark.execution_tag("color", "red")
def test_red_feature():
assert True
@pytest.mark.execution_tag("color", "blue")
def test_blue_feature():
assert True
Then filter tests by tag using the --tag-filters option with key:value format:
# Run only tests tagged with color:red
pytest --tag-filters "color:red"
# Run only tests tagged with color:blue
pytest --tag-filters "color:blue"
Note: The --tag-filters option performs exact key:value matching. Only tests with the specified tag will be selected.
🎢 Tracing
Buildkite Test Engine has support for tracing potentially slow operations within your tests, and can collect span data of four types: http, sql, sleep and annotations. This is documented as part of our public JSON API so anyone can instrument any code to send this data.
This library supports the ability to transmit tracing information to your Test Engine output by using the new spans pytest fixture. See the SpanCollector documentation for more information.
You may also need to manually capture the data you wish to trace for your use case. For examples of how we've done this in our Ruby test collector, see:
- Instrumenting Rails to capture sql data
- Monkey patching to various libraries to capture http requests
- Monkey patching for sleep
Note: the Ruby test collector is the only Test Engine collector that automatically captures and transmits span data. This Python collector can transmit information, but data capture must be done manually at this time.
🔜 Roadmap
See the GitHub 'enhancement' issues for planned features. Pull requests are always welcome, and we’ll give you feedback and guidance if you choose to contribute 💚
⚒ Developing
After cloning the repository, install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
Then install the dependencies:
uv sync --all-extras
And run the tests:
uv run pytest
Useful resources for developing collectors include the Buildkite Test Engine docs and the RSpec and Minitest collectors.
👩💻 Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/buildkite/test-collector-python
🚀 Releasing
- Open a new PR bumping the version number in
pyproject.toml, make sure the PR title contains[release]. - Get the PR approved and merged, this will trigger the release pipeline.
- (Optional) In the event of step 3 failure, run
.buildkite/steps/release-pypilocally with your own credentials. - Create a new github release for prosperity, you can create a tag as you create the release.
📜 License
The package is available as open source under the terms of the MIT License.
🤙 Thanks
Thanks to the folks at Alembic for building and maintaining this package.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file buildkite_test_collector-1.3.1.tar.gz.
File metadata
- Download URL: buildkite_test_collector-1.3.1.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd9047a918a3426397bf6fc0d3b054e84dadb90684e756fe96f7913e582a32ac
|
|
| MD5 |
d384c99fcf34452ad253851fbd018caa
|
|
| BLAKE2b-256 |
ae7ff5d6120035498e5fd4bdff6120e2126820d84530484be11f02795f2aa312
|
File details
Details for the file buildkite_test_collector-1.3.1-py3-none-any.whl.
File metadata
- Download URL: buildkite_test_collector-1.3.1-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b66bc665058b54b96a85d9b9740b8acb31fd684ce332df8270da6f449c7af41
|
|
| MD5 |
ecdc365dc3b56ca65c39475b0312350d
|
|
| BLAKE2b-256 |
be8e948665dbc424ab9713e37ecc4ba3ded13cf300d2b11a69957795f32d5bb1
|