-
Notifications
You must be signed in to change notification settings - Fork 19
156 lines (136 loc) · 5.34 KB
/
phpunit.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
155
name: PHPUnit Tests
on:
pull_request:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
GF_LICENSE: ${{ secrets.GF_LICENSE }}
jobs:
# Runs the PHPUnit tests for WordPress.
#
# Performs the following steps:
# - Set environment variables.
# - Sets up the environment variables needed for testing with memcached (if desired).
# - Downloads the built WordPress artifact from the previous job.
# - Unzips the artifact.
# - Installs NodeJS
# - Sets up caching for NPM.
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Configures caching for Composer.
# _ Installs Composer dependencies (if desired).
# - Logs Docker debug information (about both the Docker installation within the runner).
# - Starts the WordPress Docker container.
# - Starts the memcached server after the Docker network has been created (if desired).
# - Logs WordPress Docker container debug information.
# - Logs debug general information.
# - Logs the running Docker containers.
# - Logs debug information about what's installed within the WordPress Docker containers.
# - Install WordPress within the Docker container.
# - Run the PHPUnit tests.
# - Reports test results to the Distributed Hosting Tests.
test-php:
name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
php: [ '8.3', '8.2', '8.1', '8.0', '7.4', '7.3' ]
os: [ ubuntu-latest ]
multisite: [ false ]
include:
- php: '8.3'
os: ubuntu-latest
multisite: true
- php: '8.3'
os: ubuntu-latest
multisite: false
report: true
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
steps:
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
# Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node JS
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Cache node modules
uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Log debug information
run: |
npm --version
yarn --version
node --version
curl --version
git --version
svn --version
php --version
php -i
locale -a
- name: Install Composer dependencies
run: |
composer install --prefer-dist --no-suggest --no-progress --no-ansi --no-interaction --no-scripts
echo "${PWD}/vendor/bin" >> $GITHUB_PATH
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install JS Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: yarn install
- name: Install / Setup Gravity PDF + WordPress
if: ${{ ! matrix.report }}
run: |
yarn wp-env start
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install / Setup Gravity PDF + WordPress
if: ${{ matrix.report }}
run: |
PHP_ENABLE_XDEBUG=true yarn wp-env start
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run PHPUnit tests
if: ${{ ! matrix.multisite }}
run: |
yarn test:php --do-not-cache-result --verbose
yarn test:php --group ajax --do-not-cache-result --verbose
- name: Run Multisite PHPUnit tests
if: ${{ matrix.multisite }}
run: |
yarn test:php:multisite --verbose
yarn test:php:multisite --group ajax --verbose
- name: Generate Code Coverage Report for PHP
if: ${{ matrix.report }}
run: |
yarn run test:php --do-not-cache-result --verbose --coverage-clover=/var/www/html/wp-content/plugins/gravity-pdf/tmp/coverage/report-xml/php-coverage1.xml
yarn run test:php --group ajax --do-not-cache-result --verbose --coverage-clover=/var/www/html/wp-content/plugins/gravity-pdf/tmp/coverage/report-xml/php-coverage2.xml
- name: Code Coverage Upload
uses: codecov/codecov-action@v4
if: ${{ matrix.report }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: tmp/coverage/report-xml/php-coverage1.xml