-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (86 loc) · 2.88 KB
/
test.yml
File metadata and controls
99 lines (86 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Tests and Checks
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- ready_for_review
jobs:
php-matrix:
name: Resolve PHP matrix
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.php-matrix.outputs.versions }}
steps:
- name: Checkouting code...
uses: actions/checkout@v6
with:
sparse-checkout: composer.json
sparse-checkout-cone-mode: false
- name: Installing PHP...
uses: shivammathur/setup-php@2.37.0
with:
php-version: '8.4'
coverage: none
tools: composer:v2
- name: Create php-matrix composer file...
shell: bash
run: |
package_constraint=$(php -r 'echo json_decode(file_get_contents("composer.json"), true)["require"]["clean/phpdoc-md"];')
php_constraint=$(composer show clean/phpdoc-md "$package_constraint" --all --format=json | php -r '$pkg = json_decode(stream_get_contents(STDIN), true); echo $pkg["requires"]["php"];')
php -r 'file_put_contents("composer.php-matrix.json", json_encode(["require" => ["php" => $argv[1]]], JSON_UNESCAPED_SLASHES));' "$php_constraint"
- name: Generating PHP matrix...
id: php-matrix
uses: typisttech/php-matrix-action@v2
with:
composer-json: composer.php-matrix.json
source: php.net
test:
name: Test (PHP ${{ matrix.php }})
needs:
- php-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 5
matrix:
php: ${{ fromJSON(needs.php-matrix.outputs.versions) }}
steps:
- name: Checkouting code...
uses: actions/checkout@v6
- name: Detecting Composer major...
id: composer-major
env:
PHP_VERSION: ${{ matrix.php }}
shell: bash
run: |
case "$PHP_VERSION" in
5.*|7.0|7.1|7.2|7.3)
echo "value=v1" >> "$GITHUB_OUTPUT"
;;
*)
echo "value=v2" >> "$GITHUB_OUTPUT"
;;
esac
- name: Skipping tests for Composer v1 runtimes...
if: ${{ steps.composer-major.outputs.value == 'v1' }}
run: echo "Skipping PHP ${{ matrix.php }} because Composer v1 is EOL and unsupported by Packagist."
- name: Installing PHP...
if: ${{ steps.composer-major.outputs.value == 'v2' }}
uses: shivammathur/setup-php@2.37.0
with:
php-version: ${{ matrix.php }}
extensions: curl, gd, json, mbstring, pcre, session
coverage: none
tools: composer:v2
- name: Setup BATS
if: ${{ steps.composer-major.outputs.value == 'v2' }}
uses: mig4/setup-bats@v1
with:
bats-version: 1.8.2
- name: Test
if: ${{ steps.composer-major.outputs.value == 'v2' }}
run: bats tests