Skip to content

Commit b629634

Browse files
authored
Add optional workflow (#548)
* Add optional workflow * Add optional workflow
1 parent 5383cf7 commit b629634

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

.github/workflows/tests.yml

+27-10
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,39 @@ jobs:
111111
run: |
112112
vendor/bin/phpunit tests/ --no-coverage
113113
114+
define-matrix:
115+
name: "Define Matrix"
116+
runs-on: ubuntu-latest
117+
outputs:
118+
php: ${{ steps.gendef.outputs.php }}
119+
os: ${{ steps.gendef.outputs.os }}
120+
steps:
121+
- name: "Checkout"
122+
uses: actions/checkout@v4
123+
124+
- name: "Setup PHP"
125+
uses: shivammathur/setup-php@v2
126+
with:
127+
php-version: 8.2
128+
129+
- name: Define
130+
id: gendef
131+
run: |
132+
PHP_VERSIONS=$(php src/globals/test-extensions.php php)
133+
OS_VERSIONS=$(php src/globals/test-extensions.php os)
134+
echo 'php='"$PHP_VERSIONS" >> "$GITHUB_OUTPUT"
135+
echo 'os='"$OS_VERSIONS" >> "$GITHUB_OUTPUT"
136+
137+
114138
build:
115139
name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})"
116140
runs-on: ${{ matrix.os }}
141+
needs: define-matrix
117142
timeout-minutes: 120
118143
strategy:
119144
matrix:
120-
php:
121-
- "8.0"
122-
- "8.1"
123-
- "8.2"
124-
- "8.3"
125-
os:
126-
- ubuntu-latest
127-
- macos-13
128-
- windows-latest
129-
- macos-14
145+
php: ${{ fromJSON(needs.define-matrix.outputs.php) }}
146+
os: ${{ fromJSON(needs.define-matrix.outputs.os) }}
130147
fail-fast: false
131148
steps:
132149
- name: "Checkout"

src/globals/test-extensions.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
// --------------------------------- edit area ---------------------------------
1313

14+
$test_php_version = ['8.3'];
15+
16+
$test_os = ['macos-13', 'macos-14', 'ubuntu-latest', 'windows-latest'];
17+
1418
$zts = false;
1519

1620
$no_strip = false;
@@ -58,7 +62,7 @@ function _getCombination(string $type = 'common'): string
5862
}
5963

6064
if (!isset($argv[1])) {
61-
exit("Please use 'extensions', 'cmd' or 'libs' as output type");
65+
exit("Please use 'extensions', 'cmd', 'os', 'php' or 'libs' as output type");
6266
}
6367

6468
$trim_value = "\r\n \t,";
@@ -73,6 +77,8 @@ function _getCombination(string $type = 'common'): string
7377
}
7478

7579
echo match ($argv[1]) {
80+
'os' => json_encode($test_os),
81+
'php' => json_encode($test_php_version),
7682
'extensions' => $final_extensions,
7783
'libs' => $final_libs,
7884
'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)),

0 commit comments

Comments
 (0)