Skip to content

Commit

Permalink
Ajout d‘une variable d’environnement USE_POETRY (#254)
Browse files Browse the repository at this point in the history
* Add optional USE_POETRY env variable

* Update CI
  • Loading branch information
Ash-Crow authored Jan 21, 2025
1 parent df849ea commit 9b83cec
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ MEDIA_ROOT=medias

# USE_DOCKER: Set 1 to use Docker
USE_DOCKER=0
# Set 1 to use Poetry
USE_POETRY=0

DATABASE_NAME=djdb
DATABASE_USER=dju
Expand Down
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DEBUG=False
DATABASE_URL=postgres://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
USE_POETRY=1
48 changes: 29 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,90 @@ else
EXEC_CMD :=
endif

ifeq ($(USE_POETRY),1)
POETRY_CMD := poetry run
else
POETRY_CMD :=
endif

.PHONY: web-prompt
web-prompt:
$(EXEC_CMD) bash

.PHONY: collectstatic
collectstatic:
$(EXEC_CMD) poetry run python manage.py collectstatic --noinput --ignore=*.sass
$(EXEC_CMD) $(POETRY_CMD) python manage.py collectstatic --noinput --ignore=*.sass


.PHONY: messages
messages:
$(EXEC_CMD) poetry run django-admin makemessages -l fr --ignore=manage.py --ignore=config --ignore=medias --ignore=__init__.py --ignore=setup.py --ignore=staticfiles
$(EXEC_CMD) $(POETRY_CMD) django-admin makemessages -l fr --ignore=manage.py --ignore=config --ignore=medias --ignore=__init__.py --ignore=setup.py --ignore=staticfiles

.PHONY: sass
sass:
$(EXEC_CMD) poetry run python manage.py compilescss
$(EXEC_CMD) $(POETRY_CMD) python manage.py compilescss
make collectstatic

.PHONY: quality
quality:
$(EXEC_CMD) ruff check .
$(EXEC_CMD) poetry run black --check --exclude=venv .
$(EXEC_CMD) $(POETRY_CMD) black --check --exclude=venv .

.PHONY: fix
fix:
$(EXEC_CMD) ruff check . --fix
$(EXEC_CMD) poetry run black --exclude=venv .
$(EXEC_CMD) $(POETRY_CMD) black --exclude=venv .

.PHONY: index
index:
$(EXEC_CMD) poetry run python manage.py update_index
$(EXEC_CMD) $(POETRY_CMD) python manage.py update_index

.PHONY: init
init:
$(EXEC_CMD) poetry install --no-root --without dev
$(EXEC_CMD) poetry run python manage.py migrate
$(EXEC_CMD) $(POETRY_CMD) python manage.py migrate
make collectstatic
$(EXEC_CMD) poetry run python manage.py set_config
$(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms
$(EXEC_CMD) poetry run python manage.py create_starter_pages
$(EXEC_CMD) poetry run python manage.py import_page_templates
$(EXEC_CMD) $(POETRY_CMD) python manage.py set_config
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_dsfr_pictograms
$(EXEC_CMD) $(POETRY_CMD) python manage.py create_starter_pages
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_page_templates
make index

.PHONY: init-dev
init-dev:
make init
$(EXEC_CMD) poetry install --no-root
$(EXEC_CMD) poetry run pre-commit install
$(EXEC_CMD) $(POETRY_CMD) pre-commit install


.PHONY: update
update:
$(EXEC_CMD) poetry install --no-root --without dev
$(EXEC_CMD) poetry run python manage.py migrate
$(EXEC_CMD) $(POETRY_CMD) python manage.py migrate
make collectstatic
$(EXEC_CMD) poetry run python manage.py import_dsfr_pictograms
$(EXEC_CMD) poetry run python manage.py import_page_templates
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_dsfr_pictograms
$(EXEC_CMD) $(POETRY_CMD) python manage.py import_page_templates
make index


.PHONY: demo
demo:
make init
$(EXEC_CMD) poetry run python manage.py create_demo_pages
$(EXEC_CMD) $(POETRY_CMD) python manage.py create_demo_pages

.PHONY: runserver
runserver:
$(EXEC_CMD) poetry run python manage.py runserver $(HOST_URL):$(HOST_PORT)
$(EXEC_CMD) $(POETRY_CMD) python manage.py runserver $(HOST_URL):$(HOST_PORT)


.PHONY: shell
shell:
$(EXEC_CMD) $(POETRY_CMD) python manage.py shell_plus

.PHONY: test
test:
$(EXEC_CMD) poetry run python manage.py test --buffer --parallel
$(EXEC_CMD) $(POETRY_CMD) python manage.py test --buffer --parallel

.PHONY: test-unit
test-unit:
$(EXEC_CMD) poetry run python manage.py test --settings config.settings_test
$(EXEC_CMD) $(POETRY_CMD) python manage.py test --settings config.settings_test
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ python -c "from django.core.management.utils import get_random_secret_key; print
### En local
#### Installer poetry s’il ne l’est pas

Cf. la [documentation de poetry](https://python-poetry.org/docs/#installation)
- Cf. la [documentation de poetry](https://python-poetry.org/docs/#installation)
- mettre la variable d’environnement `USE_POETRY` à `1` dans le fichier `.env`

#### Installer le projet

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "sites-faciles"
requires-python = "<4.0,>=3.10"
version = "1.11.2"
version = "1.11.3"
description = "Gestionnaire de contenu permettant de créer et gérer un site internet basé sur le Système de design de l’État, accessible et responsive"
authors = [
{name = "Sébastien Reuiller", email = "[email protected]"},
Expand Down

0 comments on commit 9b83cec

Please sign in to comment.