1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

improve developer tooling (backend) (#1051)

* add basic pre-commit file

* add flake8

* add isort

* add pep585-upgrade (typing upgrades)

* use namespace for import

* add mypy

* update ci for backend

* flake8 scope

* fix version format

* update makefile

* disable strict option (temporary)

* fix mypy issues

* upgrade type hints (pre-commit)

* add vscode typing check

* add types to dev deps

* remote container draft

* update setup script

* update compose version

* run setup on create

* dev containers update

* remove unused pages

* update setup tips

* expose ports

* Update pre-commit to include flask8-print (#1053)

* Add in flake8-print to pre-commit

* pin version of flake8-print

* formatting

* update getting strated docs

* add mypy to pre-commit

* purge .mypy_cache on clean

* drop mypy

Co-authored-by: zackbcom <zackbcom@users.noreply.github.com>
This commit is contained in:
Hayden 2022-03-15 15:01:56 -08:00 committed by GitHub
parent e109391e9a
commit 3c2744a3da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
105 changed files with 723 additions and 437 deletions

View file

@ -23,15 +23,45 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT"
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
purge: clean ## ⚠️ Removes All Developer Data for a fresh server start
.PHONY: docs
docs: ## 📄 Start Mkdocs Development Server
poetry run python dev/scripts/api_docs_gen.py && \
cd docs && poetry run python -m mkdocs serve
code-gen: ## 🤖 Run Code-Gen Scripts
poetry run python dev/scripts/app_routes_gen.py
# -----------------------------------------------------------------------------
# Backend makefile
.PHONY: setup
setup: ## 🏗 Setup Development Instance
poetry install && \
cd frontend && \
yarn install && \
cd ..
poetry run pre-commit install
cp -n template.env .env || true
@echo "🏗 Development Setup Complete "
@echo "❗️ Tips"
@echo " 1. run 'make backend' to start the API server"
@echo " 2. run 'make frontend' to start the Node Server"
@echo " 3. Testing the Natural Language Processor? Try 'make setup-model' to get the most recent model"
setup-model: ## 🤖 Get the latest NLP CRF++ Model
@echo Fetching NLP Model - CRF++ is still Required
curl -L0 https://github.com/mealie-recipes/nlp-model/releases/download/v1.0.0/model.crfmodel --output ./mealie/services/parser_services/crfpp/model.crfmodel
clean-data: clean ## ⚠️ Removes All Developer Data for a fresh server start
rm -r ./dev/data/recipes/
rm -r ./dev/data/users/
rm -f ./dev/data/mealie*.db
rm -f ./dev/data/mealie.log
rm -f ./dev/data/.secret
clean: clean-pyc clean-test ## 🧹 Remove all build, test, coverage and Python artifacts
clean-pyc: ## 🧹 Remove Python file artifacts
find ./mealie -name '*.pyc' -exec rm -f {} +
find ./mealie -name '*.pyo' -exec rm -f {} +
@ -44,46 +74,38 @@ clean-test: ## 🧹 Remove test and coverage artifacts
rm -fr htmlcov/
rm -fr .pytest_cache
test-all: lint-test test ## 🧪 Check Lint Format and Testing
backend-clean: clean-pyc clean-test ## 🧹 Remove all build, test, coverage and Python artifacts
rm -fr .mypy_cache
test: ## 🧪 Run tests quickly with the default Python
backend-typecheck:
poetry run mypy mealie
backend-test: ## 🧪 Run tests quickly with the default Python
poetry run pytest
lint-test:
poetry run black . --check
poetry run isort . --check-only
poetry run flake8 mealie tests
lint: ## 🧺 Format, Check and Flake8
backend-format: ## 🧺 Format, Check and Flake8
poetry run isort .
poetry run black .
backend-lint:
poetry run flake8 mealie tests
coverage: ## ☂️ Check code coverage quickly with the default Python
poetry run pytest
backend-all: backend-format backend-lint backend-typecheck backend-test ## 🧪 Runs all the backend checks and tests
backend-coverage: ## ☂️ Check code coverage quickly with the default Python
poetry run pytest
poetry run coverage report -m
poetry run coveragepy-lcov
poetry run coverage html
$(BROWSER) htmlcov/index.html
.PHONY: setup
setup: ## 🏗 Setup Development Instance
poetry install && \
cd frontend && \
yarn install && \
cd ..
@echo Be sure to copy the template.env files
@echo Testing the Natural Languuage Processor? Try `make setup-model` to get the most recent model
setup-model: ## 🤖 Get the latest NLP CRF++ Model
@echo Fetching NLP Model - CRF++ is still Required
curl -L0 https://github.com/mealie-recipes/nlp-model/releases/download/v1.0.0/model.crfmodel --output ./mealie/services/parser_services/crfpp/model.crfmodel
backend: ## 🎬 Start Mealie Backend Development Server
poetry run python mealie/db/init_db.py && \
poetry run python mealie/app.py
# -----------------------------------------------------------------------------
# Frontend makefile
.PHONY: frontend
frontend: ## 🎬 Start Mealie Frontend Development Server
cd frontend && yarn run dev
@ -97,10 +119,8 @@ frontend-generate: ## 🏗 Generate Code for Frontend
frontend-lint: ## 🧺 Run yarn lint
cd frontend && yarn lint
.PHONY: docs
docs: ## 📄 Start Mkdocs Development Server
poetry run python dev/scripts/api_docs_gen.py && \
cd docs && poetry run python -m mkdocs serve
# -----------------------------------------------------------------------------
# Docker makefile
docker-dev: ## 🐳 Build and Start Docker Development Stack
docker-compose -f docker-compose.dev.yml -p dev-mealie down && \
@ -108,7 +128,3 @@ docker-dev: ## 🐳 Build and Start Docker Development Stack
docker-prod: ## 🐳 Build and Start Docker Production Stack
docker-compose -f docker-compose.yml -p mealie up --build
code-gen: ## 🤖 Run Code-Gen Scripts
poetry run python dev/scripts/app_routes_gen.py