Skip to content

Commit

Permalink
feat: convert to a uv based workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Oct 17, 2024
1 parent 2b4794b commit 8c3c7c0
Show file tree
Hide file tree
Showing 14 changed files with 2,850 additions and 176 deletions.
52 changes: 22 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,19 @@
"uses": "actions/checkout@v2"
},
{
"name": "Set up Python ${{ matrix.python-version }}",
"uses": "actions/setup-python@v2",
"name": "Set up uv",
"uses": "astral-sh/setup-uv@v3",
"with": {
"python-version": "${{ matrix.python-version }}"
"enable-cache": true
}
},
{
"name": "Set up pip cache",
"uses": "actions/cache@v2",
"with": {
"path": "~/.cache/pip",
"key": "pip-${{ matrix.python-version }}"
}
"name": "Set up Python ${{ matrix.python-version }}",
"run": "uv python install ${{ matrix.python-version }}"
},
{
"name": "Set up packages",
"run": "set -e\n\npip install -U pip setuptools wheel\npip install -U \\\n pre-commit coveralls pyyaml pytest-django\npip install -U -r requirements.txt\n\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
"run": "set -e\nuv sync --locked\n# change path and env vars\nsource .venv/bin/activate\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
},
{
"name": "Copy secret.py",
Expand Down Expand Up @@ -78,23 +74,19 @@
}
},
{
"name": "Set up Python ${{ matrix.python-version }}",
"uses": "actions/setup-python@v2",
"name": "Set up uv",
"uses": "astral-sh/setup-uv@v3",
"with": {
"python-version": "${{ matrix.python-version }}"
"enable-cache": true
}
},
{
"name": "Set up pip cache",
"uses": "actions/cache@v2",
"with": {
"path": "~/.cache/pip",
"key": "pip-${{ matrix.python-version }}"
}
"name": "Set up Python ${{ matrix.python-version }}",
"run": "uv python install ${{ matrix.python-version }}"
},
{
"name": "Set up packages",
"run": "set -e\n\npip install -U pip setuptools wheel\npip install -U \\\n pre-commit coveralls pyyaml pytest-django\npip install -U -r requirements.txt\n\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
"run": "set -e\nuv sync --locked\n# change path and env vars\nsource .venv/bin/activate\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
},
{
"name": "Copy secret.py",
Expand Down Expand Up @@ -179,23 +171,19 @@
"uses": "actions/checkout@v2"
},
{
"name": "Set up Python ${{ matrix.python-version }}",
"uses": "actions/setup-python@v2",
"name": "Set up uv",
"uses": "astral-sh/setup-uv@v3",
"with": {
"python-version": "${{ matrix.python-version }}"
"enable-cache": true
}
},
{
"name": "Set up pip cache",
"uses": "actions/cache@v2",
"with": {
"path": "~/.cache/pip",
"key": "pip-${{ matrix.python-version }}"
}
"name": "Set up Python ${{ matrix.python-version }}",
"run": "uv python install ${{ matrix.python-version }}"
},
{
"name": "Set up packages",
"run": "set -e\n\npip install -U pip setuptools wheel\npip install -U \\\n pre-commit coveralls pyyaml pytest-django\npip install -U -r requirements.txt\n\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
"run": "set -e\nuv sync --locked\n# change path and env vars\nsource .venv/bin/activate\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
},
{
"name": "Copy secret.py",
Expand Down Expand Up @@ -224,6 +212,10 @@
"name": "install Kerberos",
"run": "sudo apt update\nsudo apt install -y krb5-user\n"
},
{
"name": "Install coverage",
"run": "uv pip install pytest-cov"
},
{
"name": "Run tests (Fork)",
"if": "github.repository_owner != 'tjcsl'",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ package-lock.json
# Virtual environments
venv/
.venv/

# uv produced requirements.txt (platform dependent)
requirements.txt
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
name: Validate Python
- id: trailing-whitespace
- id: mixed-line-ending
args: ["--fix=lf"]
- id: check-toml
- id: check-yaml
- id: detect-private-key
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.10
hooks:
# Update the uv lockfile
- id: uv-lock
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
37 changes: 17 additions & 20 deletions ci/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ env:
node_versions: &node_versions
- 12.x

python_setup: &python_setup
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

repo_setup: &repo_setup
name: Set up repo
uses: actions/checkout@v2
Expand All @@ -43,23 +37,23 @@ env:
with:
fetch-depth: 0

setup_pip_cache: &setup_pip_cache
name: Set up pip cache
uses: actions/cache@v2
setup_uv_cache: &setup_uv_cache
name: Set up uv
uses: astral-sh/setup-uv@v3
with:
path: ~/.cache/pip
key: pip-${{ matrix.python-version }}
enable-cache: true

python_setup: &python_setup
name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

setup_packages: &setup_packages
name: Set up packages
run: |
set -e
pip install -U pip setuptools wheel
pip install -U \
pre-commit coveralls pyyaml pytest-django
pip install -U -r requirements.txt
uv sync --locked
# change path and env vars
source .venv/bin/activate
echo "PATH=$PATH" >> $GITHUB_ENV
.copy_secret: &copy_secret
Expand All @@ -77,8 +71,8 @@ jobs:

steps:
- *repo_setup
- *setup_uv_cache
- *python_setup
- *setup_pip_cache
- *setup_packages
- *copy_secret

Expand All @@ -96,8 +90,8 @@ jobs:
steps:
# We need the full history so we can validate commit messages.
- *repo_setup_fetch_all
- *setup_uv_cache
- *python_setup
- *setup_pip_cache
- *setup_packages
- *copy_secret

Expand Down Expand Up @@ -164,8 +158,8 @@ jobs:

steps:
- *repo_setup
- *setup_uv_cache
- *python_setup
- *setup_pip_cache
- *setup_packages
- *copy_secret

Expand Down Expand Up @@ -197,6 +191,9 @@ jobs:
sudo apt update
sudo apt install -y krb5-user
- name: Install coverage
run: uv pip install pytest-cov

# Tests
- name: Run tests (Fork)
if: github.repository_owner != 'tjcsl'
Expand Down
16 changes: 9 additions & 7 deletions config/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
FROM python:3.8.19-alpine3.18

ENV TZ America/New_York
ENV C_FORCE_ROOT true
ENV TZ=America/New_York
ENV C_FORCE_ROOT=true

COPY config/krb5.conf /etc/krb5.conf
COPY requirements.txt .
COPY requirements-dev.txt .
COPY pyproject.toml .

COPY --from=ghcr.io/astral-sh/uv:0.4.10 /uv /bin/uv

RUN apk update && \
apk add bash git curl build-base libpq-dev freetype-dev libffi-dev ruby-full libmagic krb5 kinit rsync nodejs npm tzdata libxml2-dev libxslt-dev && \
npm install -g sass && \
ln -s /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
pip3 install -Ir requirements.txt && \
pip3 install -Ir requirements-dev.txt && \
rm requirements.txt requirements-dev.txt
# note that this also includes dev dependencies: pass --no-dev to exclude them
uv sync --no-install-project

ENV PATH="/.venv/bin:${PATH}"

WORKDIR /ion
28 changes: 28 additions & 0 deletions intranet/apps/oauth/migrations/0010_auto_20240918_1233.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.25 on 2024-09-18 16:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('oauth', '0009_cslapplication_post_logout_redirect_uris'),
]

