Skip to content

Commit 1a9c82c

Browse files
committed
Use uv
1 parent 7683d66 commit 1a9c82c

File tree

13 files changed

+2795
-245
lines changed

13 files changed

+2795
-245
lines changed

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ fi
4949

5050
export VIRTUAL_ENV="${PWD}/.venv"
5151
PATH_add "${PWD}/.venv/bin"
52+
PATH_add "${PWD}/.devenv/bin"
53+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'Setup Launchpad dev'
2+
description: 'Sets up Python, uv, and dev dependencies'
3+
inputs:
4+
python-version:
5+
description: 'Python version'
6+
required: false
7+
default: '3.12'
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- name: Set up Python
13+
uses: actions/setup-python@v6
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v7
19+
with:
20+
enable-cache: false
21+
cache-dependency-glob: pyproject.toml
22+
23+
- name: Set up venv
24+
uses: getsentry/[email protected]
25+
with:
26+
python-version: ${{ inputs.python-version }}
27+
cache-dependency-path: uv.lock
28+
install-cmd: uv sync --frozen --active
29+
30+
- name: Install dependencies
31+
shell: bash
32+
run: make install-dev-for-ci

.github/workflows/ci.yml

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,8 @@ jobs:
1818
- name: Checkout code
1919
uses: actions/checkout@v5
2020

21-
- name: Set up Python
22-
uses: actions/setup-python@v6
23-
with:
24-
python-version: "3.12"
25-
26-
- name: Install uv
27-
uses: astral-sh/setup-uv@v7
28-
with:
29-
enable-cache: true
30-
cache-dependency-glob: pyproject.toml
31-
32-
- name: Install dependencies
33-
run: make install-dev
21+
- name: Setup launchpad dev
22+
uses: ./.github/actions/setup-dev
3423

3524
- name: Check lint
3625
run: make check-lint
@@ -50,19 +39,8 @@ jobs:
5039
- name: Checkout code
5140
uses: actions/checkout@v5
5241

53-
- name: Set up Python
54-
uses: actions/setup-python@v6
55-
with:
56-
python-version: "3.12"
57-
58-
- name: Install uv
59-
uses: astral-sh/setup-uv@v7
60-
with:
61-
enable-cache: true
62-
cache-dependency-glob: pyproject.toml
63-
64-
- name: Install dependencies
65-
run: make install-dev
42+
- name: Setup launchpad dev
43+
uses: ./.github/actions/setup-dev
6644

6745
- name: Build Docker image with test fixtures
6846
run: docker build --build-arg TEST_BUILD=true -t launchpad-test .
@@ -76,7 +54,7 @@ jobs:
7654
-e KAFKA_BOOTSTRAP_SERVERS="localhost:9092" \
7755
-e KAFKA_GROUP_ID="launchpad-test" \
7856
-e KAFKA_TOPICS="preprod-artifact-events" \
79-
launchpad-test python -m pytest -n auto tests/ -v
57+
launchpad-test uv run pytest -n auto tests/ -v
8058
8159
- name: Test CLI installation and basic functionality in Docker
8260
run: |
@@ -92,19 +70,8 @@ jobs:
9270
- name: Checkout code
9371
uses: actions/checkout@v5
9472

95-
- name: Set up Python
96-
uses: actions/setup-python@v6
97-
with:
98-
python-version: "3.12"
99-
100-
- name: Install uv
101-
uses: astral-sh/setup-uv@v7
102-
with:
103-
enable-cache: true
104-
cache-dependency-glob: pyproject.toml
105-
106-
- name: Install dependencies
107-
run: make install-dev
73+
- name: Setup launchpad dev
74+
uses: ./.github/actions/setup-dev
10875

10976
- name: Build Docker image with test fixtures
11077
run: docker build --build-arg TEST_BUILD=true -t launchpad-test .
@@ -121,7 +88,7 @@ jobs:
12188
-v ${{ github.workspace }}:/workspace \
12289
-w /workspace \
12390
--user $(id -u):$(id -g) \
124-
launchpad-test python -m pytest -n auto tests/unit/ tests/integration/ -v --cov --cov-branch --cov-report=xml --junitxml=junit.xml
91+
launchpad-test uv run pytest -n auto tests/ -v --cov --cov-branch --cov-report=xml --junitxml=junit.xml
12592
12693
- name: Upload coverage reports to Codecov
12794
uses: codecov/codecov-action@v5
@@ -144,19 +111,8 @@ jobs:
144111
- name: Checkout code
145112
uses: actions/checkout@v5
146113

