-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (75 loc) · 2.62 KB
/
Makefile
File metadata and controls
95 lines (75 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
### Defensive settings for make:
# https://tech.davis-hansson.com/p/make/
SHELL:=bash
.ONESHELL:
.SHELLFLAGS:=-xeu -o pipefail -O inherit_errexit -c
.SILENT:
.DELETE_ON_ERROR:
MAKEFLAGS+=--warn-undefined-variables
MAKEFLAGS+=--no-builtin-rules
# We like colors
# From: https://coderwall.com/p/izxssa/colored-makefile-for-golang-projects
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
YELLOW=`tput setaf 3`
# Python checks
UV?=uv
# installed?
ifeq (, $(shell which $(UV) ))
$(error "UV=$(UV) not found in $(PATH)")
endif
BACKEND_FOLDER=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
GIT_FOLDER=$(BACKEND_FOLDER)/.git
VENV_FOLDER=$(BACKEND_FOLDER)/.venv
BIN_FOLDER=$(VENV_FOLDER)/bin
IMAGE_NAME=ghcr.io/kitconcept/content-sync
IMAGE_TAG=latest
all: build
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
.PHONY: help
help: ## This help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
$(BIN_FOLDER)/pytest: ## Install dependencies
@echo "$(GREEN)==> Install environment$(RESET)"
@uv sync
$(BIN_FOLDER)/ruff: $(BIN_FOLDER)/pytest
.PHONY: install
install: $(BIN_FOLDER)/pytest ## Install package
.PHONY: clean
clean: ## Clean environment
@echo "$(RED)==> Cleaning environment and build$(RESET)"
rm -rf $(VENV_FOLDER) .python-version .venv .ruff_cache .pytest_cache uv.lock
.PHONY: lint-mypy
lint-mypy: $(BIN_FOLDER)/mypy ## Check type hints
@echo "$(GREEN)==> Check type hints$(RESET)"
@uv run mypy src
.PHONY: lint
lint: $(BIN_FOLDER)/ruff ## Check and fix code base according to Plone standards
@echo "$(GREEN)==> Lint codebase$(RESET)"
@uvx ruff@latest check --fix
@uvx pyroma@latest -d .
@uvx check-python-versions@latest .
$(MAKE) lint-mypy
.PHONY: format
format: $(BIN_FOLDER)/ruff ## Check and fix code base according to Plone standards
@echo "$(GREEN)==> Format codebase$(RESET)"
@uvx ruff@latest check --select I --fix
@uvx ruff@latest format
# Tests
.PHONY: test
test: $(BIN_FOLDER)/pytest ## run tests
@uv run pytest
.PHONY: test-cov
test-cov: $(BIN_FOLDER)/pytest ## run tests
@uv run pytest --cov=kitconcept.contentsync --cov-report term-missing
# Building the Container image
.PHONY: image-build
image-build: ## Build the Container image
@echo "$(GREEN)==> Building Container image$(RESET)"
@docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
.PHONY: image-start
image-start: image-build ## Start the container using the image
@echo "$(GREEN)==> Starting Container image$(RESET)"
@docker run -p 8000:8000 --rm -it $(IMAGE_NAME):$(IMAGE_TAG)