Skip to content

Commit 30a0bb3

Browse files
author
Edvard Majakari
committed
standard Makefile with help texts and deps rule
1 parent 4eecc9c commit 30a0bb3

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include tools/make/*.mk
2+
# please keep any rules idempotent if possible.
3+
# NOTE: whenever useful, we'll use sentinel pattern with .make- prefix to avoid unnecessary work
4+
5+
# please keep dev-setup idempotent
6+
dev-setup: deps
7+
8+
# use 'make -B deps' to force execution of rule
9+
# `make deps` allows us to absract details of package manager without changing developer flow or github actions
10+
deps: .make-dev-deps
11+
12+
# this should install all dependencies, and only those mentioned in the lock file
13+
# Note that rule should be idempotent and return immediately if there's nothing to do, so that
14+
# eg. test can depend on this. Strictly speaking this depends on 'pyproject.toml' too, but often those changes
15+
# are not relevant to dependencies and user can always do `make -B <rule> to force rebuild`
16+
.make-dev-deps: poetry.lock
17+
poetry install --with docs --sync
18+
touch $@
19+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# use sane shell by default, as well as other settings
2+
SHELL := bash
3+
.SHELLFLAGS := -eu -o pipefail -c
4+
.DELETE_ON_ERROR:
5+
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules
6+
.DEFAULT_GOAL = help
7+
8+
# location for source files
9+
SRC ?= src/
10+
11+
# Hack to make help rule work, given that rule has suffix ' ## <help text'.
12+
# Minor adjustments to make it work properly with included files
13+
.PHONY: help
14+
help: ## This help dialog
15+
@grep -hE '^[a-zA-Z-][a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort -u -t: -k1,1 | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-22s\033[0m %s\n", $$1, $$2}'
16+
17+
.PHONY: grep-tech-debt
18+
grep-tech-debt: ## Grep for lines with various types of tech debt
19+
@echo "### ❗Checking for FIXMEs"
20+
@git grep --line-number --ignore-case --extended-regexp '# (fixme|xxx)' $(SRC) || echo "No FIXMEs ✅"
21+
@echo "### 🚧 Silenced issues"
22+
@git grep --line-number --ignore-case --extended-regexp '# (noqa|type: ignore|xxx)' $(SRC) || echo "No silenced issues ✅"
23+
@echo "### 🚧 TODOs"
24+
@git grep --line-number --ignore-case --extended-regexp '# (todo|tbd)' $(SRC) || echo "No TODOs ✅"
25+
26+
######################################################################################################
27+
# Common rules which probably should be present regardless of technologies, but implemented
28+
# in specific files or root Makefile. Avoid modifying this file, because it would be updated by the template
29+
#
30+
# Note that specifying .PHONY here means actual implementation
31+
# needs only rule body (repeating .PHONY is not needed)
32+
######################################################################################################
33+
34+
.PHONY: deps
35+
deps: ## Set installed dependencies (including dev) to match those in the lock file
36+
37+
.PHONY: build
38+
build: ## Build project and/or container image(s)
39+
40+
.PHONY: build-dev
41+
build-dev: ## Build project and/or container image(s) for local development/testing
42+
43+
# this rule should do asdf install, setup .envrc etc, anything that helps new devs in getting started
44+
.PHONY: dev-setup
45+
dev-setup: ## Prepare project ready for local development
46+
47+
.PHONY: fmt
48+
fmt: ## Apply all automated formatters
49+
50+
.PHONY: release
51+
release: ## Create new release
52+
53+
.PHONY: local-run
54+
local-run: ## Run system locally without docker
55+
56+
.PHONY: docker-run
57+
docker-run: ## Run system locally with docker
58+
59+
.PHONY: test
60+
test: ## Run automated tests
61+
62+
.PHONY: lint
63+
lint: ## Analyze code for issues/smells

0 commit comments

Comments
 (0)