Get length of strategy matrix (or get all matrix options)

It would be nice to be able to get the length of a matrix list. In our specific case, we use matrix runs to parallelize a suite of tests, but it requires us to configure the total number of test runner instances we will be using. e.g.

strategy:
  matrix:
    instance: [0, 1, 2]

...

env:
  TOTAL_TEST_GROUPS: 3

It would be nice to be able to either get the entire instance list and/or be able to get the length of it.

@billyvg ,

Currently, we have no methods to calculate the number of the jobs in a matrix.

I checked the  matrix context , no property for the number of the jobs. I also tried some APIs, but none of them is helpful.

I recommend you directly report a feature request here. That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

So you can get the total number of jobs with ${{ strategy.job-total }} and the current job with ${{ strategy.job-index }}

1 Like