-
Notifications
You must be signed in to change notification settings - Fork 295
154 lines (142 loc) · 4.47 KB
/
php-lint-tests.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: PHP Tests
on:
push:
branches:
- develop
- main
# Only run if PHP-related files changed.
paths:
- '.github/workflows/php-lint-tests.yml'
- includes/**
- tests/phpunit/**
- '**.php'
- 'phpcs.xml.dist'
- 'phpunit*.xml*'
- 'composer.json'
- 'composer.lock'
pull_request:
branches:
- develop
- main
- 'feature/**'
# Only run if PHP-related files changed.
paths:
- '.github/workflows/php-lint-tests.yml'
- includes/**
- tests/phpunit/**
- '**.php'
- 'phpcs.xml.dist'
- 'phpunit*.xml*'
- 'composer.json'
- 'composer.lock'
types:
- opened
- reopened
- synchronize
concurrency:
group: php-lint-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Validate Composer configuration
run: composer validate --strict
- name: Composer Install
run: composer install --no-interaction --no-progress
- name: PHP Lint
run: composer lint
php-tests:
name: PHP Tests (PHP ${{ matrix.php_version }}, WordPress ${{ matrix.wp_version }}${{ matrix.wp_multisite && ', Multisite' }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
composer_php_version: ['']
php_version: ['7.4', '8.1']
wp_multisite: ['']
wp_version: ['latest']
include:
- php_version: '7.4'
wp_multisite: '1'
wp_version: 'latest'
- php_version: '7.4'
wp_version: 'nightly'
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: wordpress
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
env:
DB_HOST: 127.0.0.1
DB_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: wordpress
MYSQL_DATABASE: wordpress_test
WP_MULTISITE: ${{ matrix.wp_multisite }}
WP_VERSION: ${{ matrix.wp_version }}
steps:
- uses: actions/checkout@v4
- name: Install SVN
run: sudo apt-get update && sudo apt-get install -y subversion
- uses: shivammathur/setup-php@v2
with:
extensions: mysqli, runkit7, uopz
tools: composer:2.1
php-version: ${{ matrix.php_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ !matrix.composer_php_version }}
- uses: shivammathur/setup-php@v2
with:
tools: composer:2.1
php-version: ${{ matrix.composer_php_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ matrix.composer_php_version }}
- name: Get Composer Cache Directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer Install
run: composer install --no-interaction --no-progress
- uses: shivammathur/setup-php@v2
with:
extensions: mysqli, runkit, uopz
tools: composer:2.1
php-version: ${{ matrix.php_version }}
if: ${{ matrix.composer_php_version }}
- name: Set up PHP test data
run: tests/phpunit/bin/install-wp-tests.sh "${MYSQL_DATABASE}" "${MYSQL_USER}" "${MYSQL_PASSWORD}" "${DB_HOST}":"${DB_PORT}" "${WP_VERSION}"
- name: Run Unit Tests
run: composer test -- --verbose
if: ${{ !matrix.wp_multisite }}
- name: Run Unit Tests
run: composer test:multisite -- --verbose
if: ${{ matrix.wp_multisite }}