Skip to content

Commit

Permalink
Merge pull request #205 from DemocracyClub/upgrades202409
Browse files Browse the repository at this point in the history
Migrate to python 3.12
  • Loading branch information
chris48s authored Sep 10, 2024
2 parents 781d14f + 4b75902 commit 8309e65
Show file tree
Hide file tree
Showing 13 changed files with 192 additions and 169 deletions.
35 changes: 18 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ orbs:
jobs:
install_and_update_dependencies:
docker:
- image: cimg/python:3.10
- image: cimg/python:3.12
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v3-dependencies-{{ checksum "Pipfile.lock" }}
- v3-dependencies-default
- v4-dependencies-{{ checksum "Pipfile.lock" }}
- v4-dependencies-default
- run: &install-pipenv pip install -U pipenv pip --quiet --no-input
- run: pipenv install --dev
- run: pip install -U poetry
- run: pipenv sync --dev
- run: pipenv check # before save_cache so an insecure cache is never saved
- run: make lambda-layers/DependenciesLayer/requirements.txt
- persist_to_workspace:
Expand All @@ -27,25 +26,27 @@ jobs:
when: on_success
paths:
- ~/.local/share/virtualenvs/
key: v3-dependencies-{{ checksum "Pipfile.lock" }}
key: v4-dependencies-{{ checksum "Pipfile.lock" }}

run-tests:
docker:
- image: cimg/python:3.10
- image: cimg/python:3.12
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v3-dependencies-{{ checksum "Pipfile.lock" }}
- v3-dependencies-default
- v4-dependencies-{{ checksum "Pipfile.lock" }}
- v4-dependencies-default
- run: *install-pipenv
- run:
name: Ruff
command: pipenv run ruff .
name: Ruff Check
command: pipenv run ruff check .
- run:
name: Ruff format
command: pipenv run ruff format .
command: pipenv run ruff format . --check
- run: pipenv run djhtml --check .
- run: pipenv run pipenv verify
- run: pipenv run collectstatic
- run:
name: Run Tests
Expand All @@ -60,13 +61,13 @@ jobs:

sam_build:
docker:
- image: public.ecr.aws/sam/build-python3.10:latest
- image: public.ecr.aws/sam/build-python3.12:latest
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: ~/repo/
- run: pip install --upgrade pip
- run: pip install --upgrade pip setuptools
- run: pip install -r lambda-layers/DependenciesLayer/requirements.txt
- run: make collectstatic
- run: sam build ${DASH_DASH_DEBUG}
Expand All @@ -76,7 +77,7 @@ jobs:

sam_deploy:
docker:
- image: cimg/python:3.10
- image: cimg/python:3.12
working_directory: ~/repo/
parameters:
dc-environment:
Expand All @@ -100,8 +101,8 @@ jobs:
at: ~/repo/
- restore_cache:
keys:
- v3-dependencies-{{ checksum "Pipfile.lock" }}
- v3-dependencies-default
- v4-dependencies-{{ checksum "Pipfile.lock" }}
- v4-dependencies-default
- run: *install-pipenv
- run: pip install aws-sam-cli

Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10
3.12
9 changes: 5 additions & 4 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ sentry-sdk = "*"
django-pipeline = "*"
whitenoise = "*"
libsass = "*"
pip = "*"
install = "*"
dc-design-system = {ref = "0.1.1", git = "https://github.com/DemocracyClub/design-system.git"}
django-sesame = "*"
psycopg2-binary = "*"
Expand All @@ -22,12 +20,13 @@ requests = "*"
django-apiblueprint-view = "<3.0"
django-debug-toolbar = "*"
python-memcached = "*"
djangorestframework = "*"
certifi = ">2022.9.24"
django-cors-headers = "*"
typing-extensions = ">=3.7.4"
dc-logging-utils = {file = "https://github.com/DemocracyClub/dc_logging/archive/refs/tags/1.0.2.tar.gz"}
urllib3 = "<2"
setuptools = "*"
djhtml = "==3.0.6"

[dev-packages]
pre-commit = "*"
Expand All @@ -44,9 +43,10 @@ ipdb = "*"
pytest-socket = "==0.6.0"
wheel = ">0.37.0"
ruff = "==0.1.6"
uvicorn = "==0.30.6"

[requires]
python_version = "3.10"
python_version = "3.12"

[pipenv]
allow_prereleases = true
Expand All @@ -56,3 +56,4 @@ collectstatic = "python manage.py collectstatic -c --noinput"
pytest = "pytest"
coveralls = "coveralls"
migratedb = "python manage.py migrate --noinput"
start = "bash -c \"(cd api_endpoints/v1_postcode_lookup/ && uvicorn app:app --reload)\""
107 changes: 61 additions & 46 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
This section assumes a working python 3.8 environment with Pipenv installed.

* `cp ec_api/settings/local.py.example ec_api/settings/local.py`
* Install Python dependencies: `pipenv install --dev`
* Install Python dependencies:
* `pipenv install --dev`
* `pip install -r api_endpoints/v1_postcode_lookup/requirements.txt`
* Run the test suite: `pytest`
* Run lint checks: `ruff .`
* Auto-format: `ruff format .`

## Run application

- Frontend: `./mange.py runserver`
- API: `pipenv run start`

## Pre-commit

Using a pre-commit hook is suggested when working on this project to catch
Expand Down
2 changes: 1 addition & 1 deletion api_endpoints/api_auth/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
psycopg2-binary==2.9.6
psycopg2-binary==2.9.9
6 changes: 3 additions & 3 deletions ec_api/apps/api_docs/templates/api_docs/api_docs_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

{% block content %}

{% block api_docs_content %}
{% include 'api_docs/docs_parent.html' %}
{% endblock %}
{% block api_docs_content %}
{% include 'api_docs/docs_parent.html' %}
{% endblock %}

{% endblock %}
Loading

0 comments on commit 8309e65

Please sign in to comment.