Skip to content

Commit 4094ed6

Browse files
committed
Improve CI workflows and Docker uv integration
- Pin setup-uv to v8.0.0 and use activate-environment to avoid uv run wrappers in all workflows - Fix test.yml: pass matrix python-version to setup-python so tox actually tests against 3.12, 3.13, and 3.14 - Add --frozen to lint.yml install step for CI consistency - Move UV_PROJECT_ENVIRONMENT to ENV in Dockerfile.baseimage so it propagates to child images automatically - Bump uv Docker image from 0.5 to 0.11
1 parent ee88125 commit 4094ed6

6 files changed

Lines changed: 32 additions & 21 deletions

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,21 @@ jobs:
4949

5050
# Creates version files we use to track the version of code in the container
5151
- name: Install uv
52-
uses: astral-sh/setup-uv@v4
52+
uses: astral-sh/setup-uv@v8.0.0
5353
with:
5454
enable-cache: true
5555
cache-dependency-glob: uv.lock
5656
python-version: "3.12"
57+
activate-environment: true
58+
59+
- name: Setup Dunamai (uv ci group)
60+
run: uv sync --frozen --only-group ci
5761

5862
- name: Create version file
5963
run: |
60-
echo "__version__ = '$(uv run --only-group ci dunamai from git --style semver)'" >> src/palace/manager/_version.py
61-
echo "__commit__ = '$(uv run --only-group ci dunamai from git --format {commit} --full-commit)'" >> src/palace/manager/_version.py
62-
echo "__branch__ = '$(uv run --only-group ci dunamai from git --format {branch})'" >> src/palace/manager/_version.py
64+
echo "__version__ = '$(dunamai from git --style semver)'" >> src/palace/manager/_version.py
65+
echo "__commit__ = '$(dunamai from git --format {commit} --full-commit)'" >> src/palace/manager/_version.py
66+
echo "__branch__ = '$(dunamai from git --format {branch})'" >> src/palace/manager/_version.py
6367
cat src/palace/manager/_version.py
6468
6569
# Docker doesn't support uppercase letters in repo names, so we need to lowercase the owner
@@ -361,7 +365,7 @@ jobs:
361365
bash -c "
362366
cat src/palace/manager/_version.py &&
363367
source env/bin/activate &&
364-
UV_PROJECT_ENVIRONMENT=/var/www/circulation/env uv sync --frozen &&
368+
uv sync --frozen --active &&
365369
pytest --no-cov tests
366370
"
367371

.github/workflows/lint.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ jobs:
1414
- uses: actions/checkout@v6
1515

1616
- name: Install uv
17-
uses: astral-sh/setup-uv@v4
17+
uses: astral-sh/setup-uv@v8.0.0
1818
with:
1919
enable-cache: true
2020
cache-dependency-glob: uv.lock
2121
python-version: ${{ env.PYTHON_VERSION }}
22+
activate-environment: true
2223

2324
- name: Install Pre-commit
24-
run: uv sync --only-group ci
25+
run: uv sync --frozen --only-group ci
2526

2627
- name: Restore pre-commit cache
2728
uses: actions/cache@v5
@@ -31,4 +32,4 @@ jobs:
3132
restore-keys: pre-commit-${{ runner.os }}-py${{ env.PYTHON_VERSION }}
3233

3334
- name: Lint
34-
run: uv run pre-commit run --all-files --show-diff-on-failure
35+
run: pre-commit run --all-files --show-diff-on-failure

.github/workflows/mypy.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v6
1414

15-
- name: Install uv 🌀
16-
uses: astral-sh/setup-uv@v4
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v8.0.0
1717
with:
1818
enable-cache: true
1919
cache-dependency-glob: uv.lock
2020
python-version: ${{ env.PYTHON_VERSION }}
21+
activate-environment: true
2122

2223
- name: Install Python Packages 📦
2324
run: uv sync --frozen --no-group ci
2425

2526
- name: Run MyPy 🪄
26-
run: uv run mypy
27+
run: mypy

.github/workflows/test.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,23 @@ jobs:
2828
- name: Disable network offload
2929
run: sudo ethtool -K eth0 tx off rx off
3030

31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
3136
- name: Install uv
32-
uses: astral-sh/setup-uv@v4
37+
uses: astral-sh/setup-uv@v8.0.0
3338
with:
3439
enable-cache: true
3540
cache-dependency-glob: uv.lock
36-
python-version: ${{ matrix.python-version }}
41+
activate-environment: true
3742

3843
- name: Install Tox
39-
run: uv sync --only-group ci
44+
run: uv sync --frozen --only-group ci
4045

4146
- name: Run Tests
42-
run: uv run tox
47+
run: tox
4348
env:
4449
# Workaround for tox-docker not supporting Docker 29+, which removed
4550
# the top-level NetworkSettings.Gateway key from the container API.

docker/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ RUN mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
1919

2020
# Copy our uv files into the image and install our dependencies.
2121
COPY --chown=palace:palace uv.lock pyproject.toml /var/www/circulation/
22-
RUN UV_PROJECT_ENVIRONMENT=/var/www/circulation/env \
23-
uv sync --frozen --no-dev --no-install-project
22+
RUN uv sync --frozen --no-dev --no-install-project
2423

2524
COPY --chown=palace:palace . /var/www/circulation
2625

2726
# Install the project itself as a non-editable install. Omitting
2827
# --no-install-project (and passing --no-editable) is the recommended
2928
# pattern for production Docker builds with uv.
30-
RUN UV_PROJECT_ENVIRONMENT=/var/www/circulation/env \
31-
uv sync --frozen --no-dev --no-editable
29+
RUN uv sync --frozen --no-dev --no-editable
3230

3331
###############################################################################
3432
## Circ-exec Image

docker/Dockerfile.baseimage

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ RUN apt-get update && \
2222
apt-get upgrade -y --no-install-recommends -o Dpkg::Options::="--force-confold" && \
2323
/bd_build/cleanup.sh
2424

25+
ENV UV_PROJECT_ENVIRONMENT=/var/www/circulation/env
26+
2527
# Install uv (pinned to a specific minor for reproducibility).
26-
COPY --from=ghcr.io/astral-sh/uv:0.5 /uv /uvx /usr/local/bin/
28+
# https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
29+
COPY --from=ghcr.io/astral-sh/uv:0.11 /uv /uvx /usr/local/bin/
2730

2831
# Install required packages including python, pip, and libraries/compilers
2932
# needed to build the python wheels we need.
@@ -66,7 +69,6 @@ COPY --chown=palace:palace uv.lock pyproject.toml /var/www/circulation/
6669
RUN python3 -m venv env && \
6770
SIMPLIFIED_ENVIRONMENT=/var/www/circulation/environment.sh && \
6871
echo "if [ -f $SIMPLIFIED_ENVIRONMENT ]; then source $SIMPLIFIED_ENVIRONMENT; fi" >> env/bin/activate && \
69-
UV_PROJECT_ENVIRONMENT=/var/www/circulation/env \
7072
uv sync --frozen --no-dev --no-install-project && \
7173
. env/bin/activate && \
7274
# TODO: This can be removed once NLTK merges https://github.com/sloria/TextBlob/pull/469

0 commit comments

Comments
 (0)