Skip to content

Commit a020ebb

Browse files
authored
feat(py-client): Set up testing, formatters, linters, CI (#152)
1 parent 2e449e0 commit a020ebb

10 files changed

Lines changed: 392 additions & 56 deletions

File tree

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ jobs:
4747
env:
4848
RUSTDOCFLAGS: -Dwarnings
4949

50+
lint-python:
51+
name: Lint Python
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
58+
59+
- name: Install dependencies
60+
run: uv sync --all-packages --all-groups
61+
62+
- name: Format
63+
run: uv run ruff format
64+
65+
- name: Lint
66+
run: uv run ruff check
67+
68+
- name: Run mypy
69+
run: uv run mypy .
70+
5071
test_all:
5172
name: Test (all features)
5273
runs-on: ubuntu-latest
@@ -89,6 +110,21 @@ jobs:
89110
- name: Run Tests
90111
run: cargo test --workspace --all-features
91112

113+
test-python:
114+
name: Test Python
115+
runs-on: ubuntu-latest
116+
117+
steps:
118+
- uses: actions/checkout@v4
119+
120+
- uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
121+
122+
- name: Install dependencies
123+
run: uv sync --all-packages --all-groups
124+
125+
- name: Run tests
126+
run: uv run pytest python-objectstore-client
127+
92128
docs:
93129
name: Cargo Docs
94130
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ profile.json.gz
1111
.*.sw*
1212

1313
**/__pycache__
14+
/dist

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This pre-commit config is mainly aimed at formatting and linting the Python files in python-objectstore-client.
2+
# However, pre-commit requires this file to be placed at the root of the repository.
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v6.0.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
- id: check-merge-conflict
11+
12+
- repo: local
13+
hooks:
14+
- id: ruff-check
15+
name: ruff check
16+
entry: ruff check
17+
language: system
18+
types_or: [python, pyi]
19+
- id: ruff-format
20+
name: ruff format
21+
entry: ruff format
22+
language: system
23+
types_or: [python, pyi]
24+
- id: mypy
25+
name: mypy
26+
entry: .venv/bin/mypy
27+
language: system
28+
types: [python]

devenv/sync.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from devenv import constants
21
from devenv.lib import config, uv
32

3+
from devenv import constants
4+
45

56
def main(context: dict[str, str]) -> int:
67
reporoot = context["reporoot"]

pyproject.toml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
[project]
22
name = "objectstore"
33
version = "0.1.0"
4-
requires-python = ">=3.13"
4+
requires-python = ">=3.13.1"
55

6-
[[tool.uv.index]]
7-
url = "https://pypi.devinfra.sentry.io/simple"
8-
default = true
6+
[tool.uv]
7+
required-version = "==0.9.3" # keep in sync with devenv/config.ini
98

109
[tool.uv.workspace]
1110
members = [
1211
"python-objectstore-client",
1312
]
1413

1514
[dependency-groups]
16-
dev = ["devservices>=1.2.2"]
15+
dev = [
16+
"devservices>=1.2.2",
17+
"pytest>=8.3.3",
18+
"mypy>=1.17.1",
19+
"ruff>=0.14.2",
20+
"pre-commit>=4.2.0",
21+
]
22+
23+
[tool.ruff.lint]
24+
select = ["E", "F", "I", "UP"] # pycodestyle, pyflakes, isort, pyupgrade
25+
26+
[tool.mypy]
27+
no_implicit_reexport = true
28+
warn_unreachable = true
29+
warn_redundant_casts = true
30+
local_partial_types = true
31+
disallow_any_generics = true
32+
disallow_untyped_defs = true
33+
warn_unused_configs = true

python-objectstore-client/.gitignore

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
# objectstore-client
1+
# Objectstore Client
2+
3+
## Usage
4+
5+
TODO
6+
7+
## Development
8+
9+
### Environment Setup
10+
11+
The considerations for setting up the development environment that can be found in the main [README](../README.md) apply for this package as well.
12+
13+
### Pre-commit hook
14+
15+
A configuration to set up a git pre-commit hook using [pre-commit](https://github.com/pre-commit/pre-commit) is available at the root of the repository.
16+
17+
To install it, run
18+
```sh
19+
pre-commit install
20+
```
21+
22+
The hook will automatically run some checks before every commit, including the linters and formatters we run in CI.

python-objectstore-client/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name = "objectstore-client"
33
version = "0.1.0"
44
description = "Python client for the Sentry Objectstore service"
55
readme = "README.md"
6-
requires-python = ">=3.11.11"
6+
requires-python = ">=3.13.1"
77
dependencies = []
88

99
[build-system]
10-
requires = ["uv_build==0.9.3"] # must match the version specified in devenv/config.ini
10+
requires = ["uv_build"]
1111
build-backend = "uv_build"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def test_imports() -> None:
2+
import objectstore_client
3+
4+
_ = objectstore_client

uv.lock

Lines changed: 275 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)