Skip to content

Commit 7c362f2

Browse files
authored
feat: uv (#305)
1 parent 7c29b7c commit 7c362f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+678
-192
lines changed

.envrc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ if [[ -f .env ]]; then
44
dotenv .env
55
fi
66

7+
PATH_add "$PWD/.venv/bin"
8+
export VIRTUAL_ENV="$PWD/.venv"
9+
710
if [ ! -d .venv ]; then
8-
echo "warning: creating virtualenv for the first time"
9-
python3 -m venv .venv
10-
source .venv/bin/activate
11-
pip install -r requirements.txt
12-
pip install -r requirements-dev.txt
13-
else
14-
source .venv/bin/activate
15-
unset PS1
11+
uv sync
12+
fi
13+
14+
if [[ ! -f .git/hooks/pre-commit ]] || ! grep -q pre-commit .git/hooks/pre-commit 2>/dev/null; then
15+
pre-commit install --install-hooks
1616
fi

.github/workflows/build.yml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@ on:
99
jobs:
1010
dist:
1111
name: Create Distribution
12-
runs-on: ubuntu-22.04
12+
runs-on: ubuntu-24.04
1313
timeout-minutes: 10
1414
steps:
1515
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
1616

17-
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
18-
with:
19-
python-version: 3.12
20-
21-
- name: Install dev requirements
22-
run: pip install -r requirements-dev.txt
17+
- uses: astral-sh/setup-uv@e06108dd0aef18192324c70427afc47652e63a82 # v7.5.0
2318

2419
- name: "Prepare Artifacts"
25-
run: python -m build
20+
run: uv build
2621

2722
- name: Cache dist
2823
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
@@ -35,31 +30,27 @@ jobs:
3530
runs-on: ${{ matrix.os }}
3631
strategy:
3732
matrix:
38-
os: [ubuntu-22.04, macos-14]
33+
os: [ubuntu-24.04, macos-15]
3934
include:
40-
- os: ubuntu-22.04
35+
- os: ubuntu-24.04
4136
asset_name: devservices-linux
42-
- os: macos-14
37+
- os: macos-15
4338
asset_name: devservices-darwin
4439

4540
steps:
4641
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
4742

48-
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
49-
with:
50-
python-version: 3.12
51-
52-
- name: Install pyoxidizer
53-
run: pip install pyoxidizer==0.24.0
54-
55-
- name: Install dev requirements
56-
run: pip install -r requirements-dev.txt
43+
- uses: astral-sh/setup-uv@e06108dd0aef18192324c70427afc47652e63a82 # v7.5.0
5744

5845
- name: Generate metadata
59-
run: python -m build --sdist --no-isolation
46+
run: |
47+
uv sync
48+
uv pip install pyoxidizer==0.24.0
49+
uv export --no-dev --no-hashes --no-emit-project -o requirements.txt
50+
uv run python -m build --sdist --no-isolation
6051
6152
- name: Build binary
62-
run: pyoxidizer build --release
53+
run: uv run pyoxidizer build --release
6354

6455
- name: Locate binary
6556
id: locate_binary
@@ -78,7 +69,7 @@ jobs:
7869

7970
upload-artifacts:
8071
name: Upload build artifacts
81-
runs-on: ubuntu-22.04
72+
runs-on: ubuntu-24.04
8273
needs: [dist, binary]
8374
if: github.event_name != 'pull_request'
8475
steps:

.github/workflows/lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
steps:
1717
- name: Checkout repo
1818
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
19-
- name: Set up Python
20-
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
21-
with:
22-
python-version: 3.12
19+
- name: Set up uv
20+
uses: astral-sh/setup-uv@e06108dd0aef18192324c70427afc47652e63a82 # v7.5.0
21+
- name: Install dependencies
22+
run: uv sync
2323
- name: Pre-commit
24-
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
24+
run: uv run pre-commit run --all-files

.github/workflows/test.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,20 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: ["3.11", "3.12"]
19+
python-version: ["3.11.14", "3.12.13"]
2020
steps:
2121
- name: Configure git
2222
run: |
2323
git config --global user.email "test@example.com"
2424
git config --global user.name "test"
2525
- name: Checkout repo
2626
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
27-
- name: Set up Python
28-
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
29-
with:
30-
python-version: ${{ matrix.python-version }}
27+
- name: Set up uv
28+
uses: astral-sh/setup-uv@e06108dd0aef18192324c70427afc47652e63a82 # v7.5.0
3129
- name: Install dependencies
32-
run: |
33-
python -m pip install --upgrade pip
34-
pip install -r requirements.txt
35-
pip install -r requirements-dev.txt
36-
pip install -e .
30+
run: uv sync --python ${{ matrix.python-version }}
3731
- name: Run tests
38-
run: pytest --cov --junitxml=junit.xml -o junit_family=legacy
32+
run: uv run pytest --cov --junitxml=junit.xml -o junit_family=legacy
3933
- name: Upload results to Codecov
4034
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
4135
with:

.pre-commit-config.yaml

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
11
repos:
2-
- repo: https://github.com/asottile/reorder-python-imports
3-
rev: v3.12.0
4-
hooks:
5-
- id: reorder-python-imports
6-
args: [--py311-plus, --add-import, "from __future__ import annotations"]
7-
- repo: https://github.com/psf/black
8-
rev: 23.10.0
9-
hooks:
10-
- id: black
11-
language_version: python3.12
12-
- repo: https://github.com/PyCQA/flake8
13-
rev: 6.1.0
14-
hooks:
15-
- id: flake8
16-
language_version: python3.12
17-
- repo: https://github.com/pre-commit/mirrors-mypy
18-
rev: v1.6.1
2+
- repo: local
193
hooks:
4+
- id: ruff-check
5+
name: ruff check
6+
entry: .venv/bin/ruff check --fix
7+
language: system
8+
types: [python]
9+
- id: ruff-format
10+
name: ruff format
11+
entry: .venv/bin/ruff format
12+
language: system
13+
types: [python]
2014
- id: mypy
21-
additional_dependencies:
22-
- "pytest"
23-
- "types-PyYAML"
24-
language_version: python3.12
25-
- repo: https://github.com/shellcheck-py/shellcheck-py
26-
rev: v0.9.0.6
27-
hooks:
15+
name: mypy
16+
entry: .venv/bin/mypy
17+
language: system
18+
types: [python]
2819
- id: shellcheck
20+
name: shellcheck
21+
entry: .venv/bin/shellcheck
22+
language: system
23+
types: [shell]
2924
args: [--norc]
30-
language_version: python3.12
3125
- repo: https://github.com/pre-commit/pre-commit-hooks
3226
rev: v4.6.0
3327
hooks:

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.13

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,11 @@ networks:
167167
name: devservices
168168
external: true
169169
```
170+
171+
## Dev
172+
173+
```sh
174+
uv sync
175+
direnv allow
176+
pytest
177+
```

devservices/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""
22
DevServices CLI tool for managing Docker Compose services.
33
"""
4+
45
from __future__ import annotations

devservices/commands/down.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
import concurrent.futures
44
import os
55
import subprocess
6-
from argparse import _SubParsersAction
76
from argparse import ArgumentParser
87
from argparse import Namespace
8+
from argparse import _SubParsersAction
99

1010
from sentry_sdk import capture_exception
1111
from sentry_sdk import logger as sentry_logger
1212

1313
from devservices.constants import CONFIG_FILE_NAME
1414
from devservices.constants import DEPENDENCY_CONFIG_VERSION
15-
from devservices.constants import DependencyType
1615
from devservices.constants import DEVSERVICES_DEPENDENCIES_CACHE_DIR
1716
from devservices.constants import DEVSERVICES_DEPENDENCIES_CACHE_DIR_KEY
1817
from devservices.constants import DEVSERVICES_DIR_NAME
18+
from devservices.constants import DependencyType
1919
from devservices.exceptions import ConfigError
2020
from devservices.exceptions import ConfigNotFoundError
2121
from devservices.exceptions import DependencyError
@@ -25,17 +25,17 @@
2525
from devservices.exceptions import SupervisorError
2626
from devservices.utils.console import Console
2727
from devservices.utils.console import Status
28-
from devservices.utils.dependencies import construct_dependency_graph
2928
from devservices.utils.dependencies import DependencyNode
29+
from devservices.utils.dependencies import InstalledRemoteDependency
30+
from devservices.utils.dependencies import construct_dependency_graph
3031
from devservices.utils.dependencies import get_non_shared_remote_dependencies
3132
from devservices.utils.dependencies import install_and_verify_dependencies
32-
from devservices.utils.dependencies import InstalledRemoteDependency
3333
from devservices.utils.docker_compose import DockerComposeCommand
3434
from devservices.utils.docker_compose import get_docker_compose_commands_to_run
3535
from devservices.utils.docker_compose import run_cmd
36+
from devservices.utils.services import Service
3637
from devservices.utils.services import find_matching_service
3738
from devservices.utils.services import get_active_service_names
38-
from devservices.utils.services import Service
3939
from devservices.utils.state import ServiceRuntime
4040
from devservices.utils.state import State
4141
from devservices.utils.state import StateTables
@@ -231,9 +231,9 @@ def bring_down_service(
231231

232232
# Set the environment variable for the local dependencies directory to be used by docker compose
233233
current_env = os.environ.copy()
234-
current_env[
235-
DEVSERVICES_DEPENDENCIES_CACHE_DIR_KEY
236-
] = relative_local_dependency_directory
234+
current_env[DEVSERVICES_DEPENDENCIES_CACHE_DIR_KEY] = (
235+
relative_local_dependency_directory
236+
)
237237
state = State()
238238

239239
# We want to ignore any dependencies that are set to run locally if we are excluding local dependencies

devservices/commands/foreground.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import os
44
import pty
55
import shlex
6-
from argparse import _SubParsersAction
76
from argparse import ArgumentParser
87
from argparse import Namespace
8+
from argparse import _SubParsersAction
99

1010
from sentry_sdk import capture_exception
1111

1212
from devservices.constants import CONFIG_FILE_NAME
13-
from devservices.constants import DependencyType
1413
from devservices.constants import DEVSERVICES_DIR_NAME
14+
from devservices.constants import DependencyType
1515
from devservices.exceptions import ConfigError
1616
from devservices.exceptions import ConfigNotFoundError
1717
from devservices.exceptions import ServiceNotFoundError

0 commit comments

Comments
 (0)