-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (75 loc) · 3.01 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
name: Testing
on:
push:
branches: [ dev, production ]
pull_request:
branches: [ dev ]
jobs:
functional:
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }}
strategy:
fail-fast: false
matrix:
php: [ 8.1, 8.2]
wp: ['latest']
mysql: [8.0]
runs-on: ubuntu-latest
services:
mysql:
image: mysql:${{ matrix.mysql }}
ports:
- 3306
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"
steps:
- name: Check out source code
uses: actions/checkout@v2
- name: Check existence of composer.json & behat.yml files
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "composer.json, behat.yml"
- name: Set up PHP envirnoment
if: steps.check_files.outputs.files_exists == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
extensions: mysql, zip
coverage: none
tools: composer
- name: Get Composer cache Directory
if: steps.check_files.outputs.files_exists == 'true'
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Use Composer cache
if: steps.check_files.outputs.files_exists == 'true'
uses: actions/cache@master
with:
path: ${{ steps['composer-cache'].outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
if: steps.check_files.outputs.files_exists == 'true'
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
- name: Start MySQL server
if: steps.check_files.outputs.files_exists == 'true'
run: sudo systemctl start mysql
- name: Configure DB environment
if: steps.check_files.outputs.files_exists == 'true'
run: |
export MYSQL_HOST=127.0.0.1
export MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
echo "WP_CLI_TEST_DBHOST=$MYSQL_HOST:$MYSQL_TCP_PORT" >> $GITHUB_ENV
- name: Prepare test database
if: steps.check_files.outputs.files_exists == 'true'
run: composer prepare-tests
- name: Run Behat
if: steps.check_files.outputs.files_exists == 'true'
env:
WP_VERSION: '${{ matrix.wp }}'
run: composer behat