Skip to content
Merged

uv #58

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .buildkite/steps/release-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ __root="$(cd "$(dirname "${__dir}")"/../ && pwd)"

cd "$__root"

python -m venv .venv && source .venv/bin/activate
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env

pip install -e '.[dev]'
# Install dependencies and build
uv sync --all-extras

# It will spit out a tar.gz in ./dist
python -m build
# Build the package
uv build

python -m twine check dist/*

python -m twine upload --skip-existing dist/*
# Check and upload to PyPI
uv run twine check dist/*
uv run twine upload --skip-existing dist/*
32 changes: 18 additions & 14 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,39 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

env:
BUILDKITE_ANALYTICS_TOKEN: ${{ secrets.BUILDKITE_ANALYTICS_TOKEN }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- run: pytest
run: uv sync --all-extras
- name: Run tests
run: uv run pytest

pylint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.python-version }}
version: "latest"
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- run: pylint src/
run: uv sync --all-extras
- name: Run pylint
run: uv run pylint src/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ __pycache__
.direnv/*

build

# uv
.venv/
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
python 3.13.2
uv 0.7.21
37 changes: 21 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,31 @@ The official Python adapter for [Buildkite Test Analytics](https://buildkite.com

1. [Create a test suite](https://buildkite.com/docs/test-analytics), and copy the API token that it gives you.

2. Add `buildkite-test-collector` to your list of dev dependencies in `setup.py`

```python
extras_require={
"dev": [
"buildkite-test-collector"
]
}
2. Add `buildkite-test-collector` to your project dependencies

Using uv:
```sh
uv add --dev buildkite-test-collector
```

Or add it to your `pyproject.toml`:
```toml
[project.optional-dependencies]
dev = [
"buildkite-test-collector"
]
```

3. Set up your API token

Add the `BUIDLKITE_ANALYTICS_TOKEN` environment variable to your build system's environment.
Add the `BUILDKITE_ANALYTICS_TOKEN` environment variable to your build system's environment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦅 👁️


4. 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.
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.

```sh
$ pytest
uv run pytest
```

5. Verify that it works
Expand All @@ -58,22 +63,22 @@ See the [GitHub 'enhancement' issues](https://github.com/buildkite/test-collecto

## ⚒ Developing

After cloning the repository, setup virtual environment (please skip this step if you are using `direnv`):
After cloning the repository, install [uv](https://docs.astral.sh/uv/) if you haven't already:

```bash
python -m venv .venv && source .venv/bin/activate
curl -LsSf https://astral.sh/uv/install.sh | sh
```

then install the dependencies:
Then install the dependencies:

```bash
pip install -e '.[dev]'
uv sync --all-extras
```

And run the tests:

```bash
pytest
uv run pytest
```

Useful resources for developing collectors include the [Buildkite Test Analytics docs](https://buildkite.com/docs/test-analytics) and the [RSpec and Minitest collectors](https://github.com/buildkite/rspec-buildkite-analytics).
Expand Down
29 changes: 29 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "buildkite-test-collector"
version = "1.0.4"
description = "Buildkite Test Engine collector"
readme = "README.md"
requires-python = ">=3.8"
license = "MIT"
authors = [{ name = "Buildkite", email = "support@buildkite.com" }]
classifiers = ["License :: OSI Approved :: MIT License", "Framework :: Pytest"]
dependencies = ["requests>=2", "pytest>=7", "filelock>=3"]

[project.optional-dependencies]
dev = ["mock>=4", "check-manifest", "twine", "responses", "pylint"]

[project.urls]
Homepage = "https://github.com/buildkite/test-collector-python"

[project.entry-points.pytest11]
buildkite-test-collector = "buildkite_test_collector.pytest_plugin"

[tool.hatch.build.targets.wheel]
packages = ["src/buildkite_test_collector"]

[tool.hatch.build.targets.sdist]
include = ["/src", "/tests", "/README.md", "/LICENSE.txt"]
37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

15 changes: 12 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
[tox]
envlist = py36,py37,py38,py39,py310
envlist = py38,py39,py310,py311,py312,py313

[testenv]
deps = pytest
commands = pytest
package = external
package_env = .pkg
deps =
uv
commands =
uv sync --all-extras
uv run pytest

[testenv:.pkg]
deps = uv
commands = uv build
Loading