-
-
Notifications
You must be signed in to change notification settings - Fork 76
95 lines (82 loc) · 2.76 KB
/
tests.yml
File metadata and controls
95 lines (82 loc) · 2.76 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
name: Unit & Integration Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
php-tests:
name: PHP ${{ matrix.php-version }}
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ["8.2", "8.3", "8.4", "8.5"]
services:
mysql:
image: mariadb:11.4
env:
MYSQL_ROOT_PASSWORD: root
ports: [3306]
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=5
container:
image: cimg/php:${{ matrix.php-version }}
options: --user root
steps:
- uses: actions/checkout@v4
- name: Set up Composer global bin path
run: |
mkdir -p "$HOME/.config/composer/vendor/bin"
echo "PATH=$HOME/.config/composer/vendor/bin:$PATH" >> $GITHUB_ENV
- name: Install System Dependencies
run: |
apt-get update && apt-get install -y subversion mariadb-client
- name: Install PHP Extensions
run: |
install-php-extensions mysqli gd bcmath || echo "Extensions may already be installed."
- name: Install Xdebug for Coverage
if: matrix.php-version == '8.3'
run: |
install-php-extensions xdebug || echo "Xdebug may already be installed."
- name: Self-update Composer
run: |
composer self-update || echo "Composer update skipped due to permission issue."
- name: Install PHP Dependencies
run: |
composer install --no-interaction --prefer-dist
- name: Wait for MySQL to be ready
run: |
for i in {1..30}; do
if mysqladmin ping -h mysql --silent; then
echo "MySQL is up"
break
fi
echo "Waiting for MySQL..."
sleep 2
done
- name: Prepare WordPress Tests
run: |
rm -rf /tmp/wordpress-tests-lib /tmp/wordpress/
bash bin/install-wp-tests.sh wordpress_test root root mysql latest
- name: Run PHPUnit Tests
if: matrix.php-version != '8.3'
run: vendor/bin/phpunit
- name: Run PHPUnit Tests with Coverage
if: matrix.php-version == '8.3'
run: |
php -d zend_extension=xdebug.so -d xdebug.mode=coverage \
vendor/bin/phpunit --coverage-clover=coverage.xml --coverage-text \
| tee coverage-summary.txt
- name: Upload coverage to Codecov
if: matrix.php-version == '8.3'
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
flags: unittests
name: php-${{ matrix.php-version }}
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}