-
Notifications
You must be signed in to change notification settings - Fork 15
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
Migrate to UV #2282
Migrate to UV #2282
Changes from 24 commits
a7a6621
7d853ad
915e49e
7528927
c9972e5
73ae578
c7e9d0c
8a69cf2
6d5d0d1
f554139
eefd6f3
1b0e3a6
7ad181a
4022a60
a7d51c9
d847929
315ee6b
1e57ca1
c85d8a3
ea89bad
d32a8a0
32f302a
69c7155
f43426b
c5b78be
f3d3075
f2138a2
bd91e5c
165b0fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -23,7 +23,7 @@ jobs: | |||||||||
node-version: '18' | ||||||||||
|
||||||||||
- restore_cache: | ||||||||||
key: v3-dependencies-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/testing.txt" }}-{{ checksum "requirements/cdk.txt" }} | ||||||||||
key: v3-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "uv.lock" }} | ||||||||||
|
||||||||||
- run: | ||||||||||
name: Install node node_modules | ||||||||||
|
@@ -35,22 +35,15 @@ jobs: | |||||||||
name: Install app dependencies | ||||||||||
command: | | ||||||||||
sudo apt update && sudo apt install -y gdal-bin python3-gdal python3-dev | ||||||||||
pyenv local $(ls ~/.pyenv/versions/) | ||||||||||
python -m venv .venv | ||||||||||
deployscripts/install_uv.sh | ||||||||||
uv venv --python 3.12 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we actually have opposite objectives here. My thinking here was: Previously we were doing all sorts of pyenv faffing to make sure we were using the right global python version:
I did at one point work out what we were trying to do there, but I've forgotten again. My thinking here is: Lets bin all that and invoke I don't mind trying what you suggested, but also I'd like to understand what advantage that gives us, or what problem what I've suggested causes. Happy to just talk about this one on a call or whatever. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I basically want to ensure we don't drift between [Circle]CI image version and the Python version in the venv. At the moment the build isn't going to fail if we use I would like to be in a position where we either only specify the python version in one place ( The |
||||||||||
. .venv/bin/activate | ||||||||||
pip install --upgrade pip | ||||||||||
pip install coveralls wheel | ||||||||||
pip install -r requirements/testing.txt | ||||||||||
uv sync --all-extras | ||||||||||
- run: | ||||||||||
name: Install Playwright | ||||||||||
command: | | ||||||||||
. .venv/bin/activate | ||||||||||
playwright install | ||||||||||
- run: | ||||||||||
name: Install CDK Python dependencies | ||||||||||
command: | | ||||||||||
. .venv/bin/activate | ||||||||||
pip install -r requirements/cdk.txt | ||||||||||
- run: | ||||||||||
name: Pip safety check | ||||||||||
command: | | ||||||||||
|
@@ -60,7 +53,7 @@ jobs: | |||||||||
paths: | ||||||||||
- ./.venv | ||||||||||
- ./node_modules | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 9d49161 |
||||||||||
key: v3-dependencies-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/testing.txt" }}-{{ checksum "requirements/cdk.txt" }} | ||||||||||
key: v3-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "uv.lock" }} | ||||||||||
|
||||||||||
- run: | ||||||||||
name: Pre-test checks | ||||||||||
|
@@ -70,7 +63,8 @@ jobs: | |||||||||
python manage.py --version | ||||||||||
python manage.py check | ||||||||||
python manage.py makemigrations --check | ||||||||||
pip check | ||||||||||
uv lock --locked | ||||||||||
chris48s marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
uv pip check | ||||||||||
ruff format . --check | ||||||||||
ruff check . | ||||||||||
git ls-files '*.html' | xargs djhtml --check | ||||||||||
|
@@ -85,6 +79,7 @@ jobs: | |||||||||
name: Submit coverage | ||||||||||
command: | | ||||||||||
. .venv/bin/activate | ||||||||||
uv pip install coveralls | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered moving this to a package in our manifest, but I can't really be bothered. I'm not sure how to meaningfully review a bump, for example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be collapsed into one line with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||
coveralls | ||||||||||
|
||||||||||
- store_artifacts: | ||||||||||
|
@@ -107,20 +102,20 @@ jobs: | |||||||||
steps: | ||||||||||
- checkout | ||||||||||
- restore_cache: | ||||||||||
key: v3-machine-dependencies-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/testing.txt" }}-{{ checksum "requirements/cdk.txt" }} | ||||||||||
key: v3-machine-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "uv.lock" }} | ||||||||||
- run: | ||||||||||
name: Install CDK Python dependencies | ||||||||||
command: | | ||||||||||
pyenv local $(ls -1 /opt/circleci/.pyenv/versions | grep 3.12) | ||||||||||
python -m venv .venv | ||||||||||
deployscripts/install_uv.sh | ||||||||||
uv venv --python 3.12 | ||||||||||
. .venv/bin/activate | ||||||||||
pip install -r requirements/cdk.txt | ||||||||||
uv sync --extra cdk --no-dev | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, Upstream feature request: astral-sh/uv#8292 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: We should now be able to upgrade to UV 0.4.27 which adds the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, so there's a lot going on in c5b78be . As of UV 0.4.27 UV now has ..although there is obviously a lot of overlap between these two concepts. Switching from The I think this is a pretty good microcosm of what we're getting involved in here. Both in terms of the rough and the smooth (or the ruff and the smooth, if you prefer :badpundog: ). On the one hand, uv is moving quickly 🚀 A feature we wanted ended up in a release within a week or so and it was already something they were looking at before they triaged the issue. I suspect this will all shake out by the time they're offering any sort of stability but I reckon there will be some more churn between now and then. I will also note that this whole thing is basically something poetry went through over a longer timeframe before they really got it right. ..anyhooo, in c5b78be I have
|
||||||||||
|
||||||||||
- save_cache: | ||||||||||
paths: | ||||||||||
- ./.venv | ||||||||||
- ./node_modules | ||||||||||
key: v3-machine-dependencies-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/testing.txt" }}-{{ checksum "requirements/cdk.txt" }} | ||||||||||
key: v3-machine-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "uv.lock" }} | ||||||||||
|
||||||||||
- run: | ||||||||||
name: CDK version | ||||||||||
|
@@ -156,17 +151,16 @@ jobs: | |||||||||
steps: | ||||||||||
- checkout | ||||||||||
- restore_cache: | ||||||||||
key: v3-machine-dependencies-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/testing.txt" }}-{{ checksum "requirements/cdk.txt" }} | ||||||||||
key: v3-machine-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "uv.lock" }} | ||||||||||
- run: | ||||||||||
name: CDK deploy | ||||||||||
command: | | ||||||||||
pyenv local $(ls -1 /opt/circleci/.pyenv/versions | grep 3.12) | ||||||||||
. .venv/bin/activate | ||||||||||
npx cdk deploy --all --require-approval never --concurrency 3 | ||||||||||
- save_cache: | ||||||||||
paths: | ||||||||||
- .cdk.out | ||||||||||
key: v3-machine-dependencies-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/testing.txt" }}-{{ checksum "requirements/cdk.txt" }} | ||||||||||
key: v3-machine-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "uv.lock" }} | ||||||||||
- slack/notify: | ||||||||||
event: fail | ||||||||||
template: basic_fail_1 | ||||||||||
|
@@ -192,11 +186,10 @@ jobs: | |||||||||
- node/install: | ||||||||||
node-version: '18' | ||||||||||
- restore_cache: | ||||||||||
key: v3-dependencies-{{ checksum "requirements/base.txt" }}-{{ checksum "requirements/testing.txt" }}-{{ checksum "requirements/cdk.txt" }} | ||||||||||
key: v3-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "uv.lock" }} | ||||||||||
- run: | ||||||||||
name: "Code Deploy: Create deployment group" | ||||||||||
command: | | ||||||||||
pyenv local $(ls ~/.pyenv/versions/) | ||||||||||
. .venv/bin/activate | ||||||||||
python deployscripts/create_deployment_group.py | ||||||||||
- run: | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: UV Lock | ||
chris48s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
on: | ||
push: | ||
branches: | ||
- 'dependabot/**' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
|
||
- run: ./deployscripts/install_uv.sh | ||
|
||
- run: uv lock | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: Update uv.lock |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"base_ami_id": "ami-0c40c7ef04b5ab961", | ||
"recipe_version": "0.0.35" | ||
"recipe_version": "0.0.41" | ||
chris48s marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name: AddUser | ||
description: Adds a system user | ||
schemaVersion: 1.0 | ||
component_version: 0.0.4 | ||
component_version: 0.0.5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What changed here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing. When I pushed stuff to the dev AWS account to test it, the image builder threw errors saying there was already a different 0.0.4 of I don't really know what a good pattern is for managing this stuff, but given I don't think there's really any downside to bumping a version even if nothing changed, keeping them aligned across AWS accounts seems sensible to me. |
||
parameters: | ||
- username: | ||
type: string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -xeE | ||
|
||
UV_CONSTRAINT=">=0.4.0,<0.5.0" | ||
|
||
if [ "$CI" = "true" ]; then | ||
pip install uv"$UV_CONSTRAINT" | ||
else | ||
sudo PIP_BREAK_SYSTEM_PACKAGES=1 pip install uv"$UV_CONSTRAINT" | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a couple of things to talk about in this file:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting. I know we're pinning exact versions in
pyproject.toml
now, but wouldn't the lock file be updated in this case too? What's your thinking in using both files for the cache key here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good question. I went back and forth on this in my own head.
My thinking on this was that because dependabot can't bump
uv.lock
it will try to push commits that changepyproject.toml
but don't change the lockfile this might be sensible. Maybe it is irrelevant though.uv lock --locked
should ensure we just fail the build early doors on those commits anyway.I've removed it in 46d6de1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the only other consideration here is the python version. At the moment we tend to pump the
v[n]
prefix when we bump python versions, but includingpyproject.toml
would mean we bust the cash a lot more often. Not a big deal, I think what you currently have is reasonable 👍