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 Sep 16, 2024
1 parent 2b4794b commit 3292d3f
Show file tree
Hide file tree
Showing 9 changed files with 2,822 additions and 154 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
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
89 changes: 65 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ authors = [
]
requires-python = ">=3.8"
version = "1.0"
dynamic = ["dependencies"]
license = { text = "GPLv2+" }
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand All @@ -16,32 +15,74 @@ classifiers=[
"Programming Language :: Python :: 3.8",
"Framework :: Django :: 3.2",
]
dependencies = [
"django~=3.2",
"django-cacheops~=7.0",
"django-cors-headers~=3.13",
"django-debug-toolbar~=3.6",
"django-extensions~=3.2",
"django-formtools~=2.3",
"django-inline-svg~=0.1",
"django-maintenance-mode~=0.16",
"django-oauth-toolkit~=2.3",
"django-pipeline~=2.0",
"django-prometheus~=2.2",
"django-redis-cache~=3.0",
"django-redis-sessions~=0.6",
"django-referrer-policy>=1.0",
"django-requestlogging-redux~=1.2",
"django-simple-history~=3.1",
"django-user-agents~=0.4",
"django-widget-tweaks~=1.4",
"djangorestframework~=3.14",
"gunicorn~=22.0",
"hiredis~=2.0",
"flower>=2.0.1",
"beautifulsoup4~=4.11",
"lxml>=5.3.0",
"pexpect~=4.8",
"prometheus-client~=0.17",
"psycopg2~=2.9",
"pycryptodome~=3.19",
"pyrankvote~=2.0.5",
"pysftp~=0.2",
"python-dateutil~=2.8",
"python-magic~=0.4",
"python-pam~=2.0",
"reportlab~=3.6",
"requests~=2.32",
"requests-oauthlib~=1.3",
"sentry-sdk~=1.15",
"six~=1.16",
"vine>=5.1.0",
"xhtml2pdf~=0.2",
"channels-redis~=3.4",
"celery~=5.2",
"bleach~=5.0",
"bcrypt>=4.2.0",
"babel>=2.16.0",
"argon2-cffi>=23.1.0",
]

[project.urls]
Repository = "https://github.com/tjcsl/ion"
[tool.setuptools]

[tool.uv]
dev-dependencies = [
"pre-commit>=3.5.0",
"pytest>=8.3.3",
"pytest-django>=4.9.0",
"sphinx-bootstrap-theme>=0.8.1",
"sphinx>=7.1.2",
"whitenoise>=6.7.0",
]

[tool.hatch.build.targets.wheel]
packages = ["intranet", "migrations"]
[tool.setuptools.dynamic]
dependencies = {file = "requirements.txt"}
[tool.black]
line-length = 150
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| media
| migrations
| secret.*
| stubs
)/
'''

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.ruff]
extend-exclude = [
Expand Down
5 changes: 0 additions & 5 deletions requirements-dev.txt

This file was deleted.

Loading

0 comments on commit 3292d3f

Please sign in to comment.