-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (90 loc) · 3.65 KB
/
ci.yml
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: CI
on:
push:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
unit-tests:
name: "WP ${{ matrix.config.wp }}, multisite: ${{ matrix.config.ms }}, PHP: ${{ matrix.config.php }}"
if: "!contains(github.event.head_commit.message, '[ci skip]')"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
config:
- { wp: latest, ms: 'no', php: '7.4', phpunit: 7 }
- { wp: nightly, ms: 'no', php: '7.4', phpunit: 7 }
- { wp: latest, ms: 'yes', php: '7.4', phpunit: 7 }
- { wp: nightly, ms: 'yes', php: '7.4', phpunit: 7 }
- { wp: latest, ms: 'no', php: '8.0', phpunit: 9, coverage: 'yes' }
- { wp: nightly, ms: 'no', php: '8.0', phpunit: 9, coverage: 'yes' }
- { wp: latest, ms: 'yes', php: '8.0', phpunit: 9, coverage: 'yes' }
- { wp: nightly, ms: 'yes', php: '8.0', phpunit: 9, coverage: 'yes' }
services:
mysql:
image: mariadb:latest@sha256:5d851e999b84625ef9810589e832686cae58453452698ee69e2980041e626eb2
ports:
- "3306:3306"
env:
MYSQL_ROOT_PASSWORD: wordpress
MARIADB_INITDB_SKIP_TZINFO: 1
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_DATABASE: wordpress_test
steps:
- name: Check out source code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Decide whether to enable coverage
id: coverage
run: |
if [ "${{ matrix.config.coverage }}" = "yes" ]; then
echo "::set-output name=coverage::pcov"
echo '::set-output name=ini::pcov.directory=inc, pcov.exclude="~/(vendor|tests)/~"'
else
echo "::set-output name=coverage::none"
echo "::set-output name=ini::opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M"
fi
- name: Set up PHP
uses: shivammathur/setup-php@7fdd3ece872ec7ec4c098ae5ab7637d5e0a96067 # 2.26.0
with:
coverage: ${{ steps.coverage.outputs.coverage }}
ini-values: ${{ steps.coverage.outputs.ini }}
php-version: ${{ matrix.config.php }}
env:
fail-fast: 'true'
- name: Install PHPUnit
run: |
wget -q -O /usr/local/bin/phpunit "https://phar.phpunit.de/phpunit-${{ matrix.config.phpunit }}.phar"
chmod +x /usr/local/bin/phpunit
- name: Install dependencies
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # tag=2.2.0
- name: Set up WordPress and WordPress Test Library
uses: sjinks/setup-wordpress-test-library@df02a7f792eac8b75e59c3f136122de2e26bf203 # 2.0.0
with:
version: ${{ matrix.config.wp }}
- name: Set up multisite mode
run: echo "WP_MULTISITE=1" >> $GITHUB_ENV
if: matrix.config.ms == 'yes'
- name: Verify MariaDB connection
run: |
while ! mysqladmin ping -h 127.0.0.1 -P ${{ job.services.mysql.ports[3306] }} --silent; do
sleep 1
done
timeout-minutes: 1
- name: Run tests
run: |
OPTIONS=
if [ "${{ steps.coverage.outputs.coverage }}" != 'none' ]; then
OPTIONS="$OPTIONS --coverage-clover=clover.xml"
fi
phpunit --order-by=random ${OPTIONS}
- name: Upload coverage report
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
files: clover.xml
flags: unittests
if: ${{ steps.coverage.outputs.coverage != 'none' }}