Skip to content

Commit fd58602

Browse files
Merge pull request #193 from stackkit/feature/matrix-from-json
Load matrix from JSON
2 parents 4dea19c + 35a28f9 commit fd58602

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed

.github/workflows/run-tests.yml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,30 @@ jobs:
5757
throw "Action was not authorized. Exiting now."
5858
}
5959
60-
php-tests:
60+
load-matrix:
6161
runs-on: ubuntu-latest
6262
needs: access_check
63+
outputs:
64+
db: ${{ steps.load.outputs.db }}
65+
payload: ${{ steps.load.outputs.payload }}
66+
steps:
67+
- name: Checkout PR code to read matrix.json
68+
uses: actions/checkout@v4
69+
with:
70+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
71+
- name: Load matrix
72+
id: load
73+
run: |
74+
echo "db=$(jq -c '.db' matrix.json)" >> $GITHUB_OUTPUT
75+
echo "payload=$(jq -c '.payload' matrix.json)" >> $GITHUB_OUTPUT
76+
77+
php-tests:
78+
runs-on: ubuntu-latest
79+
needs: load-matrix
6380
strategy:
6481
matrix:
65-
db:
66-
- { driver: 'mysql', version: '8.0' }
67-
- { driver: 'mysql', version: '8.4' }
68-
- { driver: 'pgsql', version: '14' }
69-
- { driver: 'pgsql', version: '15' }
70-
- { driver: 'pgsql', version: '16' }
71-
- { driver: 'pgsql', version: '17' }
72-
payload:
73-
- { queue: 'github-actions-laravel11-php82', laravel: '11.*', php: '8.2', 'testbench': '9.*' }
74-
- { queue: 'github-actions-laravel11-php83', laravel: '11.*', php: '8.3', 'testbench': '9.*' }
75-
- { queue: 'github-actions-laravel11-php84', laravel: '11.*', php: '8.4', 'testbench': '9.*' }
76-
- { queue: 'github-actions-laravel12-php82', laravel: '12.*', php: '8.2', 'testbench': '10.*' }
77-
- { queue: 'github-actions-laravel12-php83', laravel: '12.*', php: '8.3', 'testbench': '10.*' }
78-
- { queue: 'github-actions-laravel12-php84', laravel: '12.*', php: '8.4', 'testbench': '10.*' }
82+
db: ${{ fromJson(needs.load-matrix.outputs.db) }}
83+
payload: ${{ fromJson(needs.load-matrix.outputs.payload) }}
7984

8085
name: PHP ${{ matrix.payload.php }} - Laravel ${{ matrix.payload.laravel }} - DB ${{ matrix.db.driver }} ${{ matrix.db.version }}
8186

@@ -102,6 +107,7 @@ jobs:
102107
elif [ "${{ matrix.db.driver }}" = "pgsql" ]; then
103108
POSTGRES_PORT=5432 PGSQL_VERSION=${{ matrix.db.version }} docker compose up ${{ matrix.db.driver }} -d
104109
fi
110+
105111
- name: Install dependencies
106112
run: |
107113
composer require "laravel/framework:${{ matrix.payload.laravel }}" "orchestra/testbench:${{ matrix.payload.testbench }}" --no-interaction --no-update
@@ -114,6 +120,7 @@ jobs:
114120
else
115121
echo "Not waiting for MySQL."
116122
fi
123+
117124
- name: Execute tests
118125
env:
119126
DB_DRIVER: ${{ matrix.db.driver }}
@@ -127,4 +134,4 @@ jobs:
127134
run: |
128135
echo $CI_SERVICE_ACCOUNT_JSON_KEY > tests/Support/gcloud-key-valid.json
129136
touch .env
130-
vendor/bin/phpunit
137+
vendor/bin/phpunit

matrix.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"db": [
3+
{ "driver": "mysql", "version": "8.0" },
4+
{ "driver": "mysql", "version": "8.4" },
5+
{ "driver": "pgsql", "version": "14" },
6+
{ "driver": "pgsql", "version": "15" },
7+
{ "driver": "pgsql", "version": "16" },
8+
{ "driver": "pgsql", "version": "17" }
9+
],
10+
"payload": [
11+
{ "queue": "github-actions-laravel11-php82", "laravel": "11.*", "php": "8.2", "testbench": "9.*" },
12+
{ "queue": "github-actions-laravel11-php83", "laravel": "11.*", "php": "8.3", "testbench": "9.*" },
13+
{ "queue": "github-actions-laravel11-php84", "laravel": "11.*", "php": "8.4", "testbench": "9.*" },
14+
{ "queue": "github-actions-laravel12-php82", "laravel": "12.*", "php": "8.2", "testbench": "10.*" },
15+
{ "queue": "github-actions-laravel12-php83", "laravel": "12.*", "php": "8.3", "testbench": "10.*" },
16+
{ "queue": "github-actions-laravel12-php84", "laravel": "12.*", "php": "8.4", "testbench": "10.*" }
17+
]
18+
}

0 commit comments

Comments
 (0)