Skip to content

Commit

Permalink
Migrate to python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
matti-lamppu authored and MrThearMan committed Dec 8, 2023
1 parent 36e3c6f commit baf1497
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 387 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
DEBUG=True
ALLOWED_HOSTS=*
APP_LOGGING_LEVEL=INFO
SECRET_KEY=secret

DATABASE_URL=postgis://tvp:[email protected]:5555/tvp
REDIS_URL=redis://127.0.0.1:6379/0
ELASTICSEARCH_URL=http://localhost:9200

CORS_ALLOWED_ORIGINS=http://localhost:8000,https://local-tilavaraus.hel.fi:3000,https://local-tilavaraus.hel.fi:3001
CSRF_TRUSTED_ORIGINS=http://localhost:8000,https://local-tilavaraus.hel.fi:3000,https://local-tilavaraus.hel.fi:3001
Expand Down
32 changes: 24 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
name: "Run tests and SonarCloud scan"
runs-on: ubuntu-latest

defaults:
run:
shell: bash

services:
postgres:
image: postgis/postgis:13-3.3-alpine
Expand Down Expand Up @@ -59,22 +63,34 @@ jobs:
- name: "Checkout code"
uses: actions/checkout@v4
with:
# Disable shallow cloning to improving relevancy of reporting for SonarCloud
# Disable shallow cloning to improve relevancy of reporting in SonarCloud
fetch-depth: 0

- name: "Set up python"
id: setup-python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: "Install poetry"
run: pipx install "poetry==1.6.0"
run: curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.6.1 python - -y

- name: "Add poetry to PATH"
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: "Configure poetry"
run: poetry config virtualenvs.in-project true

- name: "Install GDAL"
run: |
sudo apt-get update
sudo apt install -y --no-install-recommends gdal-bin
- name: "Set up python"
uses: actions/setup-python@v4
- name: "Load cached poetry environment"
uses: actions/cache@v3
with:
cache: "poetry"
python-version: "3.11"
path: .venv
key: cache-venv-python${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-v1

- name: "Install dependencies"
run: poetry install
Expand All @@ -90,8 +106,8 @@ jobs:
DEBUG: true
SECRET_KEY: build_secret

# Without this workaround Sonar reports a warning about an incorrect source path; credits to linked-events
- name: "Override coverage report source path for Sonar"
# Without this workaround, SonarCloud reports a warning about an incorrect source path
- name: "Override coverage report source path for SonarCloud"
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml

- name: "SonarCloud Scan"
Expand Down
4 changes: 2 additions & 2 deletions common/typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, TypeAlias, Union
from typing import TYPE_CHECKING, Union

from django.contrib.auth.models import AnonymousUser
from django.core.handlers.wsgi import WSGIRequest
Expand All @@ -12,7 +12,7 @@
"GQLInfo",
]

AnyUser: TypeAlias = Union["User", AnonymousUser]
type AnyUser = Union["User", AnonymousUser] # noqa: UP007


class UserHintedWSGIRequest(WSGIRequest):
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim-bullseye AS base
FROM python:3.12-slim-bullseye AS base

# Make sure we build as the root user.
USER root
Expand Down
Loading

0 comments on commit baf1497

Please sign in to comment.