Skip to content

Commit 564f66b

Browse files
feat: convert to a uv based workflow
1 parent 2b4794b commit 564f66b

File tree

16 files changed

+3082
-227
lines changed

16 files changed

+3082
-227
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,24 @@
3131
"uses": "actions/checkout@v2"
3232
},
3333
{
34-
"name": "Set up Python ${{ matrix.python-version }}",
35-
"uses": "actions/setup-python@v2",
36-
"with": {
37-
"python-version": "${{ matrix.python-version }}"
38-
}
34+
"name": "Set up uv",
35+
"uses": "astral-sh/setup-uv@v5"
3936
},
4037
{
41-
"name": "Set up pip cache",
42-
"uses": "actions/cache@v2",
43-
"with": {
44-
"path": "~/.cache/pip",
45-
"key": "pip-${{ matrix.python-version }}"
46-
}
38+
"name": "Set up Python ${{ matrix.python-version }}",
39+
"run": "uv python install ${{ matrix.python-version }}"
4740
},
4841
{
4942
"name": "Set up packages",
50-
"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"
43+
"run": "uv sync --group ci --locked"
5144
},
5245
{
5346
"name": "Copy secret.py",
5447
"run": "cp intranet/settings/ci_secret.py intranet/settings/secret.py"
5548
},
5649
{
5750
"name": "Run pre-commit",
58-
"run": "pre-commit run --all-files"
51+
"run": "uv run pre-commit run --all-files"
5952
}
6053
]
6154
},
@@ -78,40 +71,33 @@
7871
}
7972
},
8073
{
81-
"name": "Set up Python ${{ matrix.python-version }}",
82-
"uses": "actions/setup-python@v2",
83-
"with": {
84-
"python-version": "${{ matrix.python-version }}"
85-
}
74+
"name": "Set up uv",
75+
"uses": "astral-sh/setup-uv@v5"
8676
},
8777
{
88-
"name": "Set up pip cache",
89-
"uses": "actions/cache@v2",
90-
"with": {
91-
"path": "~/.cache/pip",
92-
"key": "pip-${{ matrix.python-version }}"
93-
}
78+
"name": "Set up Python ${{ matrix.python-version }}",
79+
"run": "uv python install ${{ matrix.python-version }}"
9480
},
9581
{
9682
"name": "Set up packages",
97-
"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"
83+
"run": "uv sync --group ci --locked"
9884
},
9985
{
10086
"name": "Copy secret.py",
10187
"run": "cp intranet/settings/ci_secret.py intranet/settings/secret.py"
10288
},
10389
{
10490
"name": "Regenerate workflow YAML file and check for changes",
105-
"run": "./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py"
91+
"run": "uv run ./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py"
10692
},
10793
{
10894
"name": "Check for changes to CI spec",
109-
"run": "./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py"
95+
"run": "uv run ./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py"
11096
},
11197
{
11298
"name": "Validate PR commit messages",
11399
"if": "github.event_name == 'pull_request'",
114-
"run": "./scripts/validate-commit-messages.py ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
100+
"run": "uv run ./scripts/validate-commit-messages.py ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
115101
},
116102
{
117103
"name": "Validate push commit messages",
@@ -120,7 +106,7 @@
120106
},
121107
{
122108
"name": "Build docs",
123-
"run": "./scripts/build_ensure_no_changes.sh ./scripts/build_docs.sh"
109+
"run": "uv run ./scripts/build_ensure_no_changes.sh ./scripts/build_docs.sh"
124110
},
125111
{
126112
"name": "Push docs",
@@ -179,23 +165,16 @@
179165
"uses": "actions/checkout@v2"
180166
},
181167
{
182-
"name": "Set up Python ${{ matrix.python-version }}",
183-
"uses": "actions/setup-python@v2",
184-
"with": {
185-
"python-version": "${{ matrix.python-version }}"
186-
}
168+
"name": "Set up uv",
169+
"uses": "astral-sh/setup-uv@v5"
187170
},
188171
{
189-
"name": "Set up pip cache",
190-
"uses": "actions/cache@v2",
191-
"with": {
192-
"path": "~/.cache/pip",
193-
"key": "pip-${{ matrix.python-version }}"
194-
}
172+
"name": "Set up Python ${{ matrix.python-version }}",
173+
"run": "uv python install ${{ matrix.python-version }}"
195174
},
196175
{
197176
"name": "Set up packages",
198-
"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"
177+
"run": "uv sync --group ci --locked"
199178
},
200179
{
201180
"name": "Copy secret.py",
@@ -227,24 +206,24 @@
227206
{
228207
"name": "Run tests (Fork)",
229208
"if": "github.repository_owner != 'tjcsl'",
230-
"run": "coverage run -a ./manage.py test --noinput --parallel 4"
209+
"run": "uv run coverage run -a ./manage.py test --noinput --parallel 4"
231210
},
232211
{
233212
"name": "Run tests (PR/Push)",
234213
"if": "github.repository_owner == 'tjcsl'",
235-
"run": "coverage run -a ./manage.py test --noinput"
214+
"run": "uv run coverage run -a ./manage.py test --noinput"
236215
},
237216
{
238217
"name": "Check for unmigrated changes",
239-
"run": "coverage run -a ./manage.py makemigrations --noinput --check"
218+
"run": "uv run coverage run -a ./manage.py makemigrations --noinput --check"
240219
},
241220
{
242221
"name": "Migrate database",
243-
"run": "coverage run -a ./manage.py migrate"
222+
"run": "uv run coverage run -a ./manage.py migrate"
244223
},
245224
{
246225
"name": "Collect static files",
247-
"run": "coverage run -a ./manage.py collectstatic --noinput -v 0"
226+
"run": "uv run coverage run -a ./manage.py collectstatic --noinput -v 0"
248227
},
249228
{
250229
"name": "Report coverage to Coveralls",
@@ -256,7 +235,7 @@
256235
{
257236
"name": "Build coverage XML file",
258237
"if": "github.repository_owner == 'tjcsl' && github.event_name != 'pull_request'",
259-
"run": "coverage xml"
238+
"run": "uv run coverage xml"
260239
},
261240
{
262241
"name": "Report coverage to Codacy",

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ repos:
1616
- repo: https://github.com/pre-commit/pre-commit-hooks
1717
rev: v4.4.0
1818
hooks:
19-
- id: check-ast
20-
name: Validate Python
2119
- id: trailing-whitespace
2220
- id: mixed-line-ending
2321
args: ["--fix=lf"]

.python-version

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

ci/spec.yml

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ env:
2727
node_versions: &node_versions
2828
- 12.x
2929

30-
python_setup: &python_setup
31-
name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v2
33-
with:
34-
python-version: ${{ matrix.python-version }}
35-
3630
repo_setup: &repo_setup
3731
name: Set up repo
3832
uses: actions/checkout@v2
@@ -43,24 +37,17 @@ env:
4337
with:
4438
fetch-depth: 0
4539

46-
setup_pip_cache: &setup_pip_cache
47-
name: Set up pip cache
48-
uses: actions/cache@v2
49-
with:
50-
path: ~/.cache/pip
51-
key: pip-${{ matrix.python-version }}
40+
setup_uv_cache: &setup_uv_cache
41+
name: Set up uv
42+
uses: astral-sh/setup-uv@v5
43+
44+
python_setup: &python_setup
45+
name: Set up Python ${{ matrix.python-version }}
46+
run: uv python install ${{ matrix.python-version }}
5247

5348
setup_packages: &setup_packages
5449
name: Set up packages
55-
run: |
56-
set -e
57-
58-
pip install -U pip setuptools wheel
59-
pip install -U \
60-
pre-commit coveralls pyyaml pytest-django
61-
pip install -U -r requirements.txt
62-
63-
echo "PATH=$PATH" >> $GITHUB_ENV
50+
run: uv sync --group ci --locked
6451

6552
.copy_secret: &copy_secret
6653
name: Copy secret.py
@@ -77,13 +64,13 @@ jobs:
7764

7865
steps:
7966
- *repo_setup
67+
- *setup_uv_cache
8068
- *python_setup
81-
- *setup_pip_cache
8269
- *setup_packages
8370
- *copy_secret
8471

8572
- name: Run pre-commit
86-
run: 'pre-commit run --all-files'
73+
run: 'uv run pre-commit run --all-files'
8774

8875
build:
8976
runs-on: ubuntu-latest
@@ -96,31 +83,31 @@ jobs:
9683
steps:
9784
# We need the full history so we can validate commit messages.
9885
- *repo_setup_fetch_all
86+
- *setup_uv_cache
9987
- *python_setup
100-
- *setup_pip_cache
10188
- *setup_packages
10289
- *copy_secret
10390

10491
- name: Regenerate workflow YAML file and check for changes
105-
run: ./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py
92+
run: uv run ./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py
10693

10794
# Check for changes to CI spec
10895
- name: Check for changes to CI spec
109-
run: ./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py
96+
run: uv run ./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py
11097

11198
# Validate commit messages
11299
- name: Validate PR commit messages
113100
# Validate commit messages for PRs
114101
if: "github.event_name == 'pull_request'"
115-
run: ./scripts/validate-commit-messages.py ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
102+
run: uv run ./scripts/validate-commit-messages.py ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
116103
- name: Validate push commit messages
117104
# Validate commit messages for forks and branches that aren't dev or master
118105
if: "github.event_name == 'push' && (github.repository_owner != 'tjcsl' || github.ref != 'refs/heads/master' || github.ref != 'refs/heads/dev')"
119106
run: 'git fetch origin ${{ github.event.before }} && ./scripts/validate-commit-messages.py ${{ github.event.before }}..${{ github.event.after }}'
120107

121108
# Build/push docs
122109
- name: Build docs
123-
run: ./scripts/build_ensure_no_changes.sh ./scripts/build_docs.sh
110+
run: uv run ./scripts/build_ensure_no_changes.sh ./scripts/build_docs.sh
124111
- name: Push docs
125112
# Only run for pushes to the main Ion repo
126113
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'tjcsl' && matrix.python-version == 3.8
@@ -164,8 +151,8 @@ jobs:
164151

165152
steps:
166153
- *repo_setup
154+
- *setup_uv_cache
167155
- *python_setup
168-
- *setup_pip_cache
169156
- *setup_packages
170157
- *copy_secret
171158

@@ -197,20 +184,21 @@ jobs:
197184
sudo apt update
198185
sudo apt install -y krb5-user
199186
187+
200188
# Tests
201189
- name: Run tests (Fork)
202190
if: github.repository_owner != 'tjcsl'
203-
run: coverage run -a ./manage.py test --noinput --parallel 4
191+
run: uv run coverage run -a ./manage.py test --noinput --parallel 4
204192
- name: Run tests (PR/Push)
205193
if: github.repository_owner == 'tjcsl' # Run single-threaded for accurate coverage reporting on Ion GitHub
206-
run: coverage run -a ./manage.py test --noinput
194+
run: uv run coverage run -a ./manage.py test --noinput
207195
# Check for unmigrated changes
208196
- name: Check for unmigrated changes
209-
run: coverage run -a ./manage.py makemigrations --noinput --check
197+
run: uv run coverage run -a ./manage.py makemigrations --noinput --check
210198
- name: Migrate database
211-
run: coverage run -a ./manage.py migrate
199+
run: uv run coverage run -a ./manage.py migrate
212200
- name: Collect static files
213-
run: coverage run -a ./manage.py collectstatic --noinput -v 0
201+
run: uv run coverage run -a ./manage.py collectstatic --noinput -v 0
214202

215203
# Coveralls
216204
- name: Report coverage to Coveralls
@@ -221,7 +209,7 @@ jobs:
221209
# Codacy
222210
- name: Build coverage XML file
223211
if: github.repository_owner == 'tjcsl' && github.event_name != 'pull_request'
224-
run: coverage xml
212+
run: uv run coverage xml
225213
- name: Report coverage to Codacy
226214
uses: codacy/codacy-coverage-reporter-action@master
227215
if: github.repository_owner == 'tjcsl' && github.event_name != 'pull_request'

config/docker/Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
FROM python:3.8.19-alpine3.18
22

3-
ENV TZ America/New_York
4-
ENV C_FORCE_ROOT true
3+
ENV TZ=America/New_York
4+
ENV C_FORCE_ROOT=true
55

66
COPY config/krb5.conf /etc/krb5.conf
7-
COPY requirements.txt .
8-
COPY requirements-dev.txt .
7+
COPY pyproject.toml .
8+
9+
COPY --from=ghcr.io/astral-sh/uv:0.6 /uv /bin/uv
910

1011
RUN apk update && \
1112
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 && \
1213
npm install -g sass && \
1314
ln -s /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
14-
pip3 install -Ir requirements.txt && \
15-
pip3 install -Ir requirements-dev.txt && \
16-
rm requirements.txt requirements-dev.txt
15+
# note that this also includes dev dependencies: pass --no-dev to exclude them
16+
uv sync
1717

1818
WORKDIR /ion

config/docker/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.9'
2-
31
services:
42
redis:
53
container_name: intranet_redis

config/docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export PYTHONUNBUFFERED=1 # Don't buffer Django output
1212
# Wrap the run command in a loop so that it restarts if it crashes, e.g. due to a syntax error
1313
while true
1414
do
15-
python3 manage.py run 0.0.0.0:8080 # Custom run command that skips system checks for performance
15+
uv run manage.py run 0.0.0.0:8080 # Custom run command that skips system checks for performance
1616
sleep 1
1717
done

0 commit comments

Comments
 (0)