-
Notifications
You must be signed in to change notification settings - Fork 191
107 lines (92 loc) · 4.95 KB
/
wordpress.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
name: WordPress Tests
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master, develop, epic/**, release/** ]
pull_request:
branches: [ master, develop, epic/**, release/** ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows you to use this workflow as part of another workflow
workflow_call:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "test"
test:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
strategy:
matrix:
php: [ 7.2, 7.4, 8.0 ]
mysql: [ 'mysql:5.7', 'mysql:8.0' ]
wordpress: [ '6.0', latest ]
services:
mysql57:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: N0Tweak!@123!
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# This was a total pain to get setup. The default authentication plugin changed in MySQL 8 and is incompatible
# with WordPress. So it needs to be set back to mysql_native_password. The best way to do this is to use the
# command option in docker to apply it once the container is set up... but Github Actions does not support this.
# The workaround is to execute the command in the options, but it is VITAL that it is the LAST option and that any
# environment variables are added via options. DO NOT ADD THE ENV LINE IN YAML. You've been warned.
# @see https://github.com/docker-library/mysql/issues/690
mysql80:
image: mysql:8.0
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=N0Tweak!@123! --entrypoint sh mysql:8.0 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
# @link https://github.com/spatie/laravel-activitylog/blob/master/.github/workflows/run-tests.yml
- name: Set Up PHP for build
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
- name: Install composer dependencies
run: composer install --no-progress --no-interaction
- name: Store MySQL details in environment
run: |
case "$MYSQL_VERSION" in
'mysql:5.7')
MYSQL_PORT=${{ job.services.mysql57.ports[3306] }}
MYSQL_PASS=N0Tweak!@123!
;;
'mysql:8.0')
MYSQL_PORT=${{ job.services.mysql80.ports[3306] }}
MYSQL_PASS=N0Tweak!@123!
;;
esac
echo "mysql_port=$MYSQL_PORT" >> $GITHUB_ENV
echo "mysql_pass=$MYSQL_PASS" >> $GITHUB_ENV
env:
MYSQL_VERSION: ${{ matrix.mysql }}
- name: Configure MySQL
run: mysql -uroot --password='${{ env.mysql_pass}}' -h127.0.0.1 --port=${{env.mysql_port}}
- name: Set Up PHP for testing
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
- name: Reload Composer autoload
run: composer dump-autoload
- name: Set Up Tests
run: bash tests/includes/bin/install.sh wordpress_test root ${{ env.mysql_pass }} 127.0.0.1:${{ env.mysql_port }} ${{ matrix.wordpress }}
- name: Run Tests
run: php -d memory_limit=-1 vendor/bin/phpunit
env:
DB_PORT: ${{ env.mysql_port }}