Skip to content

Commit 2a4c0b7

Browse files
committed
ci: Move to uv, add Renovate configuration
1 parent 5cba250 commit 2a4c0b7

File tree

10 files changed

+1391
-1824
lines changed

10 files changed

+1391
-1824
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- uses: actions/setup-python@v4
19+
- name: Set up Python
20+
uses: astral-sh/setup-uv@v6
2021
with:
21-
python-version: 3.12
22-
23-
- name: Install Poetry
24-
run: pipx install poetry
22+
enable-cache: true
2523

2624
- name: Build Package
27-
run: poetry build
25+
run: uv build
2826

2927
- uses: actions/upload-artifact@v4
3028
with:

.github/workflows/python-test.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,12 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v4
3939

40-
- uses: actions/setup-python@v4
40+
- name: Set up Python
41+
uses: astral-sh/setup-uv@v6
4142
with:
43+
enable-cache: true
4244
python-version: ${{ matrix.python-version }}
4345

44-
- name: Install Poetry
45-
run: pipx install poetry
46-
47-
- name: Install Dependencies
48-
env:
49-
opts: --with dev
50-
run: make install-packages
51-
5246
- name: Check for missing migrations
5347
env:
5448
opts: --no-input --dry-run --check

.pre-commit-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ repos:
88
args: [--fix]
99
# Run the formatter.
1010
- id: ruff-format
11-
- repo: https://github.com/python-poetry/poetry
12-
rev: 2.2.1
11+
- repo: https://github.com/astral-sh/uv-pre-commit
12+
rev: 0.9.7
1313
hooks:
14-
- id: poetry-check
15-
- id: poetry-lock
14+
- id: uv-lock
1615
- repo: https://github.com/pre-commit/pre-commit-hooks
1716
rev: v6.0.0
1817
hooks:
@@ -24,11 +23,11 @@ repos:
2423
- id: python-typecheck
2524
name: python-typecheck
2625
language: system
27-
entry: poetry run mypy .
26+
entry: make typecheck
2827
require_serial: true
2928
pass_filenames: false
3029
types: [python]
3130

3231
ci:
33-
skip: [python-typecheck, poetry-lock]
32+
skip: [python-typecheck, uv-lock]
3433
autoupdate_commit_msg: "ci: pre-commit autoupdate"

Makefile

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,66 @@
22

33
DOTENV_OVERRIDE_FILE ?= .env
44

5-
POETRY_VERSION ?= 2.1.3
6-
75
COMPOSE_FILE ?= docker/docker-compose.local.yml
86
COMPOSE_PROJECT_NAME ?= flagsmith-common
7+
UV_ALL_EXTRAS ?= true
98

109
-include $(DOTENV_OVERRIDE_FILE)
1110

12-
.PHONY: install-pip
13-
install-pip:
14-
python -m pip install --upgrade pip
11+
.PHONY: install-packages
12+
install-packages: ## Install all required packages
13+
uv sync $(opts)
1514

16-
.PHONY: install-poetry
17-
install-poetry:
18-
curl -sSL https://install.python-poetry.org | python3 - --version ${POETRY_VERSION}
15+
.PHONY: install-pre-commit ## Install pre-commit hooks
16+
install-pre-commit:
17+
uv run pre-commit install
1918

20-
.PHONY: install-packages
21-
install-packages:
22-
poetry install $(opts)
19+
.PHONY: ensure-dotenv
20+
ensure-dotenv: ## Create an .env file suitable for running tests
21+
@if [ ! -f .env ]; then cp .env-ci .env; echo ".env file created from .env-ci. Please update it with your settings."; fi
2322

2423
.PHONY: install
25-
install: install-pip install-poetry install-packages
24+
install: install-packages install-pre-commit ensure-dotenv ## Ensure the environment is set up
2625

2726
.PHONY: lint
28-
lint:
29-
poetry run pre-commit run -a
27+
lint: ## Run linters
28+
uv run pre-commit run --all-files
3029

3130
.PHONY: docker-up
32-
docker-up:
31+
docker-up: ## Start Docker containers
3332
docker compose up --force-recreate --remove-orphans -d
3433
docker compose ps
3534

3635
.PHONY: docker-down
37-
docker-down:
36+
docker-down: ## Stop Docker containers
3837
docker compose down
3938

