-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace pipenv with UV in CircleCI config
- Loading branch information
Showing
5 changed files
with
53 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,11 @@ version: 2.1 | |
orbs: | ||
python: circleci/[email protected] | ||
|
||
commands: | ||
install_uv: | ||
steps: | ||
- run: pip install --upgrade uv">=0.4.27,<0.5.0" | ||
|
||
jobs: | ||
install_and_update_dependencies: | ||
docker: | ||
|
@@ -13,36 +18,36 @@ jobs: | |
- checkout | ||
- restore_cache: | ||
keys: | ||
- v8-dependencies-{{ checksum "Pipfile.lock" }}-{{ checksum "thumbs/Pipfile.lock" }} | ||
- v8-dependencies-default | ||
# Ensure pip and pipenv are installed | ||
- run: | ||
name: Install pipenv | ||
command: | | ||
pip install --upgrade pipenv==2024.0.1 pip --quiet --no-input | ||
- v9-dependencies-{{ checksum "uv.lock" }} | ||
- v9-dependencies-default | ||
- install_uv | ||
- run: | ||
name: Set up virtual environment | ||
command: | | ||
pipenv sync --dev | ||
uv sync --dev --no-python-downloads | ||
- run: pipenv run ruff check . | ||
- run: ./scripts/lint.sh | ||
- run: ./scripts/format.sh | ||
- run: make lambda-layers/DependenciesLayer/requirements.txt | ||
- run: npm install | ||
- run: npm run build | ||
- run: pipenv run collectstatic --settings electionleaflets.settings.testing | ||
- run: uv run python manage.py collectstatic --settings electionleaflets.settings.testing | ||
- persist_to_workspace: | ||
root: ~/repo/ | ||
paths: | ||
- lambda-layers/DependenciesLayer/requirements.txt | ||
- electionleaflets/static/ | ||
- electionleaflets/assets/ | ||
- run: | ||
name: Prune UV cache | ||
command: uv cache prune --ci | ||
- save_cache: | ||
when: on_success | ||
paths: | ||
- ~/.local/share/virtualenvs/ | ||
key: v8-dependencies-{{ checksum "Pipfile.lock" }}-{{ checksum "thumbs/Pipfile.lock" }} | ||
- ./.venv | ||
- ./node_modules | ||
- $HOME/.cache/uv | ||
key: v9-dependencies-{{ checksum "uv.lock" }} | ||
run-tests: | ||
docker: | ||
- image: cimg/python:3.12-browsers | ||
|
@@ -62,20 +67,20 @@ jobs: | |
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v8-dependencies-{{ checksum "Pipfile.lock" }} | ||
- run: pipenv run pipenv verify | ||
|
||
- run: pipenv run python manage.py check | ||
- v9-dependencies-{{ checksum "uv.lock" }} | ||
- install_uv | ||
- run: uv sync --no-python-downloads | ||
- run: uv run python manage.py check | ||
|
||
# TODO: enable this once we drop uk_political_parties package | ||
#- run: pipenv run python manage.py makemigrations --check | ||
#- run: uv run python manage.py makemigrations --check | ||
|
||
# Run tests | ||
- run: pipenv run playwright install --with-deps chromium | ||
- run: uv run playwright install --with-deps chromium | ||
- run: | ||
name: Run tests | ||
command: | | ||
pipenv run pytest | ||
uv run pytest | ||
- store_artifacts: | ||
path: test-results | ||
destination: test-results | ||
|
@@ -90,10 +95,10 @@ jobs: | |
- checkout | ||
- attach_workspace: | ||
at: ~/repo/ | ||
- run: pip install --upgrade pip | ||
- run: pip install -r deploy-requirements.txt | ||
- run: pip install -r lambda-layers/DependenciesLayer/requirements.txt | ||
- run: sam build ${DASH_DASH_DEBUG} | ||
- install_uv | ||
- run: uv sync --only-group deploy --no-python-downloads | ||
- run: make lambda-layers/DependenciesLayer/requirements.txt | ||
- run: sam build | ||
|
||
- persist_to_workspace: | ||
root: ~/repo/ | ||
|
@@ -128,22 +133,22 @@ jobs: | |
at: ~/repo/ | ||
- restore_cache: | ||
keys: | ||
- v8-dependencies-{{ checksum "Pipfile.lock" }} | ||
- v8-dependencies-default | ||
- v9-dependencies-{{ checksum "uv.lock" }} | ||
- v9-dependencies-default | ||
- run: | ||
name: Install pipenv | ||
name: Install UV | ||
command: | | ||
pip install --upgrade pipenv==2024.0.1 pip --quiet --no-input | ||
- run: pip install -r deploy-requirements.txt | ||
pip install --upgrade uv">=0.4.27,<0.5.0" --quiet --no-input | ||
- run: uv sync --only-group deploy --no-python-downloads | ||
- run: printenv DC_DEPLOY_NAME DJANGO_SETTINGS_MODULE SAM_CONFIG_FILE DC_ENVIRONMENT SAM_PUBLIC_CONFIG_ENV | ||
- run: printenv SECRET_KEY | md5sum | ||
- run: printenv AWS_ACCESS_KEY_ID | md5sum | ||
- run: sudo apt update && sudo apt install postgresql-client | ||
- run: PGPASSWORD=$DATABASE_PASS createdb --host $DATABASE_HOST --username $DATABASE_USER $POSTGRES_DATABASE_NAME || true | ||
- run: | ||
name: "pipenv run sam deploy # App: Lambda + API Gateway" | ||
name: "sam deploy # App: Lambda + API Gateway" | ||
command: | | ||
sam deploy ${DASH_DASH_DEBUG} \ | ||
uv run sam deploy ${DASH_DASH_DEBUG} \ | ||
--config-file ~/repo/${SAM_CONFIG_FILE} \ | ||
--config-env $DC_ENVIRONMENT \ | ||
--template-file ~/repo/.aws-sam/build/template.yaml \ | ||
|
@@ -161,18 +166,20 @@ jobs: | |
AppDomain='$PUBLIC_FQDN' \ | ||
AppLeafletImagesBucketName='$LEAFLET_IMAGES_BUCKET_NAME' \ | ||
" | ||
- run: pipenv run migratedb | ||
- run: pipenv run createcachetable | ||
- run: uv run python manage.py migrate | ||
- run: uv run python manage.py createcachetable | ||
- run: printenv LEAFLET_IMAGES_BUCKET_NAME | ||
- run: echo $LEAFLET_IMAGES_BUCKET_NAME > thumbs/LEAFLET_IMAGES_BUCKET_NAME | ||
- run: make thumbs/requirements.txt | ||
- run: pipenv run thumbs_sam_build | ||
- run: pipenv run sam validate --region eu-west-2 | ||
- run: | | ||
cd thumbs | ||
uv run sam build | ||
- run: uv run sam validate --region eu-west-2 | ||
|
||
- run: | ||
name: "Deploy thumbs function" | ||
command: | | ||
pipenv run sam deploy ${DASH_DASH_DEBUG} \ | ||
uv run sam deploy ${DASH_DASH_DEBUG} \ | ||
--config-file ~/repo/thumbs/${SAM_CONFIG_FILE} \ | ||
--config-env $DC_ENVIRONMENT \ | ||
--template-file ~/repo/thumbs/.aws-sam/build/ThumbsFunction/template.yml \ | ||
|
@@ -182,18 +189,18 @@ jobs: | |
- run: | ||
name: "Deploy thumbs function to eu-west-1 for lambda@edge" | ||
command: | | ||
pipenv run sam deploy ${DASH_DASH_DEBUG} \ | ||
uv run sam deploy ${DASH_DASH_DEBUG} \ | ||
--config-file ~/repo/thumbs/${SAM_CONFIG_FILE} \ | ||
--config-env $DC_ENVIRONMENT \ | ||
--template-file ~/repo/thumbs/.aws-sam/build/ThumbsFunction/template.yml \ | ||
--region us-east-1 | ||
- run: | ||
name: "pipenv run sam deploy # Public access: CDN + DNS" | ||
name: "uv run sam deploy # Public access: CDN + DNS" | ||
no_output_timeout: 20m # CloudFront can take longer than CircleCI's 10m default | ||
command: | | ||
pipenv run sam deploy ${DASH_DASH_DEBUG} \ | ||
uv run sam deploy ${DASH_DASH_DEBUG} \ | ||
--config-file ~/repo/${SAM_CONFIG_FILE} \ | ||
--config-env $SAM_PUBLIC_CONFIG_ENV \ | ||
--template-file ~/repo/public-access-template.yaml \ | ||
|
@@ -203,8 +210,7 @@ jobs: | |
PublicFqdn=$PUBLIC_FQDN \ | ||
LeafletsBucketName=$LEAFLET_IMAGES_BUCKET_NAME | ||
" | ||
- run: pip install -U boto3 pipenv==2024.0.1 --quiet --no-input | ||
- run: python thumbs/attach_lambda_triggers.py | ||
- run: uv run python thumbs/attach_lambda_triggers.py | ||
- run: | ||
name: "Publish a new Sentry Release" | ||
command: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
pipenv run ruff format . --check | ||
uv run ruff format . --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
pipenv run ruff check . | ||
uv run ruff check . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters