-
Notifications
You must be signed in to change notification settings - Fork 68
123 lines (109 loc) · 4.08 KB
/
tests.yml
File metadata and controls
123 lines (109 loc) · 4.08 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Tests
on:
workflow_dispatch:
push:
branches:
- main
- '*.x'
pull_request:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
php: ['7.4', '8.2', '8.4']
node: ['20']
name: ${{ matrix.os }} node-${{ matrix.node }} php-${{ matrix.php }}
defaults:
run:
shell: bash
env:
extensions: curl, dom, libxml, mbstring, pcntl, pdo, pdo_sqlite, sqlite, xdebug, zip
key: cache-v1
GITHUB_ACTIONS: true
PHPUNIT_PROJECT: packages/phpunit/tests/fixtures/phpunit-stub
PEST_PROJECT: packages/phpunit/tests/fixtures/pest-stub
# Minimum PHP version per stub (used to skip incompatible installs)
PHPUNIT_MIN_PHP: v9=7.3 v10=8.1 v11=8.2 v12=8.3
PEST_MIN_PHP: v2=8.2 v3=8.2 v4=8.3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v4
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.extensions }}
tools: composer:v2
coverage: xdebug
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Cache Composer dependencies (stubs)
uses: actions/cache@v4
with:
path: |
${{ env.PHPUNIT_PROJECT }}/*/vendor
${{ env.PEST_PROJECT }}/*/vendor
key: composer-stubs-${{ matrix.os }}-php${{ matrix.php }}-${{ hashFiles('packages/phpunit/tests/fixtures/**/composer.lock') }}
restore-keys: |
composer-stubs-${{ matrix.os }}-php${{ matrix.php }}-
- name: Install Composer dependencies (PHPUnit stubs)
run: |
lookup="${{ env.PHPUNIT_MIN_PHP }}"
for dir in $(ls -d ${{ env.PHPUNIT_PROJECT }}/v*/ | sort -V); do
stub=$(basename "$dir")
min=$(echo "$lookup" | tr ' ' '\n' | grep "^${stub}=" | cut -d= -f2)
min=${min:-99}
if php -r "exit(version_compare('${{ matrix.php }}','$min','>=') ? 0 : 1);"; then
echo "::group::Installing $stub (PHP >= $min)"
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true
echo "::endgroup::"
else
echo "Skipping $stub (requires PHP >= $min, have ${{ matrix.php }})"
fi
done
- name: Install Composer dependencies (Pest stubs)
run: |
lookup="${{ env.PEST_MIN_PHP }}"
for dir in $(ls -d ${{ env.PEST_PROJECT }}/v*/ | sort -V); do
stub=$(basename "$dir")
min=$(echo "$lookup" | tr ' ' '\n' | grep "^${stub}=" | cut -d= -f2)
min=${min:-99}
if php -r "exit(version_compare('${{ matrix.php }}','$min','>=') ? 0 : 1);"; then
echo "::group::Installing $stub (PHP >= $min)"
(cd "$dir" && composer install --prefer-dist --no-interaction --no-progress) || true
echo "::endgroup::"
else
echo "Skipping $stub (requires PHP >= $min, have ${{ matrix.php }})"
fi
done
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Run the tests
run: pnpm vitest --coverage
- name: Send to codecov
if: matrix.os == 'ubuntu-latest' && matrix.php == '8.4'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/coverage-final.json
flags: unittests