From 032c348fd1d2f10e2f956e9549cf71554ffc4998 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 3 Nov 2024 02:06:59 +0100 Subject: [PATCH] chore: start using task --- Taskfile.yml | 24 ++++++++++++++++++++++++ knowledge base/task.md | 32 +++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 Taskfile.yml diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..d48c794 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,24 @@ +--- +version: '3' + +vars: + REQUIREMENTS_FILE: requirements.txt + VENV_DIR: .venv + +tasks: + + create-venv: + cmds: + - python3.12 -m 'venv' '{{.VENV_DIR}}' + - >- + {{.VENV_DIR}}/bin/pip --require-virtualenv install -r '{{.REQUIREMENTS_FILE}}' + + recreate-venv: + cmds: + - rm -rf '{{.VENV_DIR}}' + - task: create-venv + + update-venv: + cmd: >- + {{.VENV_DIR}}/bin/pip freeze -l --require-virtualenv | sed 's/==/>=/' + | xargs {{.VENV_DIR}}/bin/pip --require-virtualenv install -U diff --git a/knowledge base/task.md b/knowledge base/task.md index 10e942e..ec8d8c4 100644 --- a/knowledge base/task.md +++ b/knowledge base/task.md @@ -4,12 +4,25 @@ Task runner aiming to be simpler and easier to use than [GNU Make]. 1. [TL;DR](#tldr) 1. [Further readings](#further-readings) + 1. [Sources](#sources) ## TL;DR +Taskfiles are Task's Makefile counterpart.
+Taskfiles are written in YAML. + +Task leverages `mvdan.cc/sh` to run commands, which is a native Go shell interpreter.
+This allows to write `sh`/`bash` commands and have them work even where `sh` or `bash` are usually not available (e.g.: +Windows) as long as any called executable is available in `PATH`. + Pros: - Taskfiles are more readable than Makefiles. + Specifically: + + - No need to use tabs. + - No need for special symbols. + - Easier environment variables management. Cons: @@ -17,13 +30,6 @@ Cons: That makes them very much similar to \[[Gitlab] / [Azure Devops]]'s pipelines, and if one has any experience with them one knows what a pain that can be. -Taskfiles are Task's Makefile counterpart.
-Taskfiles are written in YAML. - -Task uses `mvdan.cc/sh`, a native Go sh interpreter, to run commands.
-This allows to write sh/bash commands and have them work even where `sh` or `bash` are usually not available (e.g.: -Windows) as long as any called executable is available in `PATH`. -
Setup @@ -35,8 +41,9 @@ sudo dnf install 'go-task' sudo snap install 'task' --classic # Setup the shell's completion. -curl -fsSL 'https://raw.githubusercontent.com/go-task/task/main/completion/fish/task.fish' \ - -o "$HOME/.config/fish/completions/task.fish" +task --completion 'fish' > ~/'.config/fish/completions/task.fish' +task --completion 'zsh' > '/usr/local/share/zsh/site-functions/_task' +task --completion 'bash' > '/etc/bash_completion.d/task' ```
@@ -76,6 +83,11 @@ curl -fsSL 'https://raw.githubusercontent.com/go-task/task/main/completion/fish/ - [Website] - [Github] +### Sources + +- [Usage] +- [Stop Using Makefile (Use Taskfile Instead)] + [github]: https://github.com/go-task/task +[usage]: https://taskfile.dev/usage/ [website]: https://taskfile.dev/ +[stop using makefile (use taskfile instead)]: https://dev.to/calvinmclean/stop-using-makefile-use-taskfile-instead-4hm9