< Task / Taskfile >

Like GNU Make but with (YAML) superpowers

Automation with Taskfile

What is it?
Why would I use it?
Why Taskfile and not Make?

Features of Taskfile

  • Easy installation
  • Available on CIs
  • Truly cross-platform
  • Great for code generation

Pros and Cons of Taskfile

Pros:

  • Provides a simple and declarative way to define tasks.
  • It can handle a wide range of tasks and can be extended with custom scripts and plugins.
  • Modern and integrates well with popular tools.
  • Can be customized.
  • Saves time and ensures consistency.

Cons:

  • May not be suitable for extremely complex tasks.
  • There may be a learning curve for developers.

How to install

(Refer to the Official documentation)

Hombrew (MacOS and Linux)

brew install go-task/tap/go-task # Maintained by the developers
# OR
brew install go-task # Official hombrew repository

Snap

sudo snap install task --classic

NPM

npm install -g @go-task/cli

Github actions

- name: arduino/setup-task
  uses: arduino/setup-task@v1.0.3

How to use

Task will look for the following file names, in order of priority:

  • Taskfile.yml
  • Taskfile.yaml
  • Taskfile.dist.yml
  • Taskfile.dist.yaml

Basic example

version: '3'

tasks:
  build:
    cmds:
      - go build -v -i main.go

  assets:
    cmds:
      - esbuild --bundle --minify css/index.css > public/bundle.css

Running from subdirectories

version: '3'

tasks:
  up:
    dir: '{{.USER_WORKING_DIR}}'
    preconditions:
      - test -f docker-compose.yml
    cmds:
      - docker-compose up -d

Including other Taskfiles

version: '3'

includes:
  docs: ./documentation # will look for ./documentation/Taskfile.yml
  docker: ./DockerTasks.yml

Dependencies and preconditions

version: '3'

tasks:
  build:
    desc: Build the project
    cmds:
      - npm install
      - npm run build
    precondition:
      - sh: command -v npm
      - msg: "npm not found, please install it"

  test:
    desc: Run tests
    cmds:
      - task build
      - npm test
    precondition:
      - sh: command -v npm
      - msg: "npm not found, please install it"

  deploy:
    desc: Deploy the project
    cmds:
      - task test
      - npm run deploy
    deps:
      - build
      - test
    precondition:
      - sh: command -v npm
      - msg: "npm not found, please install it"

Official Documentation

https://taskfile.dev/

Thank you for your attention!

Any questions?