Matrix feature improvements

I’ve been trying out the matrix feature and like it, but there are a few things that could be improved to make it a lot more robust:

  1. Allow interpolation of {{matrix}} in the env section
    We’ve have to work around this by doing command: env FOO={{matrix}} /path/to/my/command

  2. Allow more than 20 matrix items
    Our work around is to create 2 steps to split bigger lists. But that requires copy pasting and doesn’t seem necessary.

I’ve found a few bugs along the way:

  • Clicking Retry on any step generated via the matrix will retry the whole matrix. It should only retry a single step, or at least I think this would make more sense.
  • You can’t specify any env block if you have a matrix (even without interpolation). This produces 500s from your API.

Hey @jeromegn!

Welcome to the community! :blush:

Thank you for all your feedback!. We’ll share your comments with our product team :slight_smile:

Best!

It also doesn’t appear to work with the key or the agents block either. Unfortunately i can’t figure out a way to work around this.

Hi @simonbyrne,

Currently interpolation of the matrix values into command step attributes such as environment variables, labels and commands is supported so for attributes such as key or agents block it is not currently supported.

I will share this feedback with our product team :slightly_smiling_face:

Thank you

I’d also like to see matrix values be interpolated into key steps. This would def help with step dependencies. Ex: build binary X, Y then test binary X, Y. Right now you have to wait for all build steps in a group to finish before the test the binary because you can not provide it with a dependency step.

Hey @moose

Welcome to the community, thanks for reaching out!

You are correct that the matrix does not support using step keys. Group steps might fit into your use case because you can use the steps keys as well as the depends_on attributes, this is just going off a general assumption(without knowing the use case). However I can raise a request on this feedback

Cheers!

Hi @moose thanks heaps for your feedback. I am from the product team at Buildkite. I would love to hear what you think of what @stephanie.atte suggested with regards to groups and if it actually would solve your use case. If it doesn’t could you explain your use case a bit better so we understand the limitations better?

Have a great day!

Hi @Ozdenyilmaz,

Thats what we currently do. The feature i’d like to see is setting a key based on matrix value interpolation.
Current structure:

  - group: ":building_construction: Build"
    key: build
    depends_on:
      - setup
    steps:
      - label: ":building_construction: Build {{matrix.os}} {{matrix.arch}}"
        env:
          GOOS: "{{matrix.os}}"
          GOARCH: "{{matrix.arch}}"
        commands:
          - ./scripts/build build $$GOOS $$GOARCH
          - buildkite-agent artifact upload bin/*
        matrix:
          setup:
            os:
              - linux
              - darwin
              - windows
            arch:
              - amd64
              - arm64

 - group: ":jfrog: Audit"
    steps: 
      - label: ":jfrog: Scan Binary {{matrix.extension}} {{matrix.goarch}}"
        depends_on:
          - build
        commands:
          - set -e
          - buildkite-agent artifact download bin/{{matrix.goarch}}.{{matrix.os}} .
          - ./scripts/scan scan_binary bin/{{matrix.goarch}}.{{matrix.os}}
        matrix:
          setup:
            os:
              - linux
              - darwin
              - windows
            arch:
              - amd64
              - arm64

Because matrix interpolation can not drive step keys the scan group must wait for all binaries to be build before jobs can be scheduled. If steps inside a group could have keys based on the matrix then i could have scan steps be dispatched as soon as the binary has been built.

Hi @moose , I definitely understand the problem. I am going to chat with the team about it, but I’ll be honest at this point it doesn’t look like we will end up getting to this till early 2024. I’ll update you if anything changes in the meantime.
Have a great day!