From e876be0159901803555e723805d8988d2bccd8ba Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Tue, 25 Feb 2025 20:12:16 +0300 Subject: [PATCH] chore: (task|make)file templates --- knowledge base/task.md | 2 ++ templates/Makefile | 11 +++++++++++ templates/Taskfile.yml | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 templates/Makefile create mode 100644 templates/Taskfile.yml diff --git a/knowledge base/task.md b/knowledge base/task.md index 47041db..b559f81 100644 --- a/knowledge base/task.md +++ b/knowledge base/task.md @@ -85,6 +85,7 @@ task --completion 'bash' > '/etc/bash_completion.d/task' - [Website] - [Github] +- [Demystification of taskfile variables] ### Sources @@ -109,4 +110,5 @@ task --completion 'bash' > '/etc/bash_completion.d/task' [website]: https://taskfile.dev/ +[demystification of taskfile variables]: https://medium.com/@TianchenW/demystification-of-taskfile-variables-29b751950393 [stop using makefile (use taskfile instead)]: https://dev.to/calvinmclean/stop-using-makefile-use-taskfile-instead-4hm9 diff --git a/templates/Makefile b/templates/Makefile new file mode 100644 index 0000000..9275f58 --- /dev/null +++ b/templates/Makefile @@ -0,0 +1,11 @@ +#!/usr/bin/env make + +include .env +-include .env.local + +export + +REPOSITORY_ROOT = ${shell git rev-parse --show-toplevel} + +debug-env: + @set | sort diff --git a/templates/Taskfile.yml b/templates/Taskfile.yml new file mode 100644 index 0000000..f8004a4 --- /dev/null +++ b/templates/Taskfile.yml @@ -0,0 +1,39 @@ +--- +version: '3' + +set: + - errexit # -e + - pipefail # -o pipefail + +vars: + VENV_DIR: '{{.ROOT_TASKFILE}}/.venv' + +tasks: + + dev-tools:bootstrap: + cmds: + - task: python:venv:create + - npm install + + dev-tools:update: + cmds: + - task: python:update-venv + - npm update --save + + python:venv:create: + vars: + PYTHON_VERSION: '{{.PYTHON_VERSION | default 3.12}}' + REQUIREMENTS_FILE: '{{.ROOT_TASKFILE}}/requirements.txt' + cmds: + - python{{.PYTHON_VERSION}} -m 'venv' '{{.VENV_DIR}}' + - "{{.VENV_DIR}}/bin/pip --require-virtualenv install -r '{{.REQUIREMENTS_FILE}}'" + + python:venv:recreate: + cmds: + - rm -rf '{{.VENV_DIR}}' + - task: python:venv:create + + python:venv:update: + cmd: >- + {{.VENV_DIR}}/bin/pip freeze -l --require-virtualenv | sed 's/==/>=/' + | xargs {{.VENV_DIR}}/bin/pip --require-virtualenv install -U