2024-01-09 15:30:36 +01:00
|
|
|
# /!\ /!\ /!\ /!\ /!\ /!\ /!\ DISCLAIMER /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\
|
|
|
|
|
#
|
|
|
|
|
# This Makefile is only meant to be used for DEVELOPMENT purpose as we are
|
|
|
|
|
# changing the user id that will run in the container.
|
|
|
|
|
#
|
|
|
|
|
# PLEASE DO NOT USE IT FOR YOUR CI/PRODUCTION/WHATEVER...
|
|
|
|
|
#
|
|
|
|
|
# /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\ /!\
|
|
|
|
|
#
|
|
|
|
|
# Note to developers:
|
|
|
|
|
#
|
|
|
|
|
# While editing this file, please respect the following statements:
|
|
|
|
|
#
|
|
|
|
|
# 1. Every variable should be defined in the ad hoc VARIABLES section with a
|
|
|
|
|
# relevant subsection
|
|
|
|
|
# 2. Every new rule should be defined in the ad hoc RULES section with a
|
|
|
|
|
# relevant subsection depending on the targeted service
|
|
|
|
|
# 3. Rules should be sorted alphabetically within their section
|
|
|
|
|
# 4. When a rule has multiple dependencies, you should:
|
|
|
|
|
# - duplicate the rule name to add the help string (if required)
|
|
|
|
|
# - write one dependency per line to increase readability and diffs
|
|
|
|
|
# 5. .PHONY rule statement should be written after the corresponding rule
|
|
|
|
|
# ==============================================================================
|
|
|
|
|
# VARIABLES
|
|
|
|
|
|
|
|
|
|
BOLD := \033[1m
|
|
|
|
|
RESET := \033[0m
|
|
|
|
|
GREEN := \033[1;32m
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Database
|
|
|
|
|
|
|
|
|
|
DB_HOST = postgresql
|
|
|
|
|
DB_PORT = 5432
|
|
|
|
|
|
|
|
|
|
# -- Docker
|
|
|
|
|
# Get the current user ID to use for docker run and docker exec commands
|
|
|
|
|
DOCKER_UID = $(shell id -u)
|
|
|
|
|
DOCKER_GID = $(shell id -g)
|
|
|
|
|
DOCKER_USER = $(DOCKER_UID):$(DOCKER_GID)
|
|
|
|
|
COMPOSE = DOCKER_USER=$(DOCKER_USER) docker compose
|
|
|
|
|
COMPOSE_EXEC = $(COMPOSE) exec
|
|
|
|
|
COMPOSE_EXEC_APP = $(COMPOSE_EXEC) app-dev
|
|
|
|
|
COMPOSE_RUN = $(COMPOSE) run --rm
|
|
|
|
|
COMPOSE_RUN_APP = $(COMPOSE_RUN) app-dev
|
|
|
|
|
COMPOSE_RUN_CROWDIN = $(COMPOSE_RUN) crowdin crowdin
|
|
|
|
|
WAIT_DB = @$(COMPOSE_RUN) dockerize -wait tcp://$(DB_HOST):$(DB_PORT) -timeout 60s
|
|
|
|
|
|
|
|
|
|
# -- Backend
|
|
|
|
|
MANAGE = $(COMPOSE_RUN_APP) python manage.py
|
|
|
|
|
MAIL_YARN = $(COMPOSE_RUN) -w /app/src/mail node yarn
|
|
|
|
|
|
2024-04-03 12:33:36 +02:00
|
|
|
# -- Frontend
|
|
|
|
|
PATH_FRONT = ./src/frontend
|
|
|
|
|
PATH_FRONT_IMPRESS = $(PATH_FRONT)/apps/impress
|
|
|
|
|
|
2024-01-09 15:30:36 +01:00
|
|
|
# ==============================================================================
|
|
|
|
|
# RULES
|
|
|
|
|
|
|
|
|
|
default: help
|
|
|
|
|
|
|
|
|
|
data/media:
|
|
|
|
|
@mkdir -p data/media
|
|
|
|
|
|
|
|
|
|
data/static:
|
|
|
|
|
@mkdir -p data/static
|
|
|
|
|
|
|
|
|
|
# -- Project
|
|
|
|
|
|
2024-04-03 13:54:11 +02:00
|
|
|
create-env-files: ## Copy the dist env files to env files
|
|
|
|
|
create-env-files: \
|
|
|
|
|
env.d/development/common \
|
|
|
|
|
env.d/development/crowdin \
|
|
|
|
|
env.d/development/postgresql \
|
|
|
|
|
env.d/development/kc_postgresql
|
|
|
|
|
.PHONY: create-env-files
|
|
|
|
|
|
2024-01-09 15:30:36 +01:00
|
|
|
bootstrap: ## Prepare Docker images for the project
|
|
|
|
|
bootstrap: \
|
|
|
|
|
data/media \
|
|
|
|
|
data/static \
|
2024-04-03 13:54:11 +02:00
|
|
|
create-env-files \
|
2024-01-09 15:30:36 +01:00
|
|
|
build \
|
2024-09-16 14:25:42 +02:00
|
|
|
run-with-frontend \
|
2024-01-09 15:30:36 +01:00
|
|
|
migrate \
|
2024-04-10 16:29:28 +02:00
|
|
|
demo \
|
2024-04-03 12:33:36 +02:00
|
|
|
back-i18n-compile \
|
2024-01-09 15:30:36 +01:00
|
|
|
mails-install \
|
2024-05-30 15:20:55 +02:00
|
|
|
mails-build
|
2024-01-09 15:30:36 +01:00
|
|
|
.PHONY: bootstrap
|
|
|
|
|
|
|
|
|
|
# -- Docker/compose
|
2024-09-16 14:25:42 +02:00
|
|
|
build: cache ?= --no-cache
|
|
|
|
|
build: ## build the project containers
|
|
|
|
|
@$(MAKE) build-backend cache=$(cache)
|
|
|
|
|
@$(MAKE) build-yjs-provider cache=$(cache)
|
|
|
|
|
@$(MAKE) build-frontend cache=$(cache)
|
2024-01-09 15:30:36 +01:00
|
|
|
.PHONY: build
|
|
|
|
|
|
2024-09-16 14:25:42 +02:00
|
|
|
build-backend: cache ?=
|
|
|
|
|
build-backend: ## build the app-dev container
|
|
|
|
|
@$(COMPOSE) build app-dev $(cache)
|
|
|
|
|
.PHONY: build-backend
|
|
|
|
|
|
|
|
|
|
build-yjs-provider: cache ?=
|
|
|
|
|
build-yjs-provider: ## build the y-provider container
|
|
|
|
|
@$(COMPOSE) build y-provider $(cache)
|
|
|
|
|
.PHONY: build-yjs-provider
|
|
|
|
|
|
|
|
|
|
build-frontend: cache ?=
|
|
|
|
|
build-frontend: ## build the frontend container
|
|
|
|
|
@$(COMPOSE) build frontend-dev $(cache)
|
|
|
|
|
.PHONY: build-frontend
|
|
|
|
|
|
2024-01-09 15:30:36 +01:00
|
|
|
down: ## stop and remove containers, networks, images, and volumes
|
|
|
|
|
@$(COMPOSE) down
|
|
|
|
|
.PHONY: down
|
|
|
|
|
|
|
|
|
|
logs: ## display app-dev logs (follow mode)
|
|
|
|
|
@$(COMPOSE) logs -f app-dev
|
|
|
|
|
.PHONY: logs
|
|
|
|
|
|
|
|
|
|
run: ## start the wsgi (production) and development server
|
|
|
|
|
@$(COMPOSE) up --force-recreate -d celery-dev
|
2024-10-15 11:53:02 +02:00
|
|
|
@$(COMPOSE) up --force-recreate -d nginx
|
2024-09-04 16:56:40 +02:00
|
|
|
@$(COMPOSE) up --force-recreate -d y-provider
|
2024-01-09 15:30:36 +01:00
|
|
|
@echo "Wait for postgresql to be up..."
|
|
|
|
|
@$(WAIT_DB)
|
|
|
|
|
.PHONY: run
|
|
|
|
|
|
2024-09-16 14:25:42 +02:00
|
|
|
run-with-frontend: ## Start all the containers needed (backend to frontend)
|
|
|
|
|
@$(MAKE) run
|
|
|
|
|
@$(COMPOSE) up --force-recreate -d frontend-dev
|
|
|
|
|
.PHONY: run-with-frontend
|
|
|
|
|
|
2024-01-09 15:30:36 +01:00
|
|
|
status: ## an alias for "docker compose ps"
|
|
|
|
|
@$(COMPOSE) ps
|
|
|
|
|
.PHONY: status
|
|
|
|
|
|
|
|
|
|
stop: ## stop the development server using Docker
|
|
|
|
|
@$(COMPOSE) stop
|
|
|
|
|
.PHONY: stop
|
|
|
|
|
|
|
|
|
|
# -- Backend
|
|
|
|
|
|
|
|
|
|
demo: ## flush db then create a demo for load testing purpose
|
|
|
|
|
@$(MAKE) resetdb
|
|
|
|
|
@$(MANAGE) create_demo
|
|
|
|
|
.PHONY: demo
|
|
|
|
|
|
|
|
|
|
# Nota bene: Black should come after isort just in case they don't agree...
|
|
|
|
|
lint: ## lint back-end python sources
|
|
|
|
|
lint: \
|
|
|
|
|
lint-ruff-format \
|
|
|
|
|
lint-ruff-check \
|
|
|
|
|
lint-pylint
|
|
|
|
|
.PHONY: lint
|
|
|
|
|
|
|
|
|
|
lint-ruff-format: ## format back-end python sources with ruff
|
|
|
|
|
@echo 'lint:ruff-format started…'
|
|
|
|
|
@$(COMPOSE_RUN_APP) ruff format .
|
|
|
|
|
.PHONY: lint-ruff-format
|
|
|
|
|
|
|
|
|
|
lint-ruff-check: ## lint back-end python sources with ruff
|
|
|
|
|
@echo 'lint:ruff-check started…'
|
|
|
|
|
@$(COMPOSE_RUN_APP) ruff check . --fix
|
|
|
|
|
.PHONY: lint-ruff-check
|
|
|
|
|
|
|
|
|
|
lint-pylint: ## lint back-end python sources with pylint only on changed files from main
|
|
|
|
|
@echo 'lint:pylint started…'
|
|
|
|
|
bin/pylint --diff-only=origin/main
|
|
|
|
|
.PHONY: lint-pylint
|
|
|
|
|
|
|
|
|
|
test: ## run project tests
|
|
|
|
|
@$(MAKE) test-back-parallel
|
|
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
|
|
test-back: ## run back-end tests
|
|
|
|
|
@args="$(filter-out $@,$(MAKECMDGOALS))" && \
|
|
|
|
|
bin/pytest $${args:-${1}}
|
|
|
|
|
.PHONY: test-back
|
|
|
|
|
|
|
|
|
|
test-back-parallel: ## run all back-end tests in parallel
|
|
|
|
|
@args="$(filter-out $@,$(MAKECMDGOALS))" && \
|
|
|
|
|
bin/pytest -n auto $${args:-${1}}
|
|
|
|
|
.PHONY: test-back-parallel
|
|
|
|
|
|
2024-03-07 19:46:46 +01:00
|
|
|
makemigrations: ## run django makemigrations for the impress project.
|
2024-01-09 15:30:36 +01:00
|
|
|
@echo "$(BOLD)Running makemigrations$(RESET)"
|
|
|
|
|
@$(COMPOSE) up -d postgresql
|
|
|
|
|
@$(WAIT_DB)
|
|
|
|
|
@$(MANAGE) makemigrations
|
|
|
|
|
.PHONY: makemigrations
|
|
|
|
|
|
2024-03-07 19:46:46 +01:00
|
|
|
migrate: ## run django migrations for the impress project.
|
2024-01-09 15:30:36 +01:00
|
|
|
@echo "$(BOLD)Running migrations$(RESET)"
|
|
|
|
|
@$(COMPOSE) up -d postgresql
|
|
|
|
|
@$(WAIT_DB)
|
|
|
|
|
@$(MANAGE) migrate
|
|
|
|
|
.PHONY: migrate
|
|
|
|
|
|
|
|
|
|
superuser: ## Create an admin superuser with password "admin"
|
|
|
|
|
@echo "$(BOLD)Creating a Django superuser$(RESET)"
|
|
|
|
|
@$(MANAGE) createsuperuser --email admin@example.com --password admin
|
|
|
|
|
.PHONY: superuser
|
|
|
|
|
|
|
|
|
|
back-i18n-compile: ## compile the gettext files
|
|
|
|
|
@$(MANAGE) compilemessages --ignore="venv/**/*"
|
|
|
|
|
.PHONY: back-i18n-compile
|
|
|
|
|
|
|
|
|
|
back-i18n-generate: ## create the .pot files used for i18n
|
2024-08-14 14:50:36 +02:00
|
|
|
@$(MANAGE) makemessages -a --keep-pot --all
|
2024-01-09 15:30:36 +01:00
|
|
|
.PHONY: back-i18n-generate
|
|
|
|
|
|
|
|
|
|
shell: ## connect to database shell
|
|
|
|
|
@$(MANAGE) shell #_plus
|
|
|
|
|
.PHONY: dbshell
|
|
|
|
|
|
|
|
|
|
# -- Database
|
|
|
|
|
|
|
|
|
|
dbshell: ## connect to database shell
|
|
|
|
|
docker compose exec app-dev python manage.py dbshell
|
|
|
|
|
.PHONY: dbshell
|
|
|
|
|
|
2024-04-10 20:05:49 +02:00
|
|
|
resetdb: FLUSH_ARGS ?=
|
2024-01-09 15:30:36 +01:00
|
|
|
resetdb: ## flush database and create a superuser "admin"
|
|
|
|
|
@echo "$(BOLD)Flush database$(RESET)"
|
2024-04-10 20:05:49 +02:00
|
|
|
@$(MANAGE) flush $(FLUSH_ARGS)
|
2024-01-09 15:30:36 +01:00
|
|
|
@${MAKE} superuser
|
|
|
|
|
.PHONY: resetdb
|
|
|
|
|
|
|
|
|
|
env.d/development/common:
|
|
|
|
|
cp -n env.d/development/common.dist env.d/development/common
|
|
|
|
|
|
|
|
|
|
env.d/development/postgresql:
|
|
|
|
|
cp -n env.d/development/postgresql.dist env.d/development/postgresql
|
|
|
|
|
|
2024-02-23 23:54:35 +01:00
|
|
|
env.d/development/kc_postgresql:
|
|
|
|
|
cp -n env.d/development/kc_postgresql.dist env.d/development/kc_postgresql
|
|
|
|
|
|
2024-01-09 15:30:36 +01:00
|
|
|
# -- Internationalization
|
|
|
|
|
|
|
|
|
|
env.d/development/crowdin:
|
|
|
|
|
cp -n env.d/development/crowdin.dist env.d/development/crowdin
|
|
|
|
|
|
|
|
|
|
crowdin-download: ## Download translated message from crowdin
|
|
|
|
|
@$(COMPOSE_RUN_CROWDIN) download -c crowdin/config.yml
|
|
|
|
|
.PHONY: crowdin-download
|
|
|
|
|
|
2024-04-03 12:33:36 +02:00
|
|
|
crowdin-download-sources: ## Download sources from Crowdin
|
|
|
|
|
@$(COMPOSE_RUN_CROWDIN) download sources -c crowdin/config.yml
|
|
|
|
|
.PHONY: crowdin-download-sources
|
|
|
|
|
|
2024-01-09 15:30:36 +01:00
|
|
|
crowdin-upload: ## Upload source translations to crowdin
|
|
|
|
|
@$(COMPOSE_RUN_CROWDIN) upload sources -c crowdin/config.yml
|
|
|
|
|
.PHONY: crowdin-upload
|
|
|
|
|
|
|
|
|
|
i18n-compile: ## compile all translations
|
|
|
|
|
i18n-compile: \
|
2024-04-03 12:33:36 +02:00
|
|
|
back-i18n-compile \
|
|
|
|
|
frontend-i18n-compile
|
2024-01-09 15:30:36 +01:00
|
|
|
.PHONY: i18n-compile
|
|
|
|
|
|
|
|
|
|
i18n-generate: ## create the .pot files and extract frontend messages
|
|
|
|
|
i18n-generate: \
|
2024-04-03 12:33:36 +02:00
|
|
|
back-i18n-generate \
|
|
|
|
|
frontend-i18n-generate
|
2024-01-09 15:30:36 +01:00
|
|
|
.PHONY: i18n-generate
|
|
|
|
|
|
|
|
|
|
i18n-download-and-compile: ## download all translated messages and compile them to be used by all applications
|
|
|
|
|
i18n-download-and-compile: \
|
|
|
|
|
crowdin-download \
|
|
|
|
|
i18n-compile
|
|
|
|
|
.PHONY: i18n-download-and-compile
|
|
|
|
|
|
2024-04-03 12:33:36 +02:00
|
|
|
i18n-generate-and-upload: ## generate source translations for all applications and upload them to Crowdin
|
2024-01-09 15:30:36 +01:00
|
|
|
i18n-generate-and-upload: \
|
|
|
|
|
i18n-generate \
|
|
|
|
|
crowdin-upload
|
|
|
|
|
.PHONY: i18n-generate-and-upload
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Mail generator
|
|
|
|
|
|
|
|
|
|
mails-build: ## Convert mjml files to html and text
|
|
|
|
|
@$(MAIL_YARN) build
|
|
|
|
|
.PHONY: mails-build
|
|
|
|
|
|
|
|
|
|
mails-build-html-to-plain-text: ## Convert html files to text
|
|
|
|
|
@$(MAIL_YARN) build-html-to-plain-text
|
|
|
|
|
.PHONY: mails-build-html-to-plain-text
|
|
|
|
|
|
|
|
|
|
mails-build-mjml-to-html: ## Convert mjml files to html and text
|
|
|
|
|
@$(MAIL_YARN) build-mjml-to-html
|
|
|
|
|
.PHONY: mails-build-mjml-to-html
|
|
|
|
|
|
|
|
|
|
mails-install: ## install the mail generator
|
|
|
|
|
@$(MAIL_YARN) install
|
|
|
|
|
.PHONY: mails-install
|
|
|
|
|
|
|
|
|
|
# -- Misc
|
|
|
|
|
clean: ## restore repository state as it was freshly cloned
|
|
|
|
|
git clean -idx
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
|
|
help:
|
2024-03-07 19:46:46 +01:00
|
|
|
@echo "$(BOLD)impress Makefile"
|
2024-01-09 15:30:36 +01:00
|
|
|
@echo "Please use 'make $(BOLD)target$(RESET)' where $(BOLD)target$(RESET) is one of:"
|
|
|
|
|
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(GREEN)%-30s$(RESET) %s\n", $$1, $$2}'
|
|
|
|
|
.PHONY: help
|
2024-04-03 12:33:36 +02:00
|
|
|
|
2024-09-16 14:25:42 +02:00
|
|
|
# Front
|
|
|
|
|
frontend-install: ## install the frontend locally
|
|
|
|
|
cd $(PATH_FRONT_IMPRESS) && yarn
|
|
|
|
|
.PHONY: frontend-install
|
|
|
|
|
|
|
|
|
|
run-frontend-development: ## Run the frontend in development mode
|
|
|
|
|
@$(COMPOSE) stop frontend-dev
|
|
|
|
|
cd $(PATH_FRONT_IMPRESS) && yarn dev
|
|
|
|
|
.PHONY: run-frontend-development
|
2024-04-03 12:33:36 +02:00
|
|
|
|
|
|
|
|
frontend-i18n-extract: ## Extract the frontend translation inside a json to be used for crowdin
|
|
|
|
|
cd $(PATH_FRONT) && yarn i18n:extract
|
|
|
|
|
.PHONY: frontend-i18n-extract
|
|
|
|
|
|
|
|
|
|
frontend-i18n-generate: ## Generate the frontend json files used for crowdin
|
|
|
|
|
frontend-i18n-generate: \
|
|
|
|
|
crowdin-download-sources \
|
|
|
|
|
frontend-i18n-extract
|
|
|
|
|
.PHONY: frontend-i18n-generate
|
|
|
|
|
|
|
|
|
|
frontend-i18n-compile: ## Format the crowin json files used deploy to the apps
|
|
|
|
|
cd $(PATH_FRONT) && yarn i18n:deploy
|
2024-04-12 23:02:03 +02:00
|
|
|
.PHONY: frontend-i18n-compile
|
|
|
|
|
|
|
|
|
|
# -- K8S
|
|
|
|
|
build-k8s-cluster: ## build the kubernetes cluster using kind
|
|
|
|
|
./bin/start-kind.sh
|
|
|
|
|
.PHONY: build-k8s-cluster
|
|
|
|
|
|
|
|
|
|
start-tilt: ## start the kubernetes cluster using kind
|
|
|
|
|
tilt up -f ./bin/Tiltfile
|
2024-04-05 20:05:18 +02:00
|
|
|
.PHONY: build-k8s-cluster
|
|
|
|
|
|
2024-09-16 14:25:42 +02:00
|
|
|
bump-packages-version: VERSION_TYPE ?= minor
|
2024-08-23 15:59:50 +02:00
|
|
|
bump-packages-version: ## bump the version of the project - VERSION_TYPE can be "major", "minor", "patch"
|
|
|
|
|
cd ./src/mail && yarn version --no-git-tag-version --$(VERSION_TYPE)
|
|
|
|
|
cd ./src/frontend/ && yarn version --no-git-tag-version --$(VERSION_TYPE)
|
|
|
|
|
cd ./src/frontend/apps/e2e/ && yarn version --no-git-tag-version --$(VERSION_TYPE)
|
|
|
|
|
cd ./src/frontend/apps/impress/ && yarn version --no-git-tag-version --$(VERSION_TYPE)
|
2024-09-04 16:56:40 +02:00
|
|
|
cd ./src/frontend/servers/y-provider/ && yarn version --no-git-tag-version --$(VERSION_TYPE)
|
2024-08-23 15:59:50 +02:00
|
|
|
cd ./src/frontend/packages/eslint-config-impress/ && yarn version --no-git-tag-version --$(VERSION_TYPE)
|
|
|
|
|
cd ./src/frontend/packages/i18n/ && yarn version --no-git-tag-version --$(VERSION_TYPE)
|
|
|
|
|
.PHONY: bump-packages-version
|