5

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:

enter image description here

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?

2
  • Hey @fgalan, any luck? Commented Nov 30, 2021 at 8:08
  • I'm afraid no luck so far :( It would be great if GitHub staff could have a look to this post and tell something :) Commented Nov 30, 2021 at 10:43

1 Answer 1

7

I had a similar use case, found a simple solution:

  1. Change matrix range to a list of objects, containing order and range.
  2. Concatenate order with the job's name key.
  3. Use 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
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks! It works nicely :) As additional information, order could be also a non-numeric field, i.e. order: 'f1'
Yes, order can be anything, happy that helped!
Do you have any screenshot, How it is picking that name lable and value sometime my value taking as secrets ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.