Skip to content

Migrate to UV & fix some tests #185

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

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
41 changes: 22 additions & 19 deletions .github/workflows/cdkactions_build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,35 @@ jobs:
name: Django Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.local/share/virtualenvs
key: v0-${{ hashFiles('backend/Pipfile.lock') }}
key: v0-${{ hashFiles('backend/uv.lock') }}
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.6.8"
- name: Install Dependencies
run: |-
cd backend
pip install pipenv
pipenv install --deploy --dev
uv sync
- name: Lint (flake8)
run: |-
cd backend
pipenv run flake8 .
uv run flake8 .
- name: Lint (black)
run: |-
cd backend
pipenv run black --check .
uv run black --check .
- name: Test (run in parallel)
run: |-
cd backend
pipenv run python -m coverage run --concurrency=multiprocessing manage.py test --settings=Platform.settings.ci --parallel
pipenv run python -m coverage combine
uv run python -m coverage run --concurrency=multiprocessing manage.py test --settings=Platform.settings.ci --parallel
uv run python -m coverage combine
container:
image: python:3.10-buster
image: python:3.11-bookworm
env:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
services:
Expand All @@ -47,11 +50,11 @@ jobs:
name: Publish backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: buildx-publish-backend
Expand All @@ -73,11 +76,11 @@ jobs:
name: Publish platform-dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: buildx-publish-platform-dev
Expand All @@ -99,9 +102,9 @@ jobs:
name: React Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: "**/node_modules"
key: v0-${{ hashFiles('frontend/yarn.lock') }}
Expand All @@ -128,11 +131,11 @@ jobs:
name: Publish frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: buildx-publish-frontend
Expand All @@ -154,7 +157,7 @@ jobs:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- id: synth
name: Synth cdk8s manifests
run: |-
Expand Down
13 changes: 9 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ RUN wget -O/etc/apt/trusted.gpg.d/nginx.asc https://nginx.org/keys/nginx_signing

# Install dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends -y python3.11-dev pipenv python3-distutils libpq-dev gcc \
&& apt-get install --no-install-recommends -y python3.11-dev python3-distutils libpq-dev gcc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install uv
COPY --from=ghcr.io/astral-sh/uv@sha256:2381d6aa60c326b71fd40023f921a0a3b8f91b14d5db6b90402e65a635053709 /uv /uvx /bin/

# Copy config files
COPY docker/shibboleth/ /etc/shibboleth/
COPY docker/nginx-default.conf /etc/nginx/conf.d/default.conf
COPY docker/shib_clear_headers /etc/nginx/
COPY docker/supervisord.conf /etc/supervisor/

# Copy project dependencies
COPY Pipfile* /app/
COPY pyproject.toml uv.lock

# Install project dependencies
RUN pipenv install --deploy --system
RUN uv sync --frozen --no-dev --no-install-project --python $(which python); \
ln -s /app/.venv/bin/uwsgi /usr/local/bin/uwsgi; \
ln -s /app/.venv/bin/gunicorn /usr/local/bin/gunicorn

# Copy project files
COPY . /app/
Expand All @@ -38,7 +43,7 @@ ENV IDENTITY_RSA_PRIVATE_KEY 'temporary private key just to build the docker ima
ENV OIDC_RSA_PRIVATE_KEY 'temporary private key just to build the docker image'

# Collect static files
RUN python3 /app/manage.py collectstatic --noinput
RUN uv run /app/manage.py collectstatic --noinput

# Copy mime definitions
COPY docker/mime.types /etc/mime.types
Expand Down
22 changes: 18 additions & 4 deletions backend/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
FROM pennlabs/django-base:b269ea1613686b1ac6370154debbb741b012de1a-3.11
FROM pennlabs/django-base:11d476546bd11c7a499e0e93be8db6af035d360f-3.11

LABEL maintainer="Penn Labs"

# Install dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends -y wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy project dependencies
COPY Pipfile* /app/
COPY pyproject.toml uv.lock /app/

# Install project dependencies
RUN pipenv install --system
RUN uv sync --frozen --no-dev --no-install-project --python $(which python); \
ln -s /app/.venv/bin/uwsgi /usr/local/bin/uwsgi; \
ln -s /app/.venv/bin/gunicorn /usr/local/bin/gunicorn

# Make installed binaries available for POSIX compliant scripts
ENV PATH="/app/.venv/bin:$PATH"

# Patch for scripts that use a hard-coded path to python (django-run, asgi-run)
ENV PYTHONPATH="/app/.venv/lib/python3.11/site-packages/:$PYTHONPATH"

# Copy project files
COPY . /app/
Expand All @@ -15,4 +29,4 @@ ENV DJANGO_SETTINGS_MODULE Platform.settings.staging
ENV SECRET_KEY 'temporary key just to build the docker image'

# Collect static files
RUN python3 /app/manage.py collectstatic --noinput
RUN uv run /app/manage.py collectstatic --noinput
44 changes: 0 additions & 44 deletions backend/Pipfile

This file was deleted.

Loading
Loading