I'm using GitHub Actions to run a workflow using a matrix strategy, as follows (simplified):
name: Functional Tests
...
jobs:
  functional:
    ...
    strategy:
      matrix:
        range:
          - -e FT_FROM_IX=0 -e FT_TO_IX=300
          - -e FT_FROM_IX=301 -e FT_TO_IX=600
          - -e FT_FROM_IX=601 -e FT_TO_IX=900
          - -e FT_FROM_IX=901 -e FT_TO_IX=1200
          - -e FT_FROM_IX=1201
    steps:
      - uses: actions/checkout@v2
      - name: Run functional test
        run: |
          docker run  --network host -t --rm ${{ matrix.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts functional
It works fine, but I get a ugly description at GitHub because the matrix.range value appears as part of the job name:

I would like to have my jobs numbered (e.g. functional-1, functional-2, etc.). Is that possible using some expression to get the index of the matrix element (something like ${{ matrix.range.index }}) or any other way?
I had a similar use case, found a simple solution:
order and range.order with the job's name key.range key as before.Hopefully, Github Actions will add an index to the matrix jobs, simplifying the way we distinguish between them.
name: Functional Tests
...
jobs:
  functional:
    name: functional - ${{ matrix.payload.order }}
    ...
    strategy:
      matrix:
        payload:
          - { order: 1, range: '-e FT_FROM_IX=0 -e FT_TO_IX=300' }
          - { order: 2, range: '-e FT_FROM_IX=301 -e FT_TO_IX=600' }
          - { order: 3, range: '-e FT_FROM_IX=601 -e FT_TO_IX=900' }
          ...
    steps:
      - uses: actions/checkout@v2
      - name: Run functional test
        run: |
          docker run  --network host -t --rm ${{ matrix.payload.range }} -v $(pwd):/opt/fiware-orion ${{ env.TEST_IMAGE_NAME }} build -miqts functional
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With