Skip to content

Commit c0ac7ca

Browse files
committed
Update file(s) from wp-cli/.github
1 parent db87408 commit c0ac7ca

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed

.github/workflows/testing.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Testing
2+
3+
on: pull_request
4+
5+
jobs:
6+
7+
unit: #-----------------------------------------------------------------------
8+
name: Unit test / PHP ${{ matrix.php }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
13+
runs-on: ubuntu-20.04
14+
15+
steps:
16+
- name: Check out source code
17+
uses: actions/checkout@v2
18+
19+
- name: Check existence of composer.json file
20+
id: check_files
21+
uses: andstor/file-existence-action@v1
22+
with:
23+
files: "composer.json, phpunit.xml.dist"
24+
25+
- name: Set up PHP environment
26+
if: steps.check_files.outputs.files_exists == 'true'
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: '${{ matrix.php }}'
30+
coverage: none
31+
tools: composer,cs2pr
32+
33+
- name: Get Composer cache Directory
34+
if: steps.check_files.outputs.files_exists == 'true'
35+
id: composer-cache
36+
run: |
37+
echo "::set-output name=dir::$(composer config cache-files-dir)"
38+
39+
- name: Use Composer cache
40+
if: steps.check_files.outputs.files_exists == 'true'
41+
uses: actions/cache@master
42+
with:
43+
path: ${{ steps['composer-cache'].outputs.dir }}
44+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-composer-
47+
48+
- name: Install dependencies
49+
if: steps.check_files.outputs.files_exists == 'true'
50+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
51+
52+
- name: Setup problem matcher to provide annotations for PHPUnit
53+
if: steps.check_files.outputs.files_exists == 'true'
54+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
55+
56+
- name: Run PHPUnit
57+
if: steps.check_files.outputs.files_exists == 'true'
58+
run: composer phpunit
59+
60+
functional: #----------------------------------------------------------------------
61+
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }}
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
66+
wp: ['latest']
67+
mysql: ['8.0']
68+
include:
69+
- php: '5.6'
70+
wp: 'trunk'
71+
mysql: '8.0'
72+
- php: '5.6'
73+
wp: 'trunk'
74+
mysql: '5.7'
75+
- php: '5.6'
76+
wp: 'trunk'
77+
mysql: '5.6'
78+
- php: '7.4'
79+
wp: 'trunk'
80+
mysql: '8.0'
81+
- php: '8.0'
82+
wp: 'trunk'
83+
mysql: '8.0'
84+
- php: '8.0'
85+
wp: 'trunk'
86+
mysql: '5.7'
87+
- php: '8.0'
88+
wp: 'trunk'
89+
mysql: '5.6'
90+
- php: '5.6'
91+
wp: '3.7'
92+
mysql: '5.6'
93+
runs-on: ubuntu-20.04
94+
95+
services:
96+
mysql:
97+
image: mysql:${{ matrix.mysql }}
98+
ports:
99+
- 3306
100+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
101+
102+
steps:
103+
- name: Check out source code
104+
uses: actions/checkout@v2
105+
106+
- name: Check existence of composer.json & behat.yml files
107+
id: check_files
108+
uses: andstor/file-existence-action@v1
109+
with:
110+
files: "composer.json, behat.yml"
111+
112+
- name: Install Ghostscript
113+
if: steps.check_files.outputs.files_exists == 'true'
114+
run: |
115+
sudo apt-get update
116+
sudo apt-get install ghostscript -y
117+
118+
- name: Set up PHP envirnoment
119+
if: steps.check_files.outputs.files_exists == 'true'
120+
uses: shivammathur/setup-php@v2
121+
with:
122+
php-version: '${{ matrix.php }}'
123+
extensions: gd, imagick, mysql, zip
124+
coverage: none
125+
tools: composer
126+
127+
- name: Get Composer cache Directory
128+
if: steps.check_files.outputs.files_exists == 'true'
129+
id: composer-cache
130+
run: |
131+
echo "::set-output name=dir::$(composer config cache-files-dir)"
132+
133+
- name: Use Composer cache
134+
if: steps.check_files.outputs.files_exists == 'true'
135+
uses: actions/cache@master
136+
with:
137+
path: ${{ steps['composer-cache'].outputs.dir }}
138+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
139+
restore-keys: |
140+
${{ runner.os }}-composer-
141+
142+
- name: Change ImageMagick policy to allow pdf->png conversion.
143+
if: steps.check_files.outputs.files_exists == 'true'
144+
run: |
145+
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
146+
147+
- name: Install dependencies
148+
if: steps.check_files.outputs.files_exists == 'true'
149+
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
150+
151+
- name: Start MySQL server
152+
if: steps.check_files.outputs.files_exists == 'true'
153+
run: sudo systemctl start mysql
154+
155+
- name: Configure DB environment
156+
if: steps.check_files.outputs.files_exists == 'true'
157+
run: |
158+
export MYSQL_HOST=127.0.0.1
159+
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
160+
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
161+
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
162+
echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV
163+
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
164+
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
165+
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV
166+
167+
- name: Prepare test database
168+
if: steps.check_files.outputs.files_exists == 'true'
169+
run: composer prepare-tests
170+
171+
- name: Check Behat environment
172+
if: steps.check_files.outputs.files_exists == 'true'
173+
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
174+
175+
- name: Run Behat
176+
if: steps.check_files.outputs.files_exists == 'true'
177+
env:
178+
WP_VERSION: '${{ matrix.wp }}'
179+
run: composer behat || composer behat-rerun

0 commit comments

Comments
 (0)