Giter Site home page Giter Site logo

Feature: matrix support about task HOT 5 OPEN

nikaro avatar nikaro commented on August 25, 2024
Feature: matrix support

from task.

Comments (5)

pd93 avatar pd93 commented on August 25, 2024 2

@andreynering I'm inclined to agree that there is a valid use-case here even if it is only to reduce a bit of repetition. Can I propose the following syntax:

  build:all:
    desc: Build for all targets
    cmds:
      - for:
          matrix:
            ARCH: [amd64, arm64]
            OS: [linux, darwin, windows]
        cmd: go build -o build/${APP}-{{.ITEM.OS}}-{{.ITEM.ARCH}} .

This way it is any extension to the existing for functionality rather than another looping keyword. This should be relatively simple to plug into the existing code.

Edit: Also related: #675

from task.

andreynering avatar andreynering commented on August 25, 2024

Hey @nikaro,

We already have for: so you can loop though variables. That would sove your use case.

https://taskfile.dev/usage/#looping-over-values

from task.

nikaro avatar nikaro commented on August 25, 2024

Hello @andreynering,

You mean something like this?

  build:all:
    desc: Build for all targets
    vars:
      matrix:
        - os: linux
          arch: arm64
        - os: linux
          arch: amd64
        - os: darwin
          arch: arm64
        - os: darwin
          arch: darwin
        - os: windows
          arch: arm64
        - os: windows
          arch: amd64
    cmds:
      - for:
          var: matrix
        cmd: go build -o build/${APP}-{{.ITEM.os}}-{{.ITEM.arch}} .

This is a bit cleaner (as it avoids the | cut -d hack), but still a proper matrix support would be better in terms of readability :-)

from task.

andreynering avatar andreynering commented on August 25, 2024

Yeah, thinking in it as an extension to for: makes more sense 👍

from task.

vmaerten avatar vmaerten commented on August 25, 2024

I totally agree. I would add this is implemented like that in Github action and it works well

from task.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.