operations = [
migrations.AddField(
model_name='cslapplication',
name='allowed_origins',
field=models.TextField(blank=True, default='', help_text='Allowed origins list to enable CORS, space separated'),
),
migrations.AddField(
model_name='cslapplication',
name='hash_client_secret',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='cslapplication',
name='post_logout_redirect_uris',
field=models.TextField(blank=True, default='', help_text='Allowed Post Logout URIs list, space separated'),
),
]
28 changes: 12 additions & 16 deletions intranet/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import re
import sys
from typing import Any, Dict, List, Tuple # noqa
from typing import Any, Dict, List

import celery.schedules
import pytz
Expand All @@ -12,11 +12,7 @@
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration

from ..utils import helpers # pylint: disable=wrong-import-position # noqa

if sys.version_info < (3, 5):
# Require Python 3.5+
raise Exception("Python 3.5 or higher is required.")
from ..utils import helpers

# Month (1-indexed) after which a new school year begins
# July = 7
Expand All @@ -38,24 +34,24 @@

# When school is scheduled to start and end
SCHOOL_START_DATE = datetime.date(start_school_year,
8, 19 # UPDATE THIS! Value when last updated: August 19, 2024 # noqa: E128
) # noqa: E124
8, 19 # UPDATE THIS! Value when last updated: August 19, 2024
)
SCHOOL_END_DATE = datetime.date(end_school_year,
6, 11 # UPDATE THIS! Value when last updated: June 11, 2025 # noqa: E128
) # noqa: E124
6, 11 # UPDATE THIS! Value when last updated: June 11, 2025
)

# Dates when hoco starts and ends
HOCO_START_DATE = datetime.date(start_school_year,
9, 21 # UPDATE THIS! Value when last updated: September 21, 2024 # noqa: E128
) # noqa: E124
9, 21 # UPDATE THIS! Value when last updated: September 21, 2024
)
HOCO_END_DATE = datetime.date(start_school_year,
9, 29 # UPDATE THIS! Value when last updated: September 29, 2024 # noqa: E128
) # noqa: E124
9, 29 # UPDATE THIS! Value when last updated: September 29, 2024
)

# Date of tjSTAR
TJSTAR_DATE = datetime.date(end_school_year,
5, 21 # UPDATE THIS! Value when last updated: May 21, 2024 # noqa: E128
) # noqa: E124
5, 21 # UPDATE THIS! Value when last updated: May 21, 2024
)

# When to start showing the tjSTAR banner
TJSTAR_BANNER_START_DATE = TJSTAR_DATE - datetime.timedelta(days=4)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion intranet/templates/bus/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ <h1>Error</h1>
</div>

{% block js %}
<script src="{% static 'js/game.js' %}"></script>
<script src="{% static 'js/game.min.js' %}"></script>
{% endblock %}

<script>
Expand Down
Loading

0 comments on commit 8c3c7c0

Please sign in to comment.