-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.21 KB
/
tests.yml
File metadata and controls
75 lines (63 loc) · 2.21 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
name: Tests
on:
push:
branches: [ main, new_api ]
pull_request:
branches: [ main, new_api ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [8.4]
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, json, pcov, bcmath
coverage: pcov
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y bc
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run PHPUnit tests
run: ./vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
- name: Check PHPUnit coverage
run: |
COVERAGE=$(php -r "
\$xml = simplexml_load_file('coverage.xml');
\$metrics = \$xml->xpath('//metrics[@elements and @coveredelements]')[0];
\$covered = (float)\$metrics['coveredelements'];
\$total = (float)\$metrics['elements'];
\$percentage = (\$total > 0) ? (\$covered / \$total) * 100 : 0;
echo number_format(\$percentage, 2);
")
echo "PHPUnit Coverage: $COVERAGE%"
if (( $(echo "$COVERAGE < 95" | bc -l) )); then
echo "❌ PHPUnit coverage is $COVERAGE%, expected 95%"
exit 1
else
echo "✅ PHPUnit coverage is 95% or higher"
fi
- name: Run Behat tests
run: ./vendor/bin/behat --no-colors --strict
- name: Verify Behat results
run: |
BEHAT_RESULT=$(./vendor/bin/behat --no-colors --strict | tail -n 3)
echo "Behat results: $BEHAT_RESULT"
if echo "$BEHAT_RESULT" | grep -q "failed"; then
echo "❌ Some Behat scenarios failed"
exit 1
else
echo "✅ All Behat scenarios passed"
fi