Skip to content

Commit

Permalink
[PHP] Move os matrix build to php
Browse files Browse the repository at this point in the history
  • Loading branch information
Den4ik committed Jan 29, 2025
1 parent 57fe130 commit 55198b0
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 107 deletions.
108 changes: 30 additions & 78 deletions .github/workflows/docker-image-php-fpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
container:
image: php:8.4-cli-alpine
outputs:
include: ${{ steps.matrix.outputs.include }}
matrix: ${{ steps.matrix.outputs.matrix }}
env:
PHP_LATEST: ${{ vars.PHP_LATEST }}
PHP_VERSIONS: ${{ vars.PHP_VERSIONS }}
Expand All @@ -29,15 +29,15 @@ jobs:
- id: matrix
run: |
php .github/workflows/php-matrix/php-generator.php >> $GITHUB_OUTPUT
- run: echo "Matrix:\n";echo '${{ steps.matrix.outputs.include }}'
- run: echo "Matrix:\n";echo '${{ steps.matrix.outputs.matrix }}'

node-matrix:
name: Generate Base PHP-Node Matrix
runs-on: ubuntu-latest
container:
image: php:8.4-cli-alpine
outputs:
include: ${{ steps.matrix.outputs.include }}
matrix: ${{ steps.matrix.outputs.matrix }}
env:
PHP_LATEST: ${{ vars.PHP_LATEST }}
PHP_VERSIONS: ${{ vars.PHP_VERSIONS }}
Expand All @@ -49,15 +49,15 @@ jobs:
- id: matrix
run: |
php .github/workflows/php-matrix/node-generator.php >> $GITHUB_OUTPUT
- run: echo "Matrix:\n";echo '${{ steps.matrix.outputs.include }}'
- run: echo "Matrix:\n";echo '${{ steps.matrix.outputs.matrix }}'

full-matrix:
name: Generate Full Matrix
runs-on: ubuntu-latest
container:
image: php:8.4-cli-alpine
outputs:
include: ${{ steps.matrix.outputs.include }}
matrix: ${{ steps.matrix.outputs.matrix }}
env:
PHP_LATEST: ${{ vars.PHP_LATEST }}
PHP_VERSIONS: ${{ vars.PHP_VERSIONS }}
Expand All @@ -69,7 +69,7 @@ jobs:
- id: matrix
run: |
php .github/workflows/php-matrix/full-generator.php >> $GITHUB_OUTPUT
- run: echo "Matrix:\n";echo '${{ steps.matrix.outputs.include }}'
- run: echo "Matrix:\n";echo '${{ steps.matrix.outputs.matrix }}'

php-fpm:
needs: php-matrix
Expand All @@ -78,9 +78,7 @@ jobs:
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.php-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.php-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -121,9 +119,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 6 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.node-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.node-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -163,9 +159,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -206,9 +200,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -249,9 +241,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -291,9 +281,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -333,9 +321,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -375,9 +361,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -417,9 +401,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -459,9 +441,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -501,9 +481,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -544,9 +522,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -587,9 +563,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -629,9 +603,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -671,9 +643,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -713,9 +683,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -755,9 +723,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -797,9 +763,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -839,9 +803,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -882,9 +844,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -925,9 +885,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -967,9 +925,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -1009,9 +965,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -1051,9 +1005,7 @@ jobs:
strategy:
fail-fast: false
max-parallel: ${{ github.ref == 'refs/heads/main' && 2 || 0 }}
matrix:
os: ${{ fromJson(vars.RUN_ON_OS) }}
include: ${{ fromJson(needs.full-matrix.outputs.include) }}
matrix: ${{ fromJson(needs.full-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/php-matrix/constants.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

$osVersions = explode(',', getenv('RUN_ON_OS'));
$phpLatest = getenv('PHP_LATEST');
$phpVersions = explode(',', getenv('PHP_VERSIONS'));
$nodeLatest = getenv('NODE_LATEST');
Expand Down
30 changes: 17 additions & 13 deletions .github/workflows/php-matrix/full-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

include(__DIR__ . DIRECTORY_SEPARATOR . 'constants.php');

global $phpLatest, $phpVersions, $nodeLatest, $nodeVersions, $notStableXdebugPhpVersions;
global $osVersions, $phpLatest, $phpVersions, $nodeLatest, $nodeVersions, $notStableXdebugPhpVersions;
$matrix = [];

foreach ($phpVersions as $phpVersion) {
$xdebugType = !in_array($phpVersion, $notStableXdebugPhpVersions) ? 'xdebug-stable' : 'xdebug';
$matrix[] = [
'php_version' => $phpVersion,
'node_version' => 'x',
'xdebug_type' => $xdebugType,
'latest' => $phpVersion === $phpLatest,
];
foreach ($nodeVersions as $nodeVersion) {
foreach ($osVersions as $osVersion) {
foreach ($phpVersions as $phpVersion) {
$xdebugType = !in_array($phpVersion, $notStableXdebugPhpVersions) ? 'xdebug-stable' : 'xdebug';
$matrix[] = [
'os' => $osVersion,
'php_version' => $phpVersion,
'node_version' => $nodeVersion,
'node_version' => 'x',
'xdebug_type' => $xdebugType,
'latest' => $phpVersion === $phpLatest && $nodeVersion === $nodeLatest,
'latest' => $phpVersion === $phpLatest,
];
foreach ($nodeVersions as $nodeVersion) {
$matrix[] = [
'os' => $osVersion,
'php_version' => $phpVersion,
'node_version' => $nodeVersion,
'xdebug_type' => $xdebugType,
'latest' => $phpVersion === $phpLatest && $nodeVersion === $nodeLatest,
];
}
}
}

echo 'include=' . json_encode($matrix);
echo 'matrix=' . json_encode(['include' => $matrix]);
21 changes: 12 additions & 9 deletions .github/workflows/php-matrix/node-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

require_once(__DIR__ . DIRECTORY_SEPARATOR . 'constants.php');

global $phpLatest, $phpVersions, $nodeLatest, $nodeVersions;
global $osVersions, $phpLatest, $phpVersions, $nodeLatest, $nodeVersions;
$matrix = [];

foreach ($phpVersions as $phpVersion) {
foreach ($nodeVersions as $nodeVersion) {
$matrix[] = [
'php_version' => $phpVersion,
'node_version' => $nodeVersion,
'latest' => $phpVersion === $phpLatest && $nodeVersion === $nodeLatest,
];
foreach ($osVersions as $osVersion) {
foreach ($phpVersions as $phpVersion) {
foreach ($nodeVersions as $nodeVersion) {
$matrix[] = [
'os' => $osVersion,
'php_version' => $phpVersion,
'node_version' => $nodeVersion,
'latest' => $phpVersion === $phpLatest && $nodeVersion === $nodeLatest,
];
}
}
}

echo 'include=' . json_encode($matrix);
echo 'matrix=' . json_encode(['include' => $matrix]);
Loading

0 comments on commit 55198b0

Please sign in to comment.