Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate shared to uv-based tooling #423

Merged
merged 1 commit into from
Nov 18, 2024
Merged
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
15 changes: 2 additions & 13 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@
# shellcheck disable=SC1091

if [ ! -d .venv ]; then
echo "warning: creating virtualenv for the first time"
if which pyenv > /dev/null; then
eval "$(pyenv init -)"
pyenv install -s
else
echo "warning: pyenv not installed, using python3 and hoping for the best"
fi

python3 -m venv .venv
uv sync
source .venv/bin/activate
pip install -r requirements.txt
pip install -r tests/requirements.txt
pip install ruff
else
source .venv/bin/activate
unset PS1
fi
unset PS1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ dmypy.json
cython_debug/

# Editor junk
.vscode/settings.json
.*.sw?
.idea/

.ruff_cache/

/target

# Make working with Sapling a little easier
Expand Down
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
}
}
22 changes: 9 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export CODECOV_TOKEN=${CODECOV_UPLOAD_TOKEN}
.ONESHELL:

test:
docker compose exec shared python -m pytest --cov=./
docker compose exec shared uv run pytest --cov=./

test.path:
docker compose exec shared python -m pytest $(TEST_PATH)
docker compose exec shared uv run pytest $(TEST_PATH)

lint:
make lint.install
Expand All @@ -30,24 +30,20 @@ lint.check:
ruff format --check

requirements.install:
python -m venv venv
. venv/bin/activate
pip install -r tests/requirements.txt
pip install -r requirements.txt
python setup.py develop
pip install codecov-cli==0.7.2
uv sync
. .venv/bin/activate

test_env.install_cli:
pip install codecov-cli==0.7.2
pip install codecov-cli

test_env.build:
docker-compose build
docker compose build

test_env.up:
docker-compose up -d
docker compose up -d

test_env.test:
docker-compose exec shared python -m pytest --cov=./ --junitxml=junit.xml
docker compose exec shared uv run pytest --cov=./ --junitxml=junit.xml

test_env.down:
docker-compose down
docker compose down
13 changes: 0 additions & 13 deletions build-wheels.sh

This file was deleted.

8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

volumes:
postgres-volume:
timescale-volume:
Expand All @@ -21,7 +19,7 @@ services:
- ./tests/:/app/tests

postgres:
image: postgres:14.4-alpine
image: postgres:14-alpine
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
Expand All @@ -34,7 +32,7 @@ services:
size: 1024M

redis:
image: redis:4.0-alpine
image: redis:7-alpine
volumes:
- redis-volume:/data

Expand All @@ -51,7 +49,7 @@ services:
size: 1024M

minio:
image: minio/minio:RELEASE.2019-04-09T01-22-30Z
image: minio/minio:latest
command: server /export
ports:
- "9000:9000"
Expand Down
39 changes: 23 additions & 16 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
# syntax=docker/dockerfile:1.4
ARG PYTHON_IMAGE=python:3.12.2-slim-bullseye
ARG PYTHON_IMAGE=ghcr.io/astral-sh/uv:python3.12-bookworm-slim

FROM $PYTHON_IMAGE as build

RUN apt-get update && apt-get install -y --no-install-recommends \
git \
libxslt-dev \
python3-dev \
libffi-dev \
libpq-dev \
gcc \
bash \
make \
build-essential \
curl \
&& pip install --upgrade pip
git

ENV UV_LINK_MODE=copy
ENV PATH=/root/.local/bin:/app/.venv/bin:$PATH

RUN --mount=type=cache,target=/root/.cache/uv \
uv tool install codecov-cli

# Change the working directory to the `app` directory
WORKDIR /app
COPY . /app

RUN pip install -r tests/requirements.txt && \
pip install -r requirements.txt && \
python setup.py develop && \
pip install codecov-cli==0.7.2
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project

# Copy the project into the image
ADD . /app

# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen

CMD ["uv", "run", "bash"]
63 changes: 62 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
[project]
name = "shared"
version = "0.1.0"
description = "Shared code used in codecov API and worker"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"boto3>=1.35.59",
"cachetools>=5.5.0",
"cerberus>=1.3.5",
"codecov-ribs>=0.1.18",
"colour>=0.1.5",
"cryptography>=43.0.3",
"django-better-admin-arrayfield>=1.4.2",
"django-model-utils>=5.0.0",
"django-postgres-extra>=2.0.8",
"django-prometheus>=2.3.1",
"django<5",
"google-auth>=2.36.0",
"google-cloud-pubsub>=2.27.1",
"google-cloud-storage>=2.18.2",
"httpx>=0.23.0",
"ijson>=3.3.0",
"minio>=7.2.10",
"mmh3>=5.0.1",
"oauthlib>=3.2.2",
"orjson>=3.10.11",
"prometheus-client>=0.21.0",
"pyjwt>=2.9.0",
"pyparsing>=3.2.0",
"python-redis-lock>=4.0.0",
"pyyaml>=6.0.2",
"redis>=5.2.0",
"requests>=2.32.3",
"sentry-sdk>=2.18.0",
"sqlalchemy<2",
]

[build-system]
requires = ["setuptools", "wheel"]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"factory-boy>=3.3.1",
"freezegun>=1.5.1",
"mock>=5.1.0",
"mypy>=1.13.0",
"pre-commit>=4.0.1",
"psycopg2-binary>=2.9.10",
"pytest-asyncio>=0.24.0",
"pytest-cov>=6.0.0",
"pytest-django>=4.9.0",
"pytest-mock>=3.14.0",
"pytest>=8.3.3",
"respx>=0.21.1",
"ruff>=0.7.3",
"types-mock>=5.1.0.20240425",
# NOTE: some weird interaction between existing `vcrpy` snapshots and the way
# `oauth2` / `minio` deal with requests forces us to downgrade `urllib3`:
"urllib3==1.26.19",
"vcrpy>=6.0.2",
]
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

56 changes: 0 additions & 56 deletions setup.py

This file was deleted.

17 changes: 0 additions & 17 deletions tests/requirements.in

This file was deleted.

Loading
Loading