Support matrix interpolation in github_commit_status context

Hi Buildkite team and forum community!

I have this job to be done: Distinguish the custom commit statuses from steps run on a matrix.

Example syntax I would like to use:

steps:
  - label: Say hello to {{matrix}}
    command: echo "Hello, {{matrix}}!"
    matrix:
      - Jill
      - Jack
    notify:
      - github_commit_status:
          context: Say hello to {{matrix}}

The result in GitHub is a status check named “Say hello to {{matrix}}” instead of two statues “Say hello to Jill” and “Say hello to Jack.”

I acknowledge that this is consistent with what the matrix docs say:

The following command step attributes can contain matrix values for interpolation:

You can’t use matrix values in other attributes, including step keys and concurrency groups.

Still, it would be nice to be able to access the matrix info at the notify.github_commit_status.context level.

Am I missing something?

Thank you for your time.

I run a couple of experiments here but wasn’t able to find a workaround.

I tried using env as a middle step to read the value, but it looks like env vars cannot be accessed in notify.github_commit_status.context either?

steps:
  - label: Dummy
    command: echo "Hello, {{matrix}}!"
    matrix:
      - matrix value 1
      - matrix value 2
    env:
      # Note: When used standalone, {{matrix}} needs to be quoted or the parsing will fail.
      MATRIX_NAME_FOR_COMMIT_STATUS: "{{matrix}}"
    notify:
      - github_commit_status:
          context: "Dummy step with $${MATRIX_NAME_FOR_COMMIT_STATUS}"

Results in “Dummy step with ${MATRIX_NAME_FOR_COMMIT_STATUS}”

image

Hi @mokagio,

Welcome to the Buildkite Support Community! :wave:

Yes, you are right matrix interpolation is currently not supported on GitHub commit statuses. The workaround that you showed looks to end up to be the same result when expanding the env var value, thus showing the same outcome.

We are currently improving on our matrix feature. Let me raise this with our product team and see if this can be considered as one of its improvements. You should hear from our product team soon.

Cheers.

Thanks @lizette

For a real world use case, the idea to interpolate in the commit status came from this PR where I wanted to customize the name of the commit status reporting on E2E tests that run on Buildkite on Mac and Windows via build matrix.

Thanks!

Hi @mokagio ,
I’m from the product team. Sorry you weren’t able to get the workaround with ENV vars working either. Right now the matrix key interpolation is somewhat limited, we’ve had feedback about using the keys in other fields too. So, thank you for sharing this feedback and we’ll include it with the other feedback when we next review matrix steps.
Cheers
Chris