From 30a0bb36b5cf8b596b3ac4f6e095635733494bc7 Mon Sep 17 00:00:00 2001 From: Edvard Majakari Date: Tue, 21 Nov 2023 16:16:29 +0200 Subject: [PATCH 1/7] standard Makefile with help texts and deps rule --- {{cookiecutter.project_slug}}/Makefile | 19 ++++++ .../tools/make/Common.mk | 63 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/Makefile create mode 100644 {{cookiecutter.project_slug}}/tools/make/Common.mk diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile new file mode 100644 index 0000000..ac2dde3 --- /dev/null +++ b/{{cookiecutter.project_slug}}/Makefile @@ -0,0 +1,19 @@ +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 to force rebuild` +.make-dev-deps: poetry.lock + poetry install --with docs --sync + touch $@ + diff --git a/{{cookiecutter.project_slug}}/tools/make/Common.mk b/{{cookiecutter.project_slug}}/tools/make/Common.mk new file mode 100644 index 0000000..7793a43 --- /dev/null +++ b/{{cookiecutter.project_slug}}/tools/make/Common.mk @@ -0,0 +1,63 @@ +# 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 ' ## Date: Tue, 21 Nov 2023 16:16:47 +0200 Subject: [PATCH 2/7] asdf config with poetry versioning --- {{cookiecutter.project_slug}}/.tool-versions | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/.tool-versions diff --git a/{{cookiecutter.project_slug}}/.tool-versions b/{{cookiecutter.project_slug}}/.tool-versions new file mode 100644 index 0000000..fe331a7 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.tool-versions @@ -0,0 +1,4 @@ +# 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 + From 9681bb9fc7646ef98ec3140e26da575631bb251d Mon Sep 17 00:00:00 2001 From: Edvard Majakari Date: Tue, 21 Nov 2023 16:17:06 +0200 Subject: [PATCH 3/7] sample direnv config file --- {{cookiecutter.project_slug}}/sample.envrc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/sample.envrc diff --git a/{{cookiecutter.project_slug}}/sample.envrc b/{{cookiecutter.project_slug}}/sample.envrc new file mode 100644 index 0000000..8170299 --- /dev/null +++ b/{{cookiecutter.project_slug}}/sample.envrc @@ -0,0 +1,12 @@ +# Read .envrc settings in parent dirs if present +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 From 34bc83c8a48bf6ef0ef203f70c71c1bf52e91d31 Mon Sep 17 00:00:00 2001 From: Edvard Majakari Date: Tue, 21 Nov 2023 16:17:24 +0200 Subject: [PATCH 4/7] common project default env vars --- {{cookiecutter.project_slug}}/.env.defaults | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/.env.defaults diff --git a/{{cookiecutter.project_slug}}/.env.defaults b/{{cookiecutter.project_slug}}/.env.defaults new file mode 100644 index 0000000..ffdee59 --- /dev/null +++ b/{{cookiecutter.project_slug}}/.env.defaults @@ -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. From 5fdac2ed2ddf5e2dc46f26e49e2430dcc7dc54d3 Mon Sep 17 00:00:00 2001 From: Edvard Majakari Date: Tue, 21 Nov 2023 16:28:09 +0200 Subject: [PATCH 5/7] pre-commit run -> fix newlines --- {{cookiecutter.project_slug}}/.tool-versions | 1 - {{cookiecutter.project_slug}}/Makefile | 1 - {{cookiecutter.project_slug}}/tools/make/Common.mk | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.tool-versions b/{{cookiecutter.project_slug}}/.tool-versions index fe331a7..edeafe2 100644 --- a/{{cookiecutter.project_slug}}/.tool-versions +++ b/{{cookiecutter.project_slug}}/.tool-versions @@ -1,4 +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 - diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index ac2dde3..a163a6d 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -16,4 +16,3 @@ deps: .make-dev-deps .make-dev-deps: poetry.lock poetry install --with docs --sync touch $@ - diff --git a/{{cookiecutter.project_slug}}/tools/make/Common.mk b/{{cookiecutter.project_slug}}/tools/make/Common.mk index 7793a43..920dfa9 100644 --- a/{{cookiecutter.project_slug}}/tools/make/Common.mk +++ b/{{cookiecutter.project_slug}}/tools/make/Common.mk @@ -60,4 +60,4 @@ docker-run: ## Run system locally with docker test: ## Run automated tests .PHONY: lint -lint: ## Analyze code for issues/smells \ No newline at end of file +lint: ## Analyze code for issues/smells From 4b09de3cd4894e51bbb809a3d3b6ca2a3ef584fc Mon Sep 17 00:00:00 2001 From: Edvard Majakari Date: Wed, 22 Nov 2023 11:42:00 +0200 Subject: [PATCH 6/7] remove --with-docs --- {{cookiecutter.project_slug}}/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/Makefile b/{{cookiecutter.project_slug}}/Makefile index a163a6d..c642975 100644 --- a/{{cookiecutter.project_slug}}/Makefile +++ b/{{cookiecutter.project_slug}}/Makefile @@ -14,5 +14,5 @@ deps: .make-dev-deps # 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 to force rebuild` .make-dev-deps: poetry.lock - poetry install --with docs --sync + poetry install --sync touch $@ From e6715e6730a8c5f89ba676fd9f433f89dcc0e74e Mon Sep 17 00:00:00 2001 From: Edvard Majakari Date: Wed, 22 Nov 2023 11:46:17 +0200 Subject: [PATCH 7/7] remove local-run and docker-run stubs --- {{cookiecutter.project_slug}}/tools/make/Common.mk | 6 ------ 1 file changed, 6 deletions(-) diff --git a/{{cookiecutter.project_slug}}/tools/make/Common.mk b/{{cookiecutter.project_slug}}/tools/make/Common.mk index 920dfa9..87d6fac 100644 --- a/{{cookiecutter.project_slug}}/tools/make/Common.mk +++ b/{{cookiecutter.project_slug}}/tools/make/Common.mk @@ -50,12 +50,6 @@ fmt: ## Apply all automated formatters .PHONY: release release: ## Create new release -.PHONY: local-run -local-run: ## Run system locally without docker - -.PHONY: docker-run -docker-run: ## Run system locally with docker - .PHONY: test test: ## Run automated tests