147-
- name: Set up Python
148-
uses: actions/setup-python@v6
149-
with:
150-
python-version: "3.12"
151-
152-
- name: Install uv
153-
uses: astral-sh/setup-uv@v7
154-
with:
155-
enable-cache: true
156-
cache-dependency-glob: pyproject.toml
157-
158-
- name: Install dependencies
159-
run: make install-dev
114+
- name: Setup launchpad dev
115+
uses: ./.github/actions/setup-dev
160116

161117
- name: Build package
162118
run: make build

.github/workflows/image.yml

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,8 @@ jobs:
3131
- name: Set up Docker Buildx
3232
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
3333

34-
- name: Set up Python
35-
uses: actions/setup-python@v6
36-
with:
37-
python-version: "3.12"
38-
39-
- name: Install uv
40-
uses: astral-sh/setup-uv@v7
41-
with:
42-
enable-cache: true
43-
cache-dependency-glob: pyproject.toml
44-
45-
- name: Install dependencies
46-
run: make install-dev
34+
- name: Setup launchpad dev
35+
uses: ./.github/actions/setup-dev
4736

4837
- name: Build package
4938
run: make build
@@ -108,19 +97,8 @@ jobs:
10897
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
10998
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
11099
111-
- name: Set up Python
112-
uses: actions/setup-python@v6
113-
with:
114-
python-version: "3.12"
115-
116-
- name: Install uv
117-
uses: astral-sh/setup-uv@v7
118-
with:
119-
enable-cache: true
120-
cache-dependency-glob: pyproject.toml
121-
122-
- name: Install dependencies
123-
run: make install-dev
100+
- name: Setup launchpad dev
101+
uses: ./.github/actions/setup-dev
124102

125103
- name: Build package
126104
run: make build

.python-version

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

Dockerfile

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ FROM python:3.12-slim-bookworm
3333
ARG TEST_BUILD=false
3434

3535
# Set environment variables
36-
ENV PYTHONUNBUFFERED=1 \
36+
ENV PATH="/.venv/bin:$PATH" \
37+
PYTHONUNBUFFERED=1 \
3738
PYTHONDONTWRITEBYTECODE=1 \
3839
PIP_NO_CACHE_DIR=1 \
39-
PIP_DISABLE_PIP_VERSION_CHECK=1
40+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
41+
UV_PROJECT_ENVIRONMENT=/.venv \
42+
UV_COMPILE_BYTECODE=1 \
43+
UV_NO_CACHE=1
4044

4145
# Create app user and group
4246
RUN groupadd --gid 1000 app && \
@@ -64,18 +68,24 @@ RUN apt-get update && \
6468
# Set working directory
6569
WORKDIR /app
6670

67-
# Copy requirements and install Python dependencies
68-
COPY requirements.txt requirements-dev.txt ./
69-
RUN pip install --no-cache-dir -r requirements.txt -r requirements-dev.txt
71+
RUN python3 -m pip install \
72+
--index-url 'https://pypi.devinfra.sentry.io/simple' 'uv==0.8.2'
73+
74+
RUN python3 -m venv "$UV_PROJECT_ENVIRONMENT"
7075

7176
# Copy source code, tests, and scripts
7277
COPY src/ ./src/
7378
COPY tests/ ./tests/
7479
COPY scripts/ ./scripts/
7580
COPY devservices/ ./devservices/
76-
COPY pyproject.toml .
77-
COPY README.md .
78-
COPY LICENSE .
81+
COPY README.md LICENSE pyproject.toml uv.lock ./
82+
83+
RUN : && \
84+
if [ "$TEST_BUILD" = "true" ]; then \
85+
uv sync --frozen; \
86+
else \
87+
uv sync --frozen --no-dev; \
88+
fi
7989

8090
# Copy libdispatch from the build stage
8191
COPY --from=libdispatch-build /usr/lib/x86_64-linux-gnu/libdispatch.so* /usr/lib/x86_64-linux-gnu/
@@ -96,9 +106,7 @@ RUN if [ "$TEST_BUILD" = "true" ]; then \
96106
rm -rf tests/_fixtures; \
97107
fi
98108

99-
RUN pip install -e .
100-
101-
RUN python scripts/deps --install --local-architecture=x86_64 --local-system=linux
109+
RUN python3 scripts/deps --install --local-architecture=x86_64 --local-system=linux
102110

103111
# Change ownership to app user
104112
RUN chown -R app:app /app

0 commit comments

Comments
 (0)