It's possible to not run every version in the matrix?

I want to not run every version of python settled at the matrix depending on the file that was modified on the pull request. This could be done?

Hi @luchiago , 

There is a new function fromJson() to dynamicly set matrix setting.

You could add another job to get the changed file on the pull request and then set matrix setting depending on it. 

There is a previous ticket for finding pull request file changes : https://github.community/t5/GitHub-Actions/Get-list-of-files-on-pull-request-merge/td-p/41570 

Then you could follow my example workflow to set python version in matrix .

jobs:
  getchange:
   outputs:
      matrix: ${{ steps.changes.outputs.matrix }}
   runs-on: ubuntu-latest
   steps:
     - id: changes
       ## set matrix value based on file changes
       run: |
         ....... // write your script to get file change then set matrix value
         echo "::set-output name=matrix::{\"include\":[{\"python\":\"3.5\" },{\"python\":\"3.7\"}]}"
  build:
    needs: [getchange]
    runs-on: ubuntu-latest
    strategy:
      matrix: ${{ fromJson(needs.getchange.outputs.matrix) }}

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
1 Like

Thanks, @yanjingzhu, I will implement your suggestion and see if fits the project and give you feedback about it.

Hi @luchiago,
Does fromJson() function work for you? Is there any other questions you need help?

1 Like

Yes, it did. Thank you so much for your help. I don’t have any other questions.