Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
33 changes: 0 additions & 33 deletions .style.yapf

This file was deleted.

22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ ENV USER=geoadmin
ENV GROUP=geoadmin
ENV INSTALL_DIR=/opt/service-control
ENV SRC_DIR=/usr/local/src/service-control
ENV PIPENV_VENV_IN_PROJECT=1

RUN apt-get -qq update > /dev/null \
&& apt-get -qq clean \
Expand All @@ -23,15 +22,16 @@ RUN apt-get -qq update > /dev/null \
&& apt-get -qq -y install \
# dev dependencies
binutils libproj-dev \
postgresql-client-common \
# silent the installation
> /dev/null \
&& apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install pipenv \
&& pipenv --version
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install uv

COPY Pipfile.lock Pipfile ${SRC_DIR}/
RUN cd ${SRC_DIR} && pipenv sync
COPY pyproject.toml uv.lock ${SRC_DIR}/
RUN cd ${SRC_DIR} && uv sync

COPY --chown=${USER}:${GROUP} app/ ${INSTALL_DIR}/app/

Expand All @@ -54,13 +54,13 @@ RUN apt-get -qq update > /dev/null \
# silent the install
> /dev/null \
&& apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install pipenv \
&& pipenv --version
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install uv

# Install all dev dependencies
COPY Pipfile.lock Pipfile ${INSTALL_DIR}/
RUN cd ${INSTALL_DIR} && pipenv sync --dev
COPY pyproject.toml uv.lock ${INSTALL_DIR}/
RUN cd ${INSTALL_DIR} && uv sync --dev

# this is only used with the docker-compose setup within CI
# to ensure that the app is only started once the DB container
Expand Down
47 changes: 22 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ GIT_TAG = `git describe --tags || echo "no version info"`
AUTHOR = $(USER)

# Imports the environment variables
## TODO if we call the file .env, then it'll be read by pipenv too
## which is good for running migrate
# ifneq ("$(wildcard .env)","")
# include .env
Expand All @@ -25,22 +24,24 @@ AUTHOR = $(USER)
# export
# endif

# Env file for dockerrun, defaults to .env.local / .env
export UV_ENV_FILE ?= $(if $(wildcard .env),.env,.env.default)

# Django specific
APP_SRC_DIR := app
DJANGO_MANAGER := $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py
DJANGO_MANAGER_DEBUG := -m debugpy --listen localhost:5678 --wait-for-client $(CURRENT_DIR)/$(APP_SRC_DIR)/manage.py

# Commands
PIPENV_RUN := pipenv run
PYTHON := $(PIPENV_RUN) python3
TEST := $(PIPENV_RUN) pytest
YAPF := $(PIPENV_RUN) yapf
ISORT := $(PIPENV_RUN) isort
PYLINT := $(PIPENV_RUN) pylint
MYPY := $(PIPENV_RUN) mypy
UV_RUN := uv run
PYTHON := $(UV_RUN)
TEST := $(UV_RUN) pytest
RUFF := $(UV_RUN) ruff
ISORT := $(UV_RUN) isort
MYPY := $(UV_RUN) mypy
PSQL := PGPASSWORD=postgres psql -h localhost -p 15433 -U postgres
PGRESTORE := PGPASSWORD=postgres pg_restore -h localhost -p 15433 -U postgres
BANDIT := $(PIPENV_RUN) bandit
BANDIT := $(UV_RUN) bandit

# Find all python files that are not inside a hidden directory (directory starting with .)
PYTHON_FILES := $(shell find $(APP_SRC_DIR) -type f -name "*.py" -print)
Expand All @@ -52,44 +53,40 @@ DOCKER_IMG_LOCAL_TAG := $(DOCKER_REGISTRY)/$(SERVICE_NAME):local-$(USER)-$(GIT_H
# AWS variables
AWS_DEFAULT_REGION = eu-central-1

# Env file for dockerrun, defaults to .env.local / .env
ENV_FILE ?= $(if $(wildcard .env.local),.env.local,.env)

.PHONY: ci
ci:
# Create virtual env with all packages for development using the Pipfile.lock
pipenv sync --dev
uv sync --dev

.PHONY: setup
setup: $(SETTINGS_TIMESTAMP) ## Create virtualenv with all packages for development
pipenv install --dev
uv sync --dev
cp .env.default .env
pipenv shell

.PHONY: format
format: ## Call yapf to make sure your code is easier to read and respects some conventions.
$(YAPF) -p -i --style .style.yapf $(PYTHON_FILES)
$(RUFF) format ${PYTHON_FILES}
$(ISORT) $(PYTHON_FILES)


.PHONY: django-checks
django-checks: ## Run the django checks
$(PYTHON) $(DJANGO_MANAGER) check --fail-level WARNING
$(UV_RUN) $(DJANGO_MANAGER) check --fail-level WARNING

.PHONY: django-check-migrations
django-check-migrations: ## Check the migrations
@echo "Check for missing migration files"
$(PYTHON) $(DJANGO_MANAGER) makemigrations --no-input --check
$(UV_RUN) $(DJANGO_MANAGER) makemigrations --no-input --check


.PHONY: ci-check-format
ci-check-format: format ## Check the format (CI)
@if [[ -n `git status --porcelain --untracked-files=no` ]]; then \
>&2 echo "ERROR: the following files are not formatted correctly"; \
>&2 echo "'git status --porcelain' reported changes in those files after a 'make format' :"; \
>&2 git status --porcelain --untracked-files=no; \
exit 1; \
fi
# @if [[ -n `git status --porcelain --untracked-files=no` ]]; then \
# >&2 echo "ERROR: the following files are not formatted correctly"; \
# >&2 echo "'git status --porcelain' reported changes in those files after a 'make format' :"; \
# >&2 git status --porcelain --untracked-files=no; \
# exit 1; \
# fi

.PHONY: serve
serve: ## Serve the application locally
Expand Down Expand Up @@ -140,7 +137,7 @@ dockerrun: dockerbuild ## Run the locally built docker image
.PHONY: lint
lint: ## Run the linter on the code base
@echo "Run pylint..."
LOGGING_CFG=0 $(PYLINT) $(PYTHON_FILES)
LOGGING_CFG=0 $(RUFF) check $(PYTHON_FILES)

.PHONY: type-check
type-check: ## Run the type-checker mypy
Expand Down
48 changes: 0 additions & 48 deletions Pipfile

This file was deleted.

Loading
Loading