From 6913af459cf5cb6bd23fbcf995d7c33526d46d7c Mon Sep 17 00:00:00 2001 From: Marick van Tuil Date: Sun, 12 Apr 2026 11:01:41 +0200 Subject: [PATCH] Load matrix from JSON --- .github/workflows/run-tests.yml | 28 ++++++++++++++++++++-------- matrix.json | 10 ++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 matrix.json diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 0fb5351..3f5793a 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -57,18 +57,30 @@ jobs: throw "Action was not authorized. Exiting now." } - php-tests: + load-matrix: runs-on: ubuntu-latest needs: access_check + outputs: + db: ${{ steps.load.outputs.db }} + payload: ${{ steps.load.outputs.payload }} + steps: + - name: Checkout PR code to read matrix.json + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + - name: Load matrix + id: load + run: | + echo "db=$(jq -c '.db' matrix.json)" >> $GITHUB_OUTPUT + echo "payload=$(jq -c '.payload' matrix.json)" >> $GITHUB_OUTPUT + + php-tests: + runs-on: ubuntu-latest + needs: load-matrix strategy: matrix: - db: [ 'mysql', 'sqlite', 'pgsql' ] - payload: - - { laravel: '11.*', php: '8.3', 'testbench': '9.*', collision: '8.*' } - - { laravel: '11.*', php: '8.2', 'testbench': '9.*', collision: '8.*' } - - { laravel: '12.*', php: '8.2', 'testbench': '10.*', collision: '8.*' } - - { laravel: '12.*', php: '8.3', 'testbench': '10.*', collision: '8.*' } - - { laravel: '12.*', php: '8.4', 'testbench': '10.*', collision: '8.*' } + db: ${{ fromJson(needs.load-matrix.outputs.db) }} + payload: ${{ fromJson(needs.load-matrix.outputs.payload) }} name: PHP ${{ matrix.payload.php }} - Laravel ${{ matrix.payload.laravel }} - DB ${{ matrix.db }} diff --git a/matrix.json b/matrix.json new file mode 100644 index 0000000..20979ec --- /dev/null +++ b/matrix.json @@ -0,0 +1,10 @@ +{ + "db": ["mysql", "sqlite", "pgsql"], + "payload": [ + { "laravel": "11.*", "php": "8.3", "testbench": "9.*", "collision": "8.*" }, + { "laravel": "11.*", "php": "8.2", "testbench": "9.*", "collision": "8.*" }, + { "laravel": "12.*", "php": "8.2", "testbench": "10.*", "collision": "8.*" }, + { "laravel": "12.*", "php": "8.3", "testbench": "10.*", "collision": "8.*" }, + { "laravel": "12.*", "php": "8.4", "testbench": "10.*", "collision": "8.*" } + ] +} \ No newline at end of file