-
Notifications
You must be signed in to change notification settings - Fork 87
90 lines (77 loc) · 2.84 KB
/
php-lint-and-test.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
name: PHP Lint & Test
on:
pull_request:
# Prevent this workflow from running on pull requests to barista branch
branches-ignore:
- 'barista'
paths:
- '**/*.php'
jobs:
php-lint:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ '7.2' ]
name: Lint with PHP ${{ matrix.php-version }}
steps:
- name: Checkout and set up LAMP
uses: eventespresso/actions/packages/checkout-and-LAMP@main
with:
cache-key: ${{ runner.os }}-${{ secrets.GH_ACTIONS_CACHE_VERSION }}-lint
php-tools: composer:v2
php-version: ${{ matrix.php-version }}
- name: PHP Lint
run: composer config-eventespressocs --ansi && composer run-script lint:skip-warnings --ansi
php-unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
name: Unit Tests with PHP ${{ matrix.php-version }}
steps:
- name: Set WP version for PHP 7
if: ${{ startsWith( matrix.php-version, '7.' ) }}
run: |
echo "WP_VERSION=5.8.2" >> $GITHUB_ENV
- name: Set WP version for PHP 8+
if: ${{ startsWith( matrix.php-version, '8.' ) }}
run: |
echo "WP_VERSION=latest" >> $GITHUB_ENV
- name: Set Composer version for PHP
run: |
echo "COMPOSER_VERSION=v2" >> $GITHUB_ENV
- name: Set PHPUnit version for WP < 5.9
if: ${{ env.WP_VERSION == '5.8.2' }}
run: |
echo "PHPUNIT_VERSION=v7" >> $GITHUB_ENV
- name: Set PHPUnit version for WP >= 5.9
if: ${{ env.WP_VERSION == 'latest' }}
run: |
echo "PHPUNIT_VERSION=v9" >> $GITHUB_ENV
- name: Checkout and set up LAMP
uses: eventespresso/actions/packages/checkout-and-LAMP@main
with:
cache-key: ${{ runner.os }}-${{ secrets.GH_ACTIONS_CACHE_VERSION }}-${{ env.WP_VERSION }}-test
php-tools: composer:${{ env.COMPOSER_VERSION }}, phpunit:${{ env.PHPUNIT_VERSION }}, phpunit-polyfills
php-version: ${{ matrix.php-version }}
- name: Install WP Tests
uses: eventespresso/actions/packages/install-wp-tests@main
with:
wp-version: ${{ env.WP_VERSION }}
database: wordpress_test
username: root
password: root
host: localhost
- name: Run PHPUnit Tests
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
run: |
phpunit --version
phpunit --configuration tests/phpunit.xml
# allow failure for PHP 8.1
continue-on-error: ${{ matrix.php-version == 8.1 }}
# run multisite test only with 1 PHP version
- if: ${{ matrix.php-version == '7.4' }}
name: Run PHPUnit Tests - WP Multisite
env:
WP_MULTISITE: 1
run: phpunit --configuration tests/phpunit.xml