actions / runner

The Runner for GitHub Actions :rocket:
https://github.com/features/actions
MIT License
4.82k stars 947 forks source link

matrix include an object doesn't set object values during run #3279

Closed grooverdan closed 4 months ago

grooverdan commented 4 months ago

Describe the bug

An included matrix extension of objects like db below, failed to run the "Setup MariaDB" or "Setup MySQL" steps for the included bits of the matrix, but ran those steps correctly for the core matrix (for release: latest) just fine.

To Reproduce Steps to reproduce the behaviour:

  1. workflow

    jobs:
    integration:
    permissions:
      contents: read
    name: Integration tests
    runs-on: ubuntu-latest
    strategy:
      matrix:
        php: [ '8.1', '8.2', '8.3' ]
        db:
          - ver: mysql
            release: latest
          - ver: mariadb
            release: latest
        include:
          - php: 8.1
            db:
              - ver: mysql
                release: '5.7'
          - php: 8.1
            db:
              - ver: mariadb
                release: 10.5
      fail-fast: false
    
    steps:
      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: mbstring, gd, soap, zip, iconv, pdo_mysql
          tools: phpunit
    
      - name: Setup MariaDB
        if: ${{ matrix.db.ver == 'mariadb' }}
        uses: getong/mariadb-action@v1.1
        with:
          mariadb version: ${{ matrix.db.release }}
          mysql database: 'abantecart_test_build'
          mysql user: 'abantecart'
          mysql password: 'cartsarecool'
    
      - name: Setup MySQL
        if: ${{ matrix.db.ver == 'mysql' }}
        uses: mirromutth/mysql-action@v1.1
        with:
          mysql version: ${{ matrix.db.release }}
          mysql database: 'abantecart_test_build'
          mysql user: 'abantecart'
          mysql password: 'cartsarecool'
  2. See error image

Expected behavior

The Setup MySQL test executed for the include that has matrix.db.ver == 'mysql', and likewise for MariaDB.

Runner Version and Platform

Current runner version: '2.316.1' Operating System Ubuntu 22.04.4 LTS Runner Image Image: ubuntu-22.04 Version: 20240422.1.0

What's not working?

Skipped Setup [MySQL/MariaDB]

image

Job Log Output

covered above but:

https://github.com/grooverdan/abantecart-src/blob/d0842bb725fbb44b3f3564ca083324e2447a7b0c/.github/workflows/test.yml

resulting in:

https://github.com/grooverdan/abantecart-src/actions/runs/9012241154/job/24761135115

Runner and Worker's Diagnostic Logs

N/A

ChristopherHX commented 4 months ago

You told GitHub Actions to create matrix.db as an array, not object so remove the dash - from the include tree. The dash is only needed directly under the matrix key due to unrelated reasons.

          - php: 8.1
            db:
---              - ver: mysql
+++                ver: mysql
                release: '5.7'
          - php: 8.1
            db:
---              - ver: mariadb
+++                ver: mariadb
                release: 10.5

BTW to debug such problems just let actions print the object

    - run: ${{ tojson(matrix) }}
      shell: cat {0}
grooverdan commented 4 months ago

Thank you very much @ChristopherHX. I do need to get better at my yaml programming.