-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
common Makefile rules, basic direnv / asdf setup #41
base: master
Are you sure you want to change the base?
Changes from all commits
30a0bb3
29e9918
9681bb9
34bc83c
5fdac2e
4b09de3
e6715e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Add any project-wide default values here. Note that they should still | ||
# be valid values, so not examples like EMAIL=myusername@mydomain, those should | ||
# be specied elsewhere like in user-local .env file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# this if config file for https://asdf-vm.com/ | ||
# which can be used to install hundreds of tools at specific version | ||
poetry 1.7.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
include tools/make/*.mk | ||
# please keep any rules idempotent if possible. | ||
# NOTE: whenever useful, we'll use sentinel pattern with .make- prefix to avoid unnecessary work | ||
|
||
# please keep dev-setup idempotent | ||
dev-setup: deps | ||
|
||
# use 'make -B deps' to force execution of rule | ||
# `make deps` allows us to absract details of package manager without changing developer flow or github actions | ||
deps: .make-dev-deps | ||
|
||
# this should install all dependencies, and only those mentioned in the lock file | ||
# Note that rule should be idempotent and return immediately if there's nothing to do, so that | ||
# eg. test can depend on this. Strictly speaking this depends on 'pyproject.toml' too, but often those changes | ||
# are not relevant to dependencies and user can always do `make -B <rule> to force rebuild` | ||
.make-dev-deps: poetry.lock | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might seem unnecessarily complex to have rule for just |
||
poetry install --sync | ||
touch $@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Read .envrc settings in parent dirs if present | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cf before. direnv would not be required, but provided here as sample file |
||
source_up | ||
|
||
# See https://github.com/direnv/direnv/wiki/Python#poetry to activate Poetry automatically | ||
layout_poetry | ||
|
||
# first load defaults and then apply any custom env vars if present, overriding defaults | ||
dotenv .env.defaults | ||
dotenv_if_exists .env | ||
|
||
# add any tools/scripts to the path | ||
PATH_add tools |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# use sane shell by default, as well as other settings | ||
SHELL := bash | ||
.SHELLFLAGS := -eu -o pipefail -c | ||
.DELETE_ON_ERROR: | ||
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules | ||
.DEFAULT_GOAL = help | ||
|
||
# location for source files | ||
SRC ?= src/ | ||
|
||
# Hack to make help rule work, given that rule has suffix ' ## <help text'. | ||
# Minor adjustments to make it work properly with included files | ||
.PHONY: help | ||
help: ## This help dialog | ||
@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}' | ||
|
||
.PHONY: grep-tech-debt | ||
grep-tech-debt: ## Grep for lines with various types of tech debt | ||
@echo "### ❗Checking for FIXMEs" | ||
@git grep --line-number --ignore-case --extended-regexp '# (fixme|xxx)' $(SRC) || echo "No FIXMEs ✅" | ||
@echo "### 🚧 Silenced issues" | ||
@git grep --line-number --ignore-case --extended-regexp '# (noqa|type: ignore|xxx)' $(SRC) || echo "No silenced issues ✅" | ||
@echo "### 🚧 TODOs" | ||
@git grep --line-number --ignore-case --extended-regexp '# (todo|tbd)' $(SRC) || echo "No TODOs ✅" | ||
|
||
###################################################################################################### | ||
# Common rules which probably should be present regardless of technologies, but implemented | ||
# in specific files or root Makefile. Avoid modifying this file, because it would be updated by the template | ||
# | ||
# Note that specifying .PHONY here means actual implementation | ||
# needs only rule body (repeating .PHONY is not needed) | ||
###################################################################################################### | ||
|
||
.PHONY: deps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another option would be to comment these by default, so that rules that are not implemented are not visible with |
||
deps: ## Set installed dependencies (including dev) to match those in the lock file | ||
|
||
.PHONY: build | ||
build: ## Build project and/or container image(s) | ||
|
||
.PHONY: build-dev | ||
build-dev: ## Build project and/or container image(s) for local development/testing | ||
|
||
# this rule should do asdf install, setup .envrc etc, anything that helps new devs in getting started | ||
.PHONY: dev-setup | ||
dev-setup: ## Prepare project ready for local development | ||
|
||
.PHONY: fmt | ||
fmt: ## Apply all automated formatters | ||
|
||
.PHONY: release | ||
release: ## Create new release | ||
|
||
.PHONY: test | ||
test: ## Run automated tests | ||
|
||
.PHONY: lint | ||
lint: ## Analyze code for issues/smells |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that nothing would require use of asdf, but it would provide more convenient flow for those who use it