-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (83 loc) · 2.91 KB
/
tests.yml
File metadata and controls
104 lines (83 loc) · 2.91 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
name: Tests
on:
push:
branches: [ main, master, v1.x, v2.x ]
pull_request:
branches: [ main, master, v1.x, v2.x ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2, 8.3]
stability: [prefer-lowest, prefer-stable]
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: xdebug
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests (without coverage)
if: matrix.php != '8.2' || matrix.stability != 'prefer-stable'
run: composer test
- name: Execute tests (with coverage)
if: matrix.php == '8.2' && matrix.stability == 'prefer-stable'
run: composer test:coverage
- name: Upload coverage to Codecov
if: matrix.php == '8.2' && matrix.stability == 'prefer-stable'
uses: codecov/codecov-action@v3
with:
file: ./coverage.clover
fail_ci_if_error: false
code-quality:
runs-on: ubuntu-latest
name: Code Quality
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-php-8.2-composer-${{ hashFiles('composer.json') }}
- name: Install dependencies
run: composer install --prefer-dist --no-interaction
- name: Check syntax errors
run: find ./src -name "*.php" -print0 | xargs -0 -n1 -P8 php -l
- name: Check for security vulnerabilities
run: composer audit --no-dev
- name: Check if examples are working
run: |
if [ -d "examples" ]; then
echo "Found examples directory, checking syntax..."
find ./examples -name "*.php" -print0 | xargs -0 -n1 -P8 php -l
else
echo "No examples directory found, skipping..."
fi
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-php-8.2
path: |
build/
coverage.clover
retention-days: 30