How to use DAG (needs:) with Matrix builds?

Let’s assume that we want to do the following:

  • build a hello world program in different ways (32-bit, 64-bit; release, debug, memcheck)
  • parse build output for hints and warnings (with all the six different configurations; I filed a ticket to simplify this part)
  • run unit tests (with all the six different configurations)
  • run other tests (we have 10 different tests with almost exact configuration that we would potentially want to run against some of those six configurations)

Before we learned about the matrix builds we used the needs: keyword (producing a DAG) to both optimize for speed (we spared a significant amount of time by not having to wait for all the jobs to finish) and to fetch the correct artefacts.

Matrix builds sound like the perfect tool to implement the above, but I don’t manage to figure out if it is possible to use the needs: keyword any longer. I don’t know how to specify the additional keywords for the “needed job”.

Or is there a better way to achieve this?

The needs: cannot currently reference a specific parallel:matrix job, as per its limitations documented here: Keyword reference for the .gitlab-ci.yml file | GitLab - It will end up depending on all the jobs.

This is the issue tracking it: Make the definition of jobs in the needs: keyword more flexible (#254821) · Issues · GitLab.org / GitLab · GitLab