4039
.PHONY: test
41-
test:
42-
poetry run pytest $(opts)
40+
test: docker-up ## Run all tests
41+
uv run pytest $(opts)
4342

4443
.PHONY: typecheck
45-
typecheck:
46-
poetry run mypy .
44+
typecheck: ## Run mypy
45+
uv run mypy src tests
4746

4847
.PHONY: django-make-migrations
49-
django-make-migrations:
50-
poetry run python manage.py waitfordb
51-
poetry run python manage.py makemigrations $(opts)
48+
django-make-migrations: ## Create new migrations based on the changes detected to your models
49+
uv run python manage.py waitfordb
50+
uv run python manage.py makemigrations $(opts)
5251

5352
.PHONY: django-squash-migrations
54-
django-squash-migrations:
55-
poetry run python manage.py waitfordb
56-
poetry run python manage.py squashmigrations $(opts)
53+
django-squash-migrations: ## Squash migrations for apps
54+
uv run python manage.py waitfordb
55+
uv run python manage.py squashmigrations $(opts)
5756

5857
.PHONY: django-migrate
59-
django-migrate:
60-
poetry run python manage.py waitfordb
61-
poetry run python manage.py migrate
62-
poetry run python manage.py createcachetable
58+
django-migrate: ## Apply migrations to the database
59+
uv run python manage.py waitfordb
60+
uv run python manage.py migrate
61+
uv run python manage.py createcachetable
62+
63+
help:
64+
@echo "Usage: make [target]"
65+
@echo ""
66+
@echo "Available targets:"
67+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

README.md

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,36 @@
44

55
Flagsmith's common library
66

7-
### Development Setup
7+
## Local development
88

9-
This project uses [Poetry](https://python-poetry.org/) for dependency management and includes a Makefile to simplify common development tasks.
9+
The project assumes the following tools installed:
1010

11-
#### Prerequisites
11+
- [uv](https://github.com/astral-sh/uv)
12+
- [GNU Make](https://www.gnu.org/software/make/)
1213

13-
- Python >= 3.11
14-
- Make
14+
To list available Makefile targets, run `make help`.
1515

16-
#### Installation
17-
18-
You can set up your development environment using the provided Makefile:
19-
20-
```bash
21-
# Install everything (pip, poetry, and project dependencies)
22-
make install
23-
24-
# Individual installation steps are also available
25-
make install-pip # Upgrade pip
26-
make install-poetry # Install Poetry
27-
make install-packages # Install project dependencies
28-
```
29-
30-
#### Development
16+
To set up local development environment, run `make install`.
3117

32-
Run linting checks using pre-commit:
18+
To run linters, run `make lint`.
3319

34-
```bash
35-
make lint
36-
```
37-
38-
Additional options can be passed to the `install-packages` target:
39-
40-
```bash
41-
# Install with development dependencies
42-
make install-packages opts="--with dev"
43-
44-
# Install with specific extras
45-
make install-packages opts="--extras 'feature1 feature2'"
46-
```
20+
To run tests, run `make test`.
4721

4822
### Usage
4923

5024
#### Installation
5125

52-
1. `poetry add flagsmith-common`
26+
1. Install all runtime packages: `uv add flagsmith-common[common-core,task-processor]`
5327

54-
2. `poetry add --G dev flagsmith-common[test-tools]` — this will enable the Pytest fixtures. Skipping this step will make Pytest collection fail due to missing dependencies.
28+
2. To enable the Pytest fixtures, run `uv add --G dev flagsmith-common[test-tools]`. Skipping this step will make Pytest collection fail due to missing dependencies.
5529

5630
3. Make sure `"common.core"` is in the `INSTALLED_APPS` of your settings module.
5731
This enables the `manage.py flagsmith` commands.
5832

59-
4. Add `"common.gunicorn.middleware.RouteLoggerMiddleware"` to `MIDDLEWARE` in your settings module.
33+
1. Add `"common.gunicorn.middleware.RouteLoggerMiddleware"` to `MIDDLEWARE` in your settings module.
6034
This enables the `route` label for Prometheus HTTP metrics.
6135

62-
5. To enable the `/metrics` endpoint, set the `PROMETHEUS_ENABLED` setting to `True`.
36+
1. To enable the `/metrics` endpoint, set the `PROMETHEUS_ENABLED` setting to `True`.
6337

6438
#### Test tools
6539

0 commit comments

Comments
 